Browse Source

产品线重命名

master
luogw 2 months ago
parent
commit
16bd124cac
  1. 25
      src/main/java/com/project/information/domain/service/impl/UpdateProductLineDomainServiceImpl.java

25
src/main/java/com/project/information/domain/service/impl/UpdateProductLineDomainServiceImpl.java

@ -1,6 +1,5 @@
package com.project.information.domain.service.impl; package com.project.information.domain.service.impl;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.project.base.domain.exception.BusinessErrorException; import com.project.base.domain.exception.BusinessErrorException;
@ -28,16 +27,26 @@ public class UpdateProductLineDomainServiceImpl implements UpdateProductLineDoma
throw new BusinessErrorException("名称不能为空"); throw new BusinessErrorException("名称不能为空");
} }
ProductLineEntity entity = productLineBaseService.getById(dto.getId()); ProductLineEntity entity = productLineBaseService.getById(dto.getId());
if (entity == null) {
throw new BusinessErrorException("产品线不存在");
}
LambdaQueryWrapper<ProductLineEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProductLineEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ProductLineEntity::getBusiness , entity.getBusiness()); queryWrapper.eq(ProductLineEntity::getBusiness, entity.getBusiness());
queryWrapper.eq(ProductLineEntity::getLeaf , entity.getLeaf()); if (Boolean.TRUE.equals(entity.getLeaf())) {
queryWrapper.eq(ProductLineEntity::getName , dto.getName()); // 子产品线:同一父级下名称不能重复
ProductLineEntity existOne = productLineBaseService.getOne(queryWrapper); queryWrapper.eq(ProductLineEntity::getParentId, entity.getParentId());
if (Objects.nonNull(existOne)) {
if (BooleanUtil.isFalse(entity.getLeaf())) {
throw new BusinessErrorException("同一 BG 下产品线名称不能重复");
} else { } else {
// 产品线:同一 BG 下名称不能重复
queryWrapper.eq(ProductLineEntity::getLeaf, false);
}
queryWrapper.eq(ProductLineEntity::getName , dto.getName());
queryWrapper.ne(ProductLineEntity::getId , dto.getId());
long count = productLineBaseService.count(queryWrapper);
if (count > 0) {
if (Boolean.TRUE.equals(entity.getLeaf())) {
throw new BusinessErrorException("同一产品线下子产品线名称不能重复"); throw new BusinessErrorException("同一产品线下子产品线名称不能重复");
} else {
throw new BusinessErrorException("同一 BG 下产品线名称不能重复");
} }
} }
entity.setName(dto.getName()); entity.setName(dto.getName());

Loading…
Cancel
Save