Authored by kun

update

@@ -81,4 +81,9 @@ public class ProductSortController { @@ -81,4 +81,9 @@ public class ProductSortController {
81 return new ApiResponse<>(productSortService.getLevel1SortIdAndName()); 81 return new ApiResponse<>(productSortService.getLevel1SortIdAndName());
82 } 82 }
83 83
  84 + @RequestMapping(value = "/getLevel2SortIdAndName", method = RequestMethod.GET)
  85 + public ApiResponse<List<JSONObject>> getLevel2SortIdAndName() {
  86 + return new ApiResponse<>(productSortService.getLevel2SortIdAndName());
  87 + }
  88 +
84 } 89 }
@@ -62,4 +62,10 @@ public interface IProductSortService { @@ -62,4 +62,10 @@ public interface IProductSortService {
62 */ 62 */
63 List<ProductSort> getAllProcutSort(); 63 List<ProductSort> getAllProcutSort();
64 64
  65 +
  66 + /**
  67 + * 获取二级分类id和名称
  68 + * @return
  69 + */
  70 + List<JSONObject> getLevel2SortIdAndName();
65 } 71 }
@@ -171,7 +171,27 @@ public class ProductSortServiceImpl implements IProductSortService { @@ -171,7 +171,27 @@ public class ProductSortServiceImpl implements IProductSortService {
171 List<JSONObject> jsonObjectList = new ArrayList<>(); 171 List<JSONObject> jsonObjectList = new ArrayList<>();
172 JSONObject jsonObject; 172 JSONObject jsonObject;
173 for (ProductSort productSort : productSorts) { 173 for (ProductSort productSort : productSorts) {
174 - if (productSort.getParentId() == null || productSort.getParentId() == 0) { 174 + if ((productSort.getParentId() == null || productSort.getParentId() == 0) && PRODUCT_SORT_LEVEL_1.equals(productSort.getLevel())) {
  175 + jsonObject = new JSONObject();
  176 + jsonObject.put("id", productSort.getId());
  177 + jsonObject.put("text", productSort.getSortName());
  178 + jsonObjectList.add(jsonObject);
  179 + }
  180 + }
  181 + if (CollectionUtils.isEmpty(jsonObjectList)) {
  182 + jsonObject = new JSONObject();
  183 + jsonObjectList.add(jsonObject);
  184 + }
  185 + return jsonObjectList;
  186 + }
  187 +
  188 + @Override
  189 + public List<JSONObject> getLevel2SortIdAndName() {
  190 + List<ProductSort> productSorts = this.getAllProcutSort();
  191 + List<JSONObject> jsonObjectList = new ArrayList<>();
  192 + JSONObject jsonObject;
  193 + for (ProductSort productSort : productSorts) {
  194 + if ((productSort.getParentId() != null || productSort.getParentId() != 0) && PRODUCT_SORT_LEVEL_2.equals(productSort.getLevel())) {
175 jsonObject = new JSONObject(); 195 jsonObject = new JSONObject();
176 jsonObject.put("id", productSort.getId()); 196 jsonObject.put("id", productSort.getId());
177 jsonObject.put("text", productSort.getSortName()); 197 jsonObject.put("text", productSort.getSortName());
@@ -180,8 +200,6 @@ public class ProductSortServiceImpl implements IProductSortService { @@ -180,8 +200,6 @@ public class ProductSortServiceImpl implements IProductSortService {
180 } 200 }
181 if (CollectionUtils.isEmpty(jsonObjectList)) { 201 if (CollectionUtils.isEmpty(jsonObjectList)) {
182 jsonObject = new JSONObject(); 202 jsonObject = new JSONObject();
183 - /*jsonObject.put("id", "");  
184 - jsonObject.put("text", "");*/  
185 jsonObjectList.add(jsonObject); 203 jsonObjectList.add(jsonObject);
186 } 204 }
187 return jsonObjectList; 205 return jsonObjectList;
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 contentType: "application/json", 46 contentType: "application/json",
47 dataType: "json", 47 dataType: "json",
48 type: "GET", 48 type: "GET",
49 - url: contextPath + '/productSort/getProductSortIdAndName', 49 + url: contextPath + '/productSort/getLevel2SortIdAndName',
50 success: function (data) { 50 success: function (data) {
51 if (data.code != 200 || !data.data || data.data.length == 0) { 51 if (data.code != 200 || !data.data || data.data.length == 0) {
52 return; 52 return;
@@ -74,6 +74,7 @@ @@ -74,6 +74,7 @@
74 }, function (data) { 74 }, function (data) {
75 $("#sizeEditForm").form("load", data.data); 75 $("#sizeEditForm").form("load", data.data);
76 $("#sizeEditForm #sortId").myCombobox('select', data.data.sortId); 76 $("#sizeEditForm #sortId").myCombobox('select', data.data.sortId);
  77 + $("#sizeEditForm #sortId").myCombobox('disable');
77 }); 78 });
78 } 79 }
79 }); 80 });