|
|
@@ -111,6 +111,7 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
boolean save = this.save(add);
|
|
|
+ //添加考次商品
|
|
|
for (Long goodsId : bo.getGoodsId()) {
|
|
|
ExamNumberGoodsAddBo examNumberGoodsAddBo = new ExamNumberGoodsAddBo();
|
|
|
examNumberGoodsAddBo.setGoodsId(goodsId);
|
|
|
@@ -131,10 +132,11 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
|
|
|
ExamNumber info = getOne(new LambdaQueryWrapper<ExamNumber>()
|
|
|
.eq(ExamNumber::getExamNumberId,bo.getExamNumberId())
|
|
|
.last("limit 1"));
|
|
|
+ //判断考次不能小于更改前
|
|
|
if (null != bo.getExamNumber() && info.getExamNumber() > bo.getExamNumber()){
|
|
|
throw new IllegalArgumentException("考试次数不能小于更改前");
|
|
|
}
|
|
|
-
|
|
|
+ //判断前培次数不能小于更改前
|
|
|
if (null != bo.getDoNumber() &&info.getDoNumber() > bo.getDoNumber()){
|
|
|
throw new IllegalArgumentException("前培次数不能小于更改前");
|
|
|
}
|
|
|
@@ -145,20 +147,23 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
for (ExamNumberGoods examNumberGoods : list) {
|
|
|
if (bo.getStatus() == -1) {
|
|
|
+ //判断是否已启用考试安排
|
|
|
Integer apply = baseMapper.selectApply(examNumberGoods.getGoodsId());
|
|
|
if (apply > 0) {
|
|
|
throw new IllegalArgumentException("当前商品已启用考试安排,不可删除");
|
|
|
}
|
|
|
-
|
|
|
+ //判断是否已启用前培安排
|
|
|
Integer applyBefore = baseMapper.selectApplyBefore(examNumberGoods.getGoodsId());
|
|
|
if (applyBefore > 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(examNumberGoods.getGoodsId());
|
|
|
if (apply > 0) {
|
|
|
@@ -167,6 +172,7 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //添加修改后的商品
|
|
|
LambdaQueryWrapper<ExamNumberGoods> example = Wrappers.lambdaQuery();
|
|
|
example.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
|
|
|
examNumberGoodsService.remove(example);
|
|
|
@@ -179,15 +185,18 @@ public class ExamNumberServiceImpl extends ServiceImpl<ExamNumberMapper, ExamNum
|
|
|
examNumberGoodsService.insertByAddBo(examNumberGoodsAddBo);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
LambdaQueryWrapper<ExamNumberGoods> example = Wrappers.lambdaQuery();
|
|
|
example.eq(ExamNumberGoods::getExamNumberId, bo.getExamNumberId());
|
|
|
List<ExamNumberGoods> list = examNumberGoodsService.list(example);
|
|
|
if (bo.getStatus() == -1) {
|
|
|
for (ExamNumberGoods examNumberGoods : list) {
|
|
|
+ //已启用考试安排不可删除
|
|
|
Integer apply = baseMapper.selectApply(examNumberGoods.getGoodsId());
|
|
|
if (apply > 0) {
|
|
|
throw new IllegalArgumentException("当前商品已启用考试安排,不可删除");
|
|
|
}
|
|
|
+ //已启用前培安排不可删除
|
|
|
Integer applyBefore = baseMapper.selectApplyBefore(examNumberGoods.getGoodsId());
|
|
|
if (applyBefore > 0) {
|
|
|
throw new IllegalArgumentException("当前商品已启用前培安排,不可删除");
|