|
|
@@ -1,7 +1,9 @@
|
|
|
package com.zhongzheng.modules.course.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
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.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.service.ICourseHandoutsBusinessService;
|
|
|
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.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -41,6 +45,8 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
|
|
|
|
|
|
@Autowired
|
|
|
private ICourseHandoutsBusinessService courseHandoutsBusinessService;
|
|
|
+ @Autowired
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
|
|
|
@Override
|
|
|
public CourseHandoutsVo queryById(Long handoutsId){
|
|
|
@@ -137,6 +143,21 @@ public class CourseHandoutsServiceImpl extends ServiceImpl<CourseHandoutsMapper,
|
|
|
*/
|
|
|
private void validEntityBeforeSave(CourseHandouts entity){
|
|
|
//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
|