Bladeren bron

BUG修改

wangliang 2 jaren geleden
bovenliggende
commit
9ef77e8dba
1 gewijzigde bestanden met toevoegingen van 15 en 0 verwijderingen
  1. 15 0
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamPaperController.java

+ 15 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamPaperController.java

@@ -2,6 +2,7 @@ package com.qmth.themis.admin.api;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
+import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.MqDto;
@@ -13,6 +14,7 @@ import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
+import com.qmth.themis.common.util.GsonUtil;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
@@ -200,6 +202,19 @@ public class TEExamPaperController {
         if (count > 0) {
             throw new BusinessException("该试卷已存在考试记录,无法删除");
         }
+        ExamPaperCacheBean examPaperCacheBean = teExamPaperService.getExamPaperCacheBean(id);
+        Optional.ofNullable(examPaperCacheBean).orElseThrow(() -> new BusinessException("试卷数据为空"));
+
+        ExamCourseCacheBean examCourseCacheBean = examCourseService.getExamCourseCacheBean(examPaperCacheBean.getExamId(), examPaperCacheBean.getCourseCode());
+        Optional.ofNullable(examCourseCacheBean).orElseThrow(() -> new BusinessException("科目数据为空"));
+
+        Integer paperCount = examCourseCacheBean.getPaperCount();
+        paperCount = paperCount - 1;
+        examCourseCacheBean.setPaperCount(Objects.isNull(paperCount) || paperCount.intValue() < 0 ? 0 : paperCount);
+        TEExamCourse teExamCourse = GsonUtil.fromJson(GsonUtil.toJson(examCourseCacheBean), TEExamCourse.class);
+        teExamCourse.setUpdateTime(System.currentTimeMillis());
+        examCourseService.saveOrUpdate(teExamCourse);
+
         teExamPaperService.removeById(id);
         teExamPaperService.deleteExamPaperCacheBean(id);
         return ResultUtil.ok(true);