|
|
@@ -123,6 +123,7 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean updateByEditBo(ExamNumberEditBo bo) {
|
|
|
ExamNumber update = BeanUtil.toBean(bo, ExamNumber.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
@@ -138,40 +139,40 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
|
|
|
throw new IllegalArgumentException("前培次数不能小于更改前");
|
|
|
}
|
|
|
if (bo.getGoodsId() != null){
|
|
|
- for (Long goodsId : bo.getGoodsId()) {
|
|
|
- Integer integer = baseMapper.selectExam(goodsId,update.getExamNumberId());
|
|
|
+ LambdaQueryWrapper<ExamNumberGoods> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
|
|
|
+ List<ExamNumberGoods> list = examNumberGoodsService.list(lqw);
|
|
|
+ for (ExamNumberGoods examNumberGoods : list) {
|
|
|
+ if (bo.getStatus() == -1) {
|
|
|
+ Integer apply = baseMapper.selectApply(examNumberGoods.getGoodsId());
|
|
|
+ if (apply > 0) {
|
|
|
+ throw new IllegalArgumentException("当前商品已启用考试安排,不可删除");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer integer = baseMapper.selectExam(examNumberGoods.getGoodsId(),update.getExamNumberId());
|
|
|
if (bo.getStatus() == 1 && integer > 0) {
|
|
|
throw new IllegalArgumentException("当前商品已启用考次配置,不可开启,请重新创建新的配置考试次数和前培次数商品");
|
|
|
}
|
|
|
if (bo.getStatus()==0){
|
|
|
- Integer apply = baseMapper.selectApply(goodsId);
|
|
|
+ Integer apply = baseMapper.selectApply(examNumberGoods.getGoodsId());
|
|
|
if (apply > 0) {
|
|
|
throw new IllegalArgumentException("当前商品已启用考试安排,不可关闭");
|
|
|
}
|
|
|
}
|
|
|
- LambdaQueryWrapper<ExamNumberGoods> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
|
|
|
- List<ExamNumberGoods> list = examNumberGoodsService.list(lqw);
|
|
|
- if (bo.getStatus() == -1) {
|
|
|
- for (ExamNumberGoods examNumberGoods : list) {
|
|
|
- Integer apply = baseMapper.selectApply(goodsId);
|
|
|
- if (apply > 0) {
|
|
|
- throw new IllegalArgumentException("当前商品已启用考试安排,不可删除");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- examNumberGoodsService.remove(lqw);
|
|
|
- ExamNumberGoodsAddBo examNumberGoodsAddBo = new ExamNumberGoodsAddBo();
|
|
|
- examNumberGoodsAddBo.setGoodsId(goodsId);
|
|
|
- examNumberGoodsAddBo.setExamNumberId(update.getExamNumberId());
|
|
|
- examNumberGoodsAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
- examNumberGoodsAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
- examNumberGoodsService.insertByAddBo(examNumberGoodsAddBo);
|
|
|
}
|
|
|
}
|
|
|
- LambdaQueryWrapper<ExamNumberGoods> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
|
|
|
- List<ExamNumberGoods> list = examNumberGoodsService.list(lqw);
|
|
|
+ LambdaQueryWrapper<ExamNumberGoods> example = Wrappers.lambdaQuery();
|
|
|
+ example.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
|
|
|
+ examNumberGoodsService.remove(example);
|
|
|
+ for (Long goodsId : bo.getGoodsId()) {
|
|
|
+ ExamNumberGoodsAddBo examNumberGoodsAddBo = new ExamNumberGoodsAddBo();
|
|
|
+ examNumberGoodsAddBo.setGoodsId(goodsId);
|
|
|
+ examNumberGoodsAddBo.setExamNumberId(update.getExamNumberId());
|
|
|
+ examNumberGoodsAddBo.setCreateTime(DateUtils.getNowTime());
|
|
|
+ examNumberGoodsAddBo.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ examNumberGoodsService.insertByAddBo(examNumberGoodsAddBo);
|
|
|
+ }
|
|
|
+ List<ExamNumberGoods> list = examNumberGoodsService.list(example);
|
|
|
if (bo.getStatus() == -1) {
|
|
|
for (ExamNumberGoods examNumberGoods : list) {
|
|
|
Integer apply = baseMapper.selectApply(examNumberGoods.getGoodsId());
|