|
|
@ -66,6 +66,13 @@ public class PmsProductCategoryController { |
|
|
|
@PreAuthorize("hasAuthority('pms:PmsProductCategory:create')") |
|
|
|
public Object savePmsProductCategory(@RequestBody PmsProductCategory entity) { |
|
|
|
try { |
|
|
|
//查询是否存在相同级别的相同名称的分类
|
|
|
|
Long parentId = entity.getParentId(); |
|
|
|
String name = entity.getName(); |
|
|
|
int count = IPmsProductCategoryService.selectCountByNameAndLevel(parentId,name); |
|
|
|
if(count>0){ |
|
|
|
return new CommonResult().failed("该分类已存在"); |
|
|
|
} |
|
|
|
if (IPmsProductCategoryService.saveAnd(entity)) { |
|
|
|
return new CommonResult().success(); |
|
|
|
} |
|
|
@ -82,6 +89,14 @@ public class PmsProductCategoryController { |
|
|
|
@PreAuthorize("hasAuthority('pms:PmsProductCategory:update')") |
|
|
|
public Object updatePmsProductCategory(@RequestBody PmsProductCategory entity) { |
|
|
|
try { |
|
|
|
//查询是否存在相同级别的相同名称的分类
|
|
|
|
Long parentId = entity.getParentId(); |
|
|
|
String name = entity.getName(); |
|
|
|
Long id = entity.getId(); |
|
|
|
int count = IPmsProductCategoryService.selectCountByNameAndLevelId(parentId,name,id); |
|
|
|
if(count>0){ |
|
|
|
return new CommonResult().failed("该分类已存在"); |
|
|
|
} |
|
|
|
if (IPmsProductCategoryService.updateAnd(entity)) { |
|
|
|
return new CommonResult().success(); |
|
|
|
} |
|
|
|