|
@@ -5,9 +5,11 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.common.utils.ToolsUtils;
|
|
@@ -19,6 +21,8 @@ import com.zhongzheng.modules.course.mapper.CourseFileMapper;
|
|
|
import com.zhongzheng.modules.course.service.ICourseFileService;
|
|
|
import com.zhongzheng.modules.course.service.ICourseHandoutsService;
|
|
|
import com.zhongzheng.modules.course.vo.CourseFileVo;
|
|
|
+import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -40,6 +44,8 @@ public class CourseFileServiceImpl extends ServiceImpl<CourseFileMapper, CourseF
|
|
|
|
|
|
@Autowired
|
|
|
private ICourseHandoutsService iCourseHandoutsService;
|
|
|
+ @Autowired
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
@Value("${handouts.savePath}")
|
|
|
private String SAVE_HANDOUTS;
|
|
|
@Value("${handouts.updatePath}")
|
|
@@ -119,6 +125,16 @@ public class CourseFileServiceImpl extends ServiceImpl<CourseFileMapper, CourseF
|
|
|
|
|
|
@Override
|
|
|
public boolean editHandouts(CourseHandoutsEditBo bo) {
|
|
|
+ if (ObjectUtils.isNotNull(bo.getStatus()) && (bo.getStatus() == -1 || bo.getStatus() == 0)){
|
|
|
+ //删除校验
|
|
|
+ int count = iGoodsService
|
|
|
+ .count(new LambdaQueryWrapper<Goods>()
|
|
|
+ .eq(Goods::getHandoutsId, bo.getHandoutsId())
|
|
|
+ .eq(Goods::getStatus, 1));
|
|
|
+ if (count > 0){
|
|
|
+ throw new CustomException("已有商品关联此讲义,不能改动!");
|
|
|
+ }
|
|
|
+ }
|
|
|
iCourseHandoutsService.update(new LambdaUpdateWrapper<CourseHandouts>().set(CourseHandouts::getUpdateStatus,0).eq(CourseHandouts::getHandoutsId,bo.getHandoutsId()));
|
|
|
Long nowTime = DateUtils.getNowTime();
|
|
|
String sign = ToolsUtils.EncoderByMd5(nowTime.toString() + "pubilc2022");
|