Browse Source

fix 二造

he2802 2 years ago
parent
commit
0443fca99e

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/domain/Exam.java

@@ -1,6 +1,8 @@
 package com.zhongzheng.modules.bank.domain;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.zhongzheng.modules.bank.bo.ExamSimulateConfigBo;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
@@ -66,4 +68,8 @@ private static final long serialVersionUID=1L;
     private String simulateConfigJson;
     /** 开启模拟考 1启动(考试类型才能启动) 0关闭 */
     private Integer simulateStatus;
+
+    /** 模拟考配置参数 */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private ExamSimulateConfigBo simulateConfig;
 }

+ 15 - 7
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java

@@ -132,9 +132,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
     @Transactional(rollbackFor = Exception.class)
     public ExamVo insertByAddBo(ExamAddBo bo) {
         Exam add = BeanUtil.toBean(bo, Exam.class);
-        if(Validator.isNotEmpty(bo.getSimulateConfig())){
-            add.setSimulateConfigJson(JSON.toJSONString(bo.getSimulateConfig()));
-        }
         add.setCode(ServletUtils.getEncoded("SJ"));
         validEntityBeforeSave(add);
         add.setCreateTime(DateUtils.getNowTime());
@@ -185,9 +182,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
             throw new CustomException("试卷ID缺失");
         }
         Exam update = BeanUtil.toBean(bo, Exam.class);
-        if(Validator.isNotEmpty(bo.getSimulateConfig())){
-            update.setSimulateConfigJson(JSON.toJSONString(bo.getSimulateConfig()));
-        }
         validEntityBeforeSave(update);
         update.setUpdateTime(DateUtils.getNowTime());
         if(bo.getQuestionList()!=null){
@@ -243,7 +237,21 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
                 throw new CustomException("该卷已被绑定,不允许修改发布状态为未发布");
             }
         }
-
+        if(Validator.isNotEmpty(entity.getSimulateConfig())){
+            Integer q1 = entity.getSimulateConfig().getSingleChoice().getQNum();
+            Integer q2 = entity.getSimulateConfig().getMultipleChoice().getQNum();
+            Integer q3 = entity.getSimulateConfig().getCaseQuestion().getQNum();
+            if((q1>0)&&(q1<entity.getSimulateConfig().getSingleChoice().getKNum())){
+                throw new CustomException("模拟配置单选题参数错误");
+            }
+            if((q2>0)&&(q2<entity.getSimulateConfig().getMultipleChoice().getKNum())){
+                throw new CustomException("模拟配置多选题参数错误");
+            }
+            if((q3>0)&&(q3<entity.getSimulateConfig().getCaseQuestion().getKNum())){
+                throw new CustomException("模拟配置案例题参数错误");
+            }
+            entity.setSimulateConfigJson(JSON.toJSONString(entity.getSimulateConfig()));
+        }
     }
 
     @Override