|
@@ -7,13 +7,12 @@ import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.modules.course.bo.CourseChapterSectionListAddBo;
|
|
|
import com.zhongzheng.modules.course.domain.CourseChapterSection;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseChapterMapper;
|
|
|
-import com.zhongzheng.modules.goods.bo.GoodsAddBo;
|
|
|
-import com.zhongzheng.modules.goods.bo.GoodsCourseAddBo;
|
|
|
-import com.zhongzheng.modules.goods.bo.GoodsEditBo;
|
|
|
-import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
|
|
|
+import com.zhongzheng.modules.goods.bo.*;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
+import com.zhongzheng.modules.goods.domain.GoodsAttached;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsCourse;
|
|
|
import com.zhongzheng.modules.goods.mapper.GoodsMapper;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
@@ -46,6 +45,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
@Autowired
|
|
|
private IGoodsCourseService iGoodsCourseService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGoodsAttachedService iGoodsAttachedService;
|
|
|
+
|
|
|
@Override
|
|
|
public GoodsVo queryById(Long goodsId){
|
|
|
Goods db = this.baseMapper.selectById(goodsId);
|
|
@@ -132,6 +134,28 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean insertBankByAddBo(GoodsBankAddBo bo) {
|
|
|
+ Goods add = BeanUtil.toBean(bo, Goods.class);
|
|
|
+ add.setCode(ServletUtils.getEncoded("SP"));
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ boolean result = this.save(add);
|
|
|
+ if(bo.getBankList()!=null){
|
|
|
+ Collection<GoodsAttached> coll = new HashSet<>();
|
|
|
+ for(int i=0;i<bo.getBankList().size();i++){
|
|
|
+ GoodsAttachedAddBo item = bo.getBankList().get(i);
|
|
|
+ GoodsAttached addItem = BeanUtil.toBean(item, GoodsAttached.class);
|
|
|
+ addItem.setGoodsId(add.getGoodsId());
|
|
|
+ coll.add(addItem);
|
|
|
+ }
|
|
|
+ iGoodsAttachedService.saveBatch(coll);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateByEditBo(GoodsEditBo bo) {
|
|
@@ -154,6 +178,26 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return this.updateById(update);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean updateBankByEditBo(GoodsBankEditBo bo) {
|
|
|
+ Goods update = BeanUtil.toBean(bo, Goods.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ if(bo.getBankList()!=null&&bo.getBankList().size()>0){
|
|
|
+ iGoodsAttachedService.remove(new LambdaQueryWrapper<GoodsAttached>().eq(GoodsAttached::getGoodsId, bo.getGoodsId()));
|
|
|
+ Collection<GoodsAttached> coll = new HashSet<>();
|
|
|
+ for(int i=0;i<bo.getBankList().size();i++){
|
|
|
+ GoodsAttachedEditBo item = bo.getBankList().get(i);
|
|
|
+ GoodsAttached addItem = BeanUtil.toBean(item, GoodsAttached.class);
|
|
|
+ addItem.setGoodsId(update.getGoodsId());
|
|
|
+ coll.add(addItem);
|
|
|
+ }
|
|
|
+ iGoodsAttachedService.saveBatch(coll);
|
|
|
+ }
|
|
|
+ return this.updateById(update);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*
|