|
@@ -1,21 +1,31 @@
|
|
package com.zhongzheng.modules.goods.service.impl;
|
|
package com.zhongzheng.modules.goods.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.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSectionWatchPer;
|
|
import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherAddBo;
|
|
import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherAddBo;
|
|
import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherEditBo;
|
|
import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherEditBo;
|
|
|
|
+import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherItemBo;
|
|
import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherQueryBo;
|
|
import com.zhongzheng.modules.goods.bo.GoodsCourseTeacherQueryBo;
|
|
|
|
+import com.zhongzheng.modules.goods.domain.GoodsCourse;
|
|
import com.zhongzheng.modules.goods.domain.GoodsCourseTeacher;
|
|
import com.zhongzheng.modules.goods.domain.GoodsCourseTeacher;
|
|
import com.zhongzheng.modules.goods.mapper.GoodsCourseTeacherMapper;
|
|
import com.zhongzheng.modules.goods.mapper.GoodsCourseTeacherMapper;
|
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseTeacherService;
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseTeacherService;
|
|
import com.zhongzheng.modules.goods.vo.GoodsCourseTeacherVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsCourseTeacherVo;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -30,6 +40,9 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class GoodsCourseTeacherServiceImpl extends ServiceImpl<GoodsCourseTeacherMapper, GoodsCourseTeacher> implements IGoodsCourseTeacherService {
|
|
public class GoodsCourseTeacherServiceImpl extends ServiceImpl<GoodsCourseTeacherMapper, GoodsCourseTeacher> implements IGoodsCourseTeacherService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IGoodsCourseService iGoodsCourseService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public GoodsCourseTeacherVo queryById(Long id){
|
|
public GoodsCourseTeacherVo queryById(Long id){
|
|
GoodsCourseTeacher db = this.baseMapper.selectById(id);
|
|
GoodsCourseTeacher db = this.baseMapper.selectById(id);
|
|
@@ -38,12 +51,7 @@ public class GoodsCourseTeacherServiceImpl extends ServiceImpl<GoodsCourseTeache
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<GoodsCourseTeacherVo> queryList(GoodsCourseTeacherQueryBo bo) {
|
|
public List<GoodsCourseTeacherVo> queryList(GoodsCourseTeacherQueryBo bo) {
|
|
- LambdaQueryWrapper<GoodsCourseTeacher> lqw = Wrappers.lambdaQuery();
|
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCourseIds()), GoodsCourseTeacher::getCourseIds, bo.getCourseIds());
|
|
|
|
- lqw.like(StrUtil.isNotBlank(bo.getName()), GoodsCourseTeacher::getName, bo.getName());
|
|
|
|
- lqw.eq(bo.getStatus() != null, GoodsCourseTeacher::getStatus, bo.getStatus());
|
|
|
|
- lqw.eq(bo.getGoodsId() != null, GoodsCourseTeacher::getGoodsId, bo.getGoodsId());
|
|
|
|
- return entity2Vo(this.list(lqw));
|
|
|
|
|
|
+ return baseMapper.getList(bo);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -68,7 +76,22 @@ public class GoodsCourseTeacherServiceImpl extends ServiceImpl<GoodsCourseTeache
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Boolean insertByAddBo(GoodsCourseTeacherAddBo bo) {
|
|
public Boolean insertByAddBo(GoodsCourseTeacherAddBo bo) {
|
|
|
|
+ if(Validator.isEmpty(bo.getCourseList())||bo.getCourseList().size()<2){
|
|
|
|
+ throw new CustomException("课程列表错误");
|
|
|
|
+ }
|
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
|
+ for(GoodsCourseTeacherItemBo item : bo.getCourseList()){
|
|
|
|
+ idList.add(item.getCourseId());
|
|
|
|
+ if(Validator.isEmpty(item.getAliasName())||Validator.isEmpty(item.getCourseId())){
|
|
|
|
+ throw new CustomException("课程参数错误");
|
|
|
|
+ }
|
|
|
|
+ iGoodsCourseService.update(new LambdaUpdateWrapper<GoodsCourse>()
|
|
|
|
+ .set(GoodsCourse::getAliasName,item.getAliasName())
|
|
|
|
+ .eq(GoodsCourse::getGoodsId,bo.getGoodsId()).eq(GoodsCourse::getCourseId,item.getCourseId()));
|
|
|
|
+ }
|
|
|
|
+ String courseIds = StringUtils.join(idList,",");
|
|
GoodsCourseTeacher add = BeanUtil.toBean(bo, GoodsCourseTeacher.class);
|
|
GoodsCourseTeacher add = BeanUtil.toBean(bo, GoodsCourseTeacher.class);
|
|
|
|
+ add.setCourseIds(courseIds);
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
@@ -78,6 +101,23 @@ public class GoodsCourseTeacherServiceImpl extends ServiceImpl<GoodsCourseTeache
|
|
@Override
|
|
@Override
|
|
public Boolean updateByEditBo(GoodsCourseTeacherEditBo bo) {
|
|
public Boolean updateByEditBo(GoodsCourseTeacherEditBo bo) {
|
|
GoodsCourseTeacher update = BeanUtil.toBean(bo, GoodsCourseTeacher.class);
|
|
GoodsCourseTeacher update = BeanUtil.toBean(bo, GoodsCourseTeacher.class);
|
|
|
|
+ if(Validator.isEmpty(bo.getStatus())||bo.getStatus()!=-1){
|
|
|
|
+ if(Validator.isEmpty(bo.getCourseList())||bo.getCourseList().size()<2){
|
|
|
|
+ throw new CustomException("课程列表错误");
|
|
|
|
+ }
|
|
|
|
+ List<Long> idList = new ArrayList<>();
|
|
|
|
+ for(GoodsCourseTeacherItemBo item : bo.getCourseList()){
|
|
|
|
+ idList.add(item.getCourseId());
|
|
|
|
+ if(Validator.isEmpty(item.getAliasName())||Validator.isEmpty(item.getCourseId())){
|
|
|
|
+ throw new CustomException("课程参数错误");
|
|
|
|
+ }
|
|
|
|
+ iGoodsCourseService.update(new LambdaUpdateWrapper<GoodsCourse>()
|
|
|
|
+ .set(GoodsCourse::getAliasName,item.getAliasName())
|
|
|
|
+ .eq(GoodsCourse::getGoodsId,bo.getGoodsId()).eq(GoodsCourse::getCourseId,item.getCourseId()));
|
|
|
|
+ }
|
|
|
|
+ String courseIds = StringUtils.join(idList,",");
|
|
|
|
+ update.setCourseIds(courseIds);
|
|
|
|
+ }
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
return this.updateById(update);
|
|
return this.updateById(update);
|