支持添加重复名称的商品分类
This commit is contained in:
@@ -61,14 +61,6 @@ public class CategoryManagerController {
|
||||
@PostMapping
|
||||
@ApiOperation(value = "添加商品分类")
|
||||
public ResultMessage<Category> saveCategory(@Valid Category category) {
|
||||
|
||||
//不能添加重复的分类名称
|
||||
Category category1 = new Category();
|
||||
category1.setName(category.getName());
|
||||
List<Category> list = categoryService.findByAllBySortOrder(category1);
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
throw new ServiceException(ResultCode.CATEGORY_NOT_EXIST);
|
||||
}
|
||||
//非顶级分类
|
||||
if (category.getParentId() != null && !category.getParentId().equals("0")) {
|
||||
Category parent = categoryService.getById(category.getParentId());
|
||||
@@ -90,15 +82,7 @@ public class CategoryManagerController {
|
||||
public ResultMessage<Category> updateCategory(@Valid CategoryVO category) {
|
||||
Category catTemp = categoryService.getById(category.getId());
|
||||
if (catTemp == null) {
|
||||
throw new ServiceException(ResultCode.CATEGORY_PARENT_NOT_EXIST);
|
||||
}
|
||||
//不能添加重复的分类名称
|
||||
Category category1 = new Category();
|
||||
category1.setName(category.getName());
|
||||
category1.setId(category.getId());
|
||||
List<Category> list = categoryService.findByAllBySortOrder(category1);
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
throw new ServiceException(ResultCode.CATEGORY_NAME_IS_EXIST);
|
||||
throw new ServiceException(ResultCode.CATEGORY_NOT_EXIST);
|
||||
}
|
||||
|
||||
categoryService.updateCategory(category);
|
||||
|
||||
Reference in New Issue
Block a user