|
@@ -84,6 +84,9 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
|
@@ -84,6 +84,9 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
84
|
// 一级层级
|
84
|
// 一级层级
|
85
|
saleCategory.setLevel(PRODUCT_SORT_LEVEL_1);
|
85
|
saleCategory.setLevel(PRODUCT_SORT_LEVEL_1);
|
86
|
saleCategory.setParentId(TOP_PARENT_ID);
|
86
|
saleCategory.setParentId(TOP_PARENT_ID);
|
|
|
87
|
+ if (!saleCategoryMapper.selectByPidAndOrderBy(TOP_PARENT_ID, saleCategory.getOrderBy()).isEmpty()) {
|
|
|
88
|
+ throw new CommonException(201, "排序已存在:" + saleCategory.getOrderBy());
|
|
|
89
|
+ }
|
87
|
if(StringUtils.equals(saleCategoryResponseBo.getLinkType(), "on")) {
|
90
|
if(StringUtils.equals(saleCategoryResponseBo.getLinkType(), "on")) {
|
88
|
saleCategory.setLinkType("series");
|
91
|
saleCategory.setLinkType("series");
|
89
|
} else {
|
92
|
} else {
|
|
@@ -95,6 +98,9 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
|
@@ -95,6 +98,9 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
95
|
if(saleCategoryParent==null){
|
98
|
if(saleCategoryParent==null){
|
96
|
throw new CommonException(201, "父类销售类目找不到!");
|
99
|
throw new CommonException(201, "父类销售类目找不到!");
|
97
|
}
|
100
|
}
|
|
|
101
|
+ if (!saleCategoryMapper.selectByPidAndOrderBy(saleCategory.getParentId(), saleCategory.getOrderBy()).isEmpty()) {
|
|
|
102
|
+ throw new CommonException(201, "排序已存在:" + saleCategory.getOrderBy());
|
|
|
103
|
+ }
|
98
|
saleCategory.setLevel(saleCategoryParent.getLevel()+1);
|
104
|
saleCategory.setLevel(saleCategoryParent.getLevel()+1);
|
99
|
}
|
105
|
}
|
100
|
saleCategory.setStatus(1);//新创建的默认为“关闭”
|
106
|
saleCategory.setStatus(1);//新创建的默认为“关闭”
|
|
@@ -113,6 +119,12 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
|
@@ -113,6 +119,12 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
113
|
if(db_saleCategory==null){
|
119
|
if(db_saleCategory==null){
|
114
|
throw new CommonException(201, "找不到销售类目!");
|
120
|
throw new CommonException(201, "找不到销售类目!");
|
115
|
}
|
121
|
}
|
|
|
122
|
+
|
|
|
123
|
+ List<SaleCategory> exists = saleCategoryMapper.selectByPidAndOrderBy(db_saleCategory.getParentId(), saleCategory.getOrderBy());
|
|
|
124
|
+ if (exists.size() > 1 || (exists.size() == 1 && !exists.get(0).getId().equals(saleCategory.getId()))) {
|
|
|
125
|
+ throw new CommonException(201, "排序已存在:" + saleCategory.getOrderBy());
|
|
|
126
|
+ }
|
|
|
127
|
+
|
116
|
db_saleCategory.setCategoryName(saleCategory.getCategoryName());
|
128
|
db_saleCategory.setCategoryName(saleCategory.getCategoryName());
|
117
|
db_saleCategory.setOrderBy(saleCategory.getOrderBy());
|
129
|
db_saleCategory.setOrderBy(saleCategory.getOrderBy());
|
118
|
db_saleCategory.setImageUrl(saleCategory.getImageUrl());
|
130
|
db_saleCategory.setImageUrl(saleCategory.getImageUrl());
|