|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ynfy.buss.exam.paper.enmus.JoinType;
|
|
|
import com.ynfy.buss.exam.paperquestion.service.IPaperQuestionService;
|
|
|
import com.ynfy.buss.exam.paperruledetail.dto.RuleDetailDTO;
|
|
|
import com.ynfy.buss.exam.paperruledetail.entity.PaperRuleDetail;
|
|
@@ -21,6 +22,7 @@ import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -202,24 +204,33 @@ public class QuestionController extends JeecgController<Question, IQuestionServi
|
|
|
*/
|
|
|
@ApiOperation(value = "题目-按照难度分组查询", notes = "题目-按照难度分组查询")
|
|
|
@PostMapping(value = "/groupLevelById")
|
|
|
- public Result<List<QuestionDTO>> groupLevelById(@RequestBody RuleDetailDTO ruleDetailDTO) {
|
|
|
- if (StringUtils.isBlank(ruleDetailDTO.getRepositoryIds())) {
|
|
|
+ public Result<List<QuestionDTO>> groupLevelById(@RequestBody RuleDetailDTO dto) {
|
|
|
+ if (StringUtils.isBlank(dto.getRepositoryIds())) {
|
|
|
return Result.OK();
|
|
|
}
|
|
|
- List<QuestionDTO> questionDTOs = questionService.groupLevelById(Arrays.asList(ruleDetailDTO.getRepositoryIds()
|
|
|
- .split(",")), ruleDetailDTO.getType());
|
|
|
- if (!StringUtils.isEmpty(ruleDetailDTO.getRuleList())) {
|
|
|
- List<PaperRuleDetail> ruleDetails = JSONObject.parseArray(JSON.toJSON(ruleDetailDTO.getRuleList()).toString(), PaperRuleDetail.class);
|
|
|
- if (!CollectionUtils.isEmpty(ruleDetails)) {
|
|
|
- ruleDetails.stream().forEach(rule -> {
|
|
|
- for (QuestionDTO tmp : questionDTOs) {
|
|
|
- if (tmp.getRepositoryId().equals(rule.getRepositoryId()) && tmp.getType().equals(ruleDetailDTO.getType())
|
|
|
- && tmp.getLevel().equals(rule.getLevel())) {
|
|
|
- tmp.setNum(rule.getNum());
|
|
|
+ if (Objects.isNull(dto.getJoinType())) {
|
|
|
+ throw new JeecgBootException("组卷方式不能为空");
|
|
|
+ }
|
|
|
+ List<QuestionDTO> questionDTOs = null;
|
|
|
+ if (JoinType.SJ.getCode().equals(dto.getJoinType())) {//随机组卷
|
|
|
+ questionDTOs = questionService.groupLevelById(Arrays.asList(dto.getRepositoryIds().split(",")), dto.getType(), null);
|
|
|
+ if (!StringUtils.isEmpty(dto.getRuleList())) {
|
|
|
+ List<PaperRuleDetail> ruleDetails = JSONObject.parseArray(JSON.toJSON(dto.getRuleList()).toString(), PaperRuleDetail.class);
|
|
|
+ if (!CollectionUtils.isEmpty(ruleDetails)) {
|
|
|
+ for (PaperRuleDetail rule : ruleDetails) {
|
|
|
+ for (QuestionDTO tmp : questionDTOs) {
|
|
|
+ if (tmp.getRepositoryId().equals(rule.getRepositoryId()) && tmp.getType().equals(dto.getType())
|
|
|
+ && tmp.getLevel().equals(rule.getLevel())) {
|
|
|
+ tmp.setNum(rule.getNum());
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
+ } else if (JoinType.CT.getCode().equals(dto.getJoinType())) {//抽题组卷
|
|
|
+ questionDTOs = questionService.groupLevelById(Arrays.asList(dto.getRepositoryIds().split(",")),
|
|
|
+ dto.getType(), StringUtils.isNotBlank(dto.getQuestionIds()) ? Arrays.asList(dto.getQuestionIds().split(",")) : null);
|
|
|
}
|
|
|
return Result.OK(questionDTOs);
|
|
|
}
|