Browse Source

发布状态

he2802 3 năm trước cách đây
mục cha
commit
b40d3f0556

+ 20 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/ExamServiceImpl.java

@@ -2,20 +2,22 @@ package com.zhongzheng.modules.bank.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.bank.bo.*;
-import com.zhongzheng.modules.bank.domain.Exam;
-import com.zhongzheng.modules.bank.domain.ExamQuestion;
-import com.zhongzheng.modules.bank.domain.QuestionBusiness;
+import com.zhongzheng.modules.bank.domain.*;
 import com.zhongzheng.modules.bank.mapper.ExamMapper;
 import com.zhongzheng.modules.bank.service.IExamQuestionService;
 import com.zhongzheng.modules.bank.service.IExamService;
 import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
+import com.zhongzheng.modules.bank.service.IQuestionChapterExamService;
 import com.zhongzheng.modules.bank.vo.ExamVo;
 import com.zhongzheng.modules.course.bo.CourseChapterSectionListAddBo;
 import com.zhongzheng.modules.course.domain.CourseChapterSection;
 import com.zhongzheng.modules.course.service.ICourseChapterBusinessService;
+import com.zhongzheng.modules.goods.domain.GoodsAttached;
+import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import com.zhongzheng.modules.user.domain.User;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -46,6 +48,12 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
     @Autowired
     private IQuestionBusinessService iQuestionBusinessService;
 
+    @Autowired
+    private IGoodsAttachedService iGoodsAttachedService;
+
+    @Autowired
+    private IQuestionChapterExamService iQuestionChapterExamService;
+
     @Autowired
     private ExamMapper examMapper;
 
@@ -178,6 +186,15 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
      */
     private void validEntityBeforeSave(Exam entity){
         //TODO 做一些数据校验,如唯一约束
+        if(entity.getExamId()>0&&entity.getPublishStatus().equals(0)){
+            GoodsAttached one = iGoodsAttachedService.getOne(new LambdaQueryWrapper<GoodsAttached>().eq(GoodsAttached::getMajorId, entity.getExamId()).eq(GoodsAttached::getType,3).last("limit 1"));
+            if(one!=null){
+                throw new CustomException("该卷已被绑定,不允许修改发布状态为未发布");
+            }
+            if(iQuestionChapterExamService.getOne(new LambdaQueryWrapper<QuestionChapterExam>().eq(QuestionChapterExam::getExamId,entity.getExamId()).last("limit 1"))!=null){
+                throw new CustomException("该卷已被绑定,不允许修改发布状态为未发布");
+            }
+        }
     }
 
     @Override

+ 21 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionChapterServiceImpl.java

@@ -2,17 +2,22 @@ package com.zhongzheng.modules.bank.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.bank.bo.*;
 import com.zhongzheng.modules.bank.domain.QuestionBusiness;
 import com.zhongzheng.modules.bank.domain.QuestionChapter;
 import com.zhongzheng.modules.bank.domain.QuestionChapterExam;
+import com.zhongzheng.modules.bank.domain.QuestionModuleChapter;
 import com.zhongzheng.modules.bank.mapper.QuestionChapterMapper;
 import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
 import com.zhongzheng.modules.bank.service.IQuestionChapterExamService;
 import com.zhongzheng.modules.bank.service.IQuestionChapterService;
+import com.zhongzheng.modules.bank.service.IQuestionModuleChapterService;
 import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
+import com.zhongzheng.modules.goods.domain.GoodsAttached;
+import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -43,6 +48,12 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
     private IQuestionChapterExamService iQuestionChapterExamService;
     @Autowired
     private QuestionChapterMapper questionChapterMapper;
