撤回修改
This commit is contained in:
@ -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<>();
|
||||||
|
if(catePid == pid){
|
||||||
|
newHtml = String.join("", Collections.nCopies(level,html));
|
||||||
map.put("value",storeCategory.getId());
|
map.put("value",storeCategory.getId());
|
||||||
map.put("label",html + html + storeCategory.getCateName());
|
map.put("label",newHtml + storeCategory.getCateName());
|
||||||
|
if(storeCategory.getPid() == 0){
|
||||||
map.put("disabled",0);
|
map.put("disabled",0);
|
||||||
|
}else{
|
||||||
|
map.put("disabled",1);
|
||||||
|
}
|
||||||
cateList.add(map);
|
cateList.add(map);
|
||||||
List<YxStoreCategory> categoriesChild = yxStoreCategoryService.lambdaQuery()
|
data.remove(i);
|
||||||
.eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
|
||||||
.eq(YxStoreCategory::getPid, storeCategory.getId()).list();
|
i--;
|
||||||
for (YxStoreCategory categoryChild : categoriesChild) {
|
if(storeCategory.getPid() > 0){
|
||||||
Map<String,Object> childMap = new HashMap<>();
|
this.makeCate(data,cateList,storeCategory.getPid(),level);
|
||||||
childMap.put("value",categoryChild.getId());
|
}else{
|
||||||
childMap.put("label",html + categoryChild.getCateName());
|
this.makeCate(data,cateList,storeCategory.getId(),level + 1);
|
||||||
childMap.put("disabled",1);
|
}
|
||||||
cateList.add(childMap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return cateList;
|
return cateList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user