撤回修改

This commit is contained in:
xuwenbo
2020-09-14 15:53:13 +08:00
parent 53b7c4431b
commit 02ac3aea1a

View File

@ -97,9 +97,9 @@ public class StoreProductController {
List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery() List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery()
.eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue()) .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
.list(); .list();
List<Map<String,Object>> cateList = new LinkedList<>(); List<Map<String,Object>> cateList = new ArrayList<>();
Map<String, Object> queryAll = yxStoreProductService.queryAll(criteria, pageable); Map<String, Object> queryAll = yxStoreProductService.queryAll(criteria, pageable);
queryAll.put("cateList", this.makeCate(cateList)); queryAll.put("cateList", this.makeCate(storeCategories,cateList,0,1));
return new ResponseEntity<>(queryAll,HttpStatus.OK); return new ResponseEntity<>(queryAll,HttpStatus.OK);
} }
@ -160,8 +160,14 @@ public class StoreProductController {
List<YxShippingTemplates> shippingTemplatesList = yxShippingTemplatesService.list(); List<YxShippingTemplates> shippingTemplatesList = yxShippingTemplatesService.list();
map.put("tempList", shippingTemplatesList); map.put("tempList", shippingTemplatesList);
List<Map<String,Object>> cateList = new LinkedList<>(); //商品分类
map.put("cateList", this.makeCate(cateList)); List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery()
.eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
.orderByAsc(YxStoreCategory::getPid)
.list();
List<Map<String,Object>> cateList = new ArrayList<>();
map.put("cateList", this.makeCate(storeCategories,cateList,0,1));
//商品规格 //商品规格
map.put("ruleList",yxStoreProductRuleService.list()); map.put("ruleList",yxStoreProductRuleService.list());
@ -230,33 +236,45 @@ public class StoreProductController {
/** /**
* 分类 * 分类递归
* @param data 分类列表
* @param pid 附件id
* @param level d等级
* @return list * @return list
*/ */
private List<Map<String,Object>> makeCate(List<Map<String,Object>> cateList) private List<Map<String,Object>> makeCate(List<YxStoreCategory> data,List<Map<String,Object>> cateList,int pid, int level)
{ {
String html = "|-----"; String html = "|-----";
List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery() String newHtml = "";
.eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue()) List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery().eq(YxStoreCategory::getPid, 0).list();
.eq(YxStoreCategory::getPid, 0)
.list(); for (int i = 0; i < data.size(); i++) {
for (YxStoreCategory storeCategory : storeCategories) { YxStoreCategory storeCategory = data.get(i);
int catePid = storeCategory.getPid();
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("value",storeCategory.getId()); if(catePid == pid){
map.put("label",html + html + storeCategory.getCateName()); newHtml = String.join("", Collections.nCopies(level,html));
map.put("disabled",0); map.put("value",storeCategory.getId());
cateList.add(map); map.put("label",newHtml + storeCategory.getCateName());
List<YxStoreCategory> categoriesChild = yxStoreCategoryService.lambdaQuery() if(storeCategory.getPid() == 0){
.eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue()) map.put("disabled",0);
.eq(YxStoreCategory::getPid, storeCategory.getId()).list(); }else{
for (YxStoreCategory categoryChild : categoriesChild) { map.put("disabled",1);
Map<String,Object> childMap = new HashMap<>(); }
childMap.put("value",categoryChild.getId()); cateList.add(map);
childMap.put("label",html + categoryChild.getCateName()); data.remove(i);
childMap.put("disabled",1);
cateList.add(childMap); i--;
if(storeCategory.getPid() > 0){
this.makeCate(data,cateList,storeCategory.getPid(),level);
}else{
this.makeCate(data,cateList,storeCategory.getId(),level + 1);
}
} }
} }
return cateList; return cateList;
} }