优化商品类型里面的重复判断逻辑,增加上级目录的条件

This commit is contained in:
jishenghua
2025-10-28 17:21:58 +08:00
parent 390c2d34e1
commit 13a9ec92dd
4 changed files with 12 additions and 4 deletions

View File

@@ -204,9 +204,13 @@ public class MaterialCategoryService {
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
public int checkIsNameExist(Long id, String name, Long parentId)throws Exception {
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
if(parentId!=null) {
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andParentIdEqualTo(parentId).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else {
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<MaterialCategory> list=null;
try{
list= materialCategoryMapper.selectByExample(example);