|
|
|
@ -22,10 +22,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
@ -46,7 +43,7 @@ public class CompanyQnTitleServiceImpl extends ServiceImpl<CompanyQnTitleMapper,
|
|
|
|
|
// 列表
|
|
|
|
|
public Result<List<ResultQnTitleList>> qnTitleList(int qnId) {
|
|
|
|
|
QueryWrapper<CompanyQnTitle> qw = new QueryWrapper<>();
|
|
|
|
|
qw.eq("qn_id", qnId).orderByDesc("id");
|
|
|
|
|
qw.eq("qn_id", qnId).orderByAsc("id");
|
|
|
|
|
List<CompanyQnTitle> list = super.list(qw);
|
|
|
|
|
List <ResultQnTitleList> result = new ArrayList<>();
|
|
|
|
|
for (CompanyQnTitle r : list) {
|
|
|
|
@ -99,27 +96,42 @@ public class CompanyQnTitleServiceImpl extends ServiceImpl<CompanyQnTitleMapper,
|
|
|
|
|
// 添入题库题目
|
|
|
|
|
public Result qnTitleAddModel(CompanyQnTitleController.paramsQnTitleAddModel params) {
|
|
|
|
|
Integer qnId = params.getQnId();
|
|
|
|
|
// 已有题型id列表
|
|
|
|
|
List<CompanyQnTitle> cList = super.list(new QueryWrapper<CompanyQnTitle>().select("title_id").eq("qn_id", qnId));
|
|
|
|
|
HashSet<Integer> idList = new HashSet<>();
|
|
|
|
|
ArrayList<CompanyQnTitle> list = new ArrayList<>();
|
|
|
|
|
for (CompanyQnTitle i : cList) {
|
|
|
|
|
idList.add(i.getTitleId());
|
|
|
|
|
}
|
|
|
|
|
// 待加入题型数组
|
|
|
|
|
Collection ids = new ArrayList<>();
|
|
|
|
|
HashMap<Integer, QnTitle> titleList = new HashMap();
|
|
|
|
|
if (params.getTitleIds().length > 0) {
|
|
|
|
|
for (int i : params.getTitleIds()) {
|
|
|
|
|
ids.add(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Collection<QnTitle> qnTitles = qnTitleService.listByIds(ids);
|
|
|
|
|
for (QnTitle qnTitle : qnTitles) {
|
|
|
|
|
titleList.put(qnTitle.getId(),qnTitle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 批量加入
|
|
|
|
|
for (int titleId : params.getTitleIds()) {
|
|
|
|
|
if(idList.contains(titleId)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
QnTitle qnTitle = qnTitleService.getById(titleId);
|
|
|
|
|
if (null == qnTitle) {
|
|
|
|
|
return Result.err("未知题型");
|
|
|
|
|
if (null ==titleList.get(titleId)){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
QnTitle i = titleList.get(titleId);
|
|
|
|
|
CompanyQnTitle companyQnTitle = new CompanyQnTitle()
|
|
|
|
|
.setQnId(params.getQnId())
|
|
|
|
|
.setTitleId(qnTitle.getId())
|
|
|
|
|
.setTitle(qnTitle.getTitle())
|
|
|
|
|
.setKind(qnTitle.getKind())
|
|
|
|
|
.setGroupId(qnTitle.getGroupId()==1?CompanyQnTitle.ManageQnTitleBase:CompanyQnTitle.ManageQnTitleNotBase)
|
|
|
|
|
.setOptions(qnTitle.getOptions());
|
|
|
|
|
.setTitleId(i.getId())
|
|
|
|
|
.setTitle(i.getTitle())
|
|
|
|
|
.setKind(i.getKind())
|
|
|
|
|
.setGroupId(i.getGroupId()==1?CompanyQnTitle.ManageQnTitleBase:CompanyQnTitle.ManageQnTitleNotBase)
|
|
|
|
|
.setOptions(i.getOptions());
|
|
|
|
|
list.add(companyQnTitle);
|
|
|
|
|
}
|
|
|
|
|
super.saveBatch(list);
|
|
|
|
|