+    @Autowired
+    private IGoodsAttachedService iGoodsAttachedService;
+
+
+    @Autowired
+    private IQuestionModuleChapterService iQuestionModuleChapterService;
 
     @Override
     public QuestionChapterVo queryById(Long chapterExamId){
@@ -163,6 +174,16 @@ public class QuestionChapterServiceImpl extends ServiceImpl<QuestionChapterMappe
      */
     private void validEntityBeforeSave(QuestionChapter entity){
         //TODO 做一些数据校验,如唯一约束
+        if(entity.getChapterExamId()>0&&entity.getPublishStatus().equals(0)){
+            GoodsAttached one = iGoodsAttachedService.getOne(new LambdaQueryWrapper<GoodsAttached>().eq(GoodsAttached::getMajorId, entity.getChapterExamId()).eq(GoodsAttached::getType,2).last("limit 1"));
+            if(one!=null){
+                throw new CustomException("该章卷已被绑定,不允许修改发布状态为未发布");
+            }
+            if(iQuestionModuleChapterService.getOne(new LambdaQueryWrapper<QuestionModuleChapter>().eq(QuestionModuleChapter::getChapterExamId,entity.getChapterExamId()).last("limit 1"))!=null){
+                throw new CustomException("该章卷已被绑定,不允许修改发布状态为未发布");
+            }
+
+        }
     }
 
     @Override

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionModuleServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.bank.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.bank.bo.*;
@@ -13,6 +14,8 @@ import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
 import com.zhongzheng.modules.bank.service.IQuestionModuleChapterService;
 import com.zhongzheng.modules.bank.service.IQuestionModuleService;
 import com.zhongzheng.modules.bank.vo.QuestionModuleVo;
+import com.zhongzheng.modules.goods.domain.GoodsAttached;
+import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -45,6 +48,9 @@ public class QuestionModuleServiceImpl extends ServiceImpl<QuestionModuleMapper,
     @Autowired
     private QuestionModuleMapper questionModuleMapper;
 
+    @Autowired
+    private IGoodsAttachedService iGoodsAttachedService;
+
     @Override
     public QuestionModuleVo queryById(Long questionModuleId){
         QuestionModule db = this.baseMapper.selectById(questionModuleId);
@@ -160,6 +166,12 @@ public class QuestionModuleServiceImpl extends ServiceImpl<QuestionModuleMapper,
      */
     private void validEntityBeforeSave(QuestionModule entity){
         //TODO 做一些数据校验,如唯一约束
+        if(entity.getModuleExamId()>0&&entity.getPublishStatus().equals(0)){
+            GoodsAttached one = iGoodsAttachedService.getOne(new LambdaQueryWrapper<GoodsAttached>().eq(GoodsAttached::getMajorId, entity.getModuleExamId()).eq(GoodsAttached::getType,1).last("limit 1"));
+            if(one!=null){
+                throw new CustomException("该模块卷已被绑定,不允许修改发布状态为未发布");
+            }
+        }
     }
 
     @Override

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -11,8 +11,10 @@ import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.bank.bo.*;
+import com.zhongzheng.modules.bank.domain.ExamQuestion;
 import com.zhongzheng.modules.bank.domain.Question;
 import com.zhongzheng.modules.bank.domain.QuestionBusiness;
+import com.zhongzheng.modules.bank.domain.QuestionModuleChapter;
 import com.zhongzheng.modules.bank.mapper.QuestionMapper;
 import com.zhongzheng.modules.bank.service.IExamQuestionService;
 import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
@@ -71,6 +73,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     @Autowired
     private IExamKnowledgeService iExamKnowledgeService;
 
+    @Autowired
+    private IExamQuestionService iExamQuestionService;
+
     @Autowired
     private RedisCache redisCache;
 
@@ -186,6 +191,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
        /* if(checkNameUnique(entity)&&Validator.isEmpty(entity.getQuestionId())){
             throw new CustomException("名称重复");
         }*/
+        if(entity.getQuestionId()>0&&entity.getPublishStatus().equals(0)){
+            if(iExamQuestionService.getOne(new LambdaQueryWrapper<ExamQuestion>().eq(ExamQuestion::getQuestionId,entity.getQuestionId()).last("limit 1"))!=null){
+                throw new CustomException("该题目已被绑定,不允许修改发布状态为未发布");
+            }
+        }
     }
 
     @Override

+ 11 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.modules.bank.domain.ExamQuestion;
 import com.zhongzheng.modules.bank.domain.Question;
 import com.zhongzheng.modules.course.bo.CourseAddBo;
 import com.zhongzheng.modules.course.bo.CourseEditBo;
@@ -19,6 +20,8 @@ import com.zhongzheng.modules.course.service.ICourseSectionBusinessService;
 import com.zhongzheng.modules.course.service.ICourseService;
 import com.zhongzheng.modules.course.vo.CourseUserVo;
 import com.zhongzheng.modules.course.vo.CourseVo;
+import com.zhongzheng.modules.goods.domain.GoodsCourse;
+import com.zhongzheng.modules.goods.service.IGoodsCourseService;
 import com.zhongzheng.modules.goods.vo.GoodsPeriodStatusVo;
 import com.zhongzheng.modules.goods.vo.GoodsPeriodVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserVo;
@@ -69,6 +72,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
     @Autowired
     private IUserStudyRecordService iUserStudyRecordService;
 
+    @Autowired
+    private IGoodsCourseService iGoodsCourseService;
+
     @Override
     public CourseVo queryById(Long courseId){
         Course db = this.baseMapper.selectById(courseId);
@@ -170,6 +176,11 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
       /*  if(checkNameUnique(entity)){
             throw new CustomException("名称重复");
         }*/
+        if(entity.getCourseId()>0&&entity.getPublishStatus().equals(0)){
+            if(iGoodsCourseService.getOne(new LambdaQueryWrapper<GoodsCourse>().eq(GoodsCourse::getCourseId,entity.getCourseId()).last("limit 1"))!=null){
+                throw new CustomException("该课程已被绑定,不允许修改发布状态为未发布");
+            }
+        }
     }
 
     @Override