Browse Source

学习计划

change 4 years ago
parent
commit
1953a29d0a

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamSiteMapper.java

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
  */
 public interface ExamSiteMapper extends BaseMapper<ExamSite> {
 public interface ExamSiteMapper extends BaseMapper<ExamSite> {
 
 
+    Integer selectCountSite(Long siteId);
 }
 }

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

@@ -138,9 +138,6 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
             throw new IllegalArgumentException("前培次数不能小于更改前");
             throw new IllegalArgumentException("前培次数不能小于更改前");
         }
         }
         if (bo.getGoodsId() != null){
         if (bo.getGoodsId() != null){
-            LambdaQueryWrapper<ExamNumberGoods> lqw = Wrappers.lambdaQuery();
-            lqw.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
-            examNumberGoodsService.remove(lqw);
             for (Long goodsId : bo.getGoodsId()) {
             for (Long goodsId : bo.getGoodsId()) {
                 if (bo.getStatus() == 1) {
                 if (bo.getStatus() == 1) {
                     Integer integer = baseMapper.selectExam(goodsId);
                     Integer integer = baseMapper.selectExam(goodsId);
@@ -148,12 +145,15 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
                         throw new IllegalArgumentException("当前商品已启用考次配置,不可开启,请重新创建新的配置考试次数和前培次数商品");
                         throw new IllegalArgumentException("当前商品已启用考次配置,不可开启,请重新创建新的配置考试次数和前培次数商品");
                     }
                     }
                 }
                 }
-                if (bo.getStatus() == -1 || bo.getStatus()==1){
+                if (bo.getStatus() == -1 || bo.getStatus()==0){
                     Integer integer = baseMapper.selectApply(goodsId);
                     Integer integer = baseMapper.selectApply(goodsId);
                     if (integer > 0) {
                     if (integer > 0) {
-                        throw new IllegalArgumentException("当前商品已启用考试安排,不可开启");
+                        throw new IllegalArgumentException("当前商品已启用考试安排,不可关闭");
                     }
                     }
                 }
                 }
+                LambdaQueryWrapper<ExamNumberGoods> lqw = Wrappers.lambdaQuery();
+                lqw.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
+                examNumberGoodsService.remove(lqw);
                 ExamNumberGoodsAddBo examNumberGoodsAddBo = new ExamNumberGoodsAddBo();
                 ExamNumberGoodsAddBo examNumberGoodsAddBo = new ExamNumberGoodsAddBo();
                 examNumberGoodsAddBo.setGoodsId(goodsId);
                 examNumberGoodsAddBo.setGoodsId(goodsId);
                 examNumberGoodsAddBo.setExamNumberId(update.getExamNumberId());
                 examNumberGoodsAddBo.setExamNumberId(update.getExamNumberId());

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamSiteServiceImpl.java

@@ -107,6 +107,10 @@ public class ExamSiteServiceImpl extends ServiceImpl<ExamSiteMapper, ExamSite> i
                 }
                 }
             }
             }
         }
         }
+        Integer integer = baseMapper.selectCountSite(update.getSiteId());
+        if (bo.getStatus() == -1 && integer > 0){
+            throw new IllegalArgumentException("内容使用中,禁止删除");
+        }
         return this.updateById(update);
         return this.updateById(update);
     }
     }
 
 

+ 11 - 0
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamSiteMapper.xml

@@ -15,4 +15,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
     </resultMap>
 
 
 
 
+
+    <select id="selectCountSite" parameterType="long" resultType="integer">
+        SELECT
+            COUNT( 1 )
+        FROM
+            exam_apply ea
+                LEFT JOIN exam_apply_site eas ON ea.apply_id = eas.apply_id
+        WHERE
+            eas.site_id = #{siteId}
+          AND ea.`status` =1
+    </select>
 </mapper>
 </mapper>