he2802 3 жил өмнө
parent
commit
6ead3ddd47

+ 21 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseHandoutsServiceImpl.java

@@ -1,7 +1,9 @@
 package com.zhongzheng.modules.course.service.impl;
 package com.zhongzheng.modules.course.service.impl;
 
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.course.bo.CourseHandoutsBusinessAddBo;
 import com.zhongzheng.modules.course.bo.CourseHandoutsBusinessAddBo;
@@ -9,6 +11,8 @@ import com.zhongzheng.modules.course.domain.CourseEducationTier;
 import com.zhongzheng.modules.course.domain.CourseHandoutsBusiness;
 import com.zhongzheng.modules.course.domain.CourseHandoutsBusiness;
 import com.zhongzheng.modules.course.service.ICourseHandoutsBusinessService;
 import com.zhongzheng.modules.course.service.ICourseHandoutsBusinessService;
 import com.zhongzheng.modules.course.vo.CourseHandoutsBusinessVo;
 import com.zhongzheng.modules.course.vo.CourseHandoutsBusinessVo;
+import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.service.IGoodsService;
 import org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution;
 import org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -41,6 +45,8 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
 
 
     @Autowired
     @Autowired
     private ICourseHandoutsBusinessService courseHandoutsBusinessService;
     private ICourseHandoutsBusinessService courseHandoutsBusinessService;
+    @Autowired
+    private IGoodsService iGoodsService;
 
 
     @Override
     @Override
     public CourseHandoutsVo queryById(Long handoutsId){
     public CourseHandoutsVo queryById(Long handoutsId){
@@ -137,6 +143,21 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
      */
      */
     private void validEntityBeforeSave(CourseHandouts entity){
     private void validEntityBeforeSave(CourseHandouts entity){
         //TODO 做一些数据校验,如唯一约束
         //TODO 做一些数据校验,如唯一约束
+        if(Validator.isNotEmpty(entity.getHandoutsId())){
+            if(entity.getStatus()==0){
+                CourseHandouts courseHandouts =this.baseMapper.selectById(entity.getHandoutsId());
+                if(courseHandouts.getStatus()==1){
+                    //从发布改为未发布
+                    LambdaQueryWrapper<Goods> lqw = Wrappers.lambdaQuery();
+                    lqw.eq( Goods::getHandoutsId, entity.getHandoutsId());
+                    Goods goods = iGoodsService.getOne(lqw.last("limit 1"));
+                    if(Validator.isNotEmpty(goods)){
+                        throw new CustomException("该讲义已被关联,禁止改为未发布");
+                    }
+
+                }
+            }
+        }
     }
     }
 
 
     @Override
     @Override

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -398,6 +398,7 @@
             cgu.user_id =#{userId}
             cgu.user_id =#{userId}
         AND cg.status=1
         AND cg.status=1
           AND  (unix_timestamp(now()) &lt; cg.class_end_time or cg.class_start_time is null)
           AND  (unix_timestamp(now()) &lt; cg.class_end_time or cg.class_start_time is null)
+        ORDER BY cgu.create_time DESC
     </select>
     </select>
 
 
     <select id="listSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"  resultMap="GoodsPeriodStatusVo">
     <select id="listSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"  resultMap="GoodsPeriodStatusVo">