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