change 3 rokov pred
rodič
commit
a2fb7f1df6

+ 2 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamNumberMapper.java

@@ -4,6 +4,7 @@ import com.zhongzheng.modules.exam.bo.ExamNumberQueryBo;
 import com.zhongzheng.modules.exam.domain.ExamNumber;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.zhongzheng.modules.exam.vo.ExamNumberVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -17,7 +18,7 @@ public interface ExamNumberMapper extends BaseMapper<ExamNumber> {
 
     List<ExamNumberVo> ListExamNumber(ExamNumberQueryBo bo);
 
-    Integer selectExam(Long goodsId);
+    Integer selectExam(@Param("goodsId") Long goodsId,@Param("examNumberId") Long examNumberId);
 
     Integer selectApply(Long goodsId);
 }

+ 5 - 7
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamNumberServiceImpl.java

@@ -139,15 +139,13 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
         }
         if (bo.getGoodsId() != null){
             for (Long goodsId : bo.getGoodsId()) {
-                if (bo.getStatus() == 1) {
-                    Integer integer = baseMapper.selectExam(goodsId);
-                    if (integer > 0) {
-                        throw new IllegalArgumentException("当前商品已启用考次配置,不可开启,请重新创建新的配置考试次数和前培次数商品");
-                    }
+                Integer integer = baseMapper.selectExam(goodsId,update.getExamNumberId());
+                if (bo.getStatus() == 1 && integer > 0) {
+                    throw new IllegalArgumentException("当前商品已启用考次配置,不可开启,请重新创建新的配置考试次数和前培次数商品");
                 }
                 if (bo.getStatus() == -1 || bo.getStatus()==0){
-                    Integer integer = baseMapper.selectApply(goodsId);
-                    if (integer > 0) {
+                    Integer apply = baseMapper.selectApply(goodsId);
+                    if (apply > 0) {
                         throw new IllegalArgumentException("当前商品已启用考试安排,不可关闭");
                     }
                 }

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamNumberMapper.xml

@@ -62,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         WHERE
             1 = 1
           AND eng.goods_id = #{goodsId}
+          and en.exam_number_id != #{examNumberId}
           AND en.STATUS =1
     </select>