Authored by kun

update

... ... @@ -81,4 +81,9 @@ public class ProductSortController {
return new ApiResponse<>(productSortService.getLevel1SortIdAndName());
}
@RequestMapping(value = "/getLevel2SortIdAndName", method = RequestMethod.GET)
public ApiResponse<List<JSONObject>> getLevel2SortIdAndName() {
return new ApiResponse<>(productSortService.getLevel2SortIdAndName());
}
}
... ...
... ... @@ -62,4 +62,10 @@ public interface IProductSortService {
*/
List<ProductSort> getAllProcutSort();
/**
* 获取二级分类id和名称
* @return
*/
List<JSONObject> getLevel2SortIdAndName();
}
... ...
... ... @@ -171,7 +171,27 @@ public class ProductSortServiceImpl implements IProductSortService {
List<JSONObject> jsonObjectList = new ArrayList<>();
JSONObject jsonObject;
for (ProductSort productSort : productSorts) {
if (productSort.getParentId() == null || productSort.getParentId() == 0) {
if ((productSort.getParentId() == null || productSort.getParentId() == 0) && PRODUCT_SORT_LEVEL_1.equals(productSort.getLevel())) {
jsonObject = new JSONObject();
jsonObject.put("id", productSort.getId());
jsonObject.put("text", productSort.getSortName());
jsonObjectList.add(jsonObject);
}
}
if (CollectionUtils.isEmpty(jsonObjectList)) {
jsonObject = new JSONObject();
jsonObjectList.add(jsonObject);
}
return jsonObjectList;
}
@Override
public List<JSONObject> getLevel2SortIdAndName() {
List<ProductSort> productSorts = this.getAllProcutSort();
List<JSONObject> jsonObjectList = new ArrayList<>();
JSONObject jsonObject;
for (ProductSort productSort : productSorts) {
if ((productSort.getParentId() != null || productSort.getParentId() != 0) && PRODUCT_SORT_LEVEL_2.equals(productSort.getLevel())) {
jsonObject = new JSONObject();
jsonObject.put("id", productSort.getId());
jsonObject.put("text", productSort.getSortName());
... ... @@ -180,8 +200,6 @@ public class ProductSortServiceImpl implements IProductSortService {
}
if (CollectionUtils.isEmpty(jsonObjectList)) {
jsonObject = new JSONObject();
/*jsonObject.put("id", "");
jsonObject.put("text", "");*/
jsonObjectList.add(jsonObject);
}
return jsonObjectList;
... ...
... ... @@ -46,7 +46,7 @@
contentType: "application/json",
dataType: "json",
type: "GET",
url: contextPath + '/productSort/getProductSortIdAndName',
url: contextPath + '/productSort/getLevel2SortIdAndName',
success: function (data) {
if (data.code != 200 || !data.data || data.data.length == 0) {
return;
... ... @@ -74,6 +74,7 @@
}, function (data) {
$("#sizeEditForm").form("load", data.data);
$("#sizeEditForm #sortId").myCombobox('select', data.data.sortId);
$("#sizeEditForm #sortId").myCombobox('disable');
});
}
});
... ...