diff --git a/litemall-admin/config/dep.env.js b/litemall-admin/config/dep.env.js index db4d9480..ad5dc964 100644 --- a/litemall-admin/config/dep.env.js +++ b/litemall-admin/config/dep.env.js @@ -1,5 +1,5 @@ module.exports = { NODE_ENV: '"production"', ENV_CONFIG: '"dep"', - BASE_API: '"http://122.152.206.172:8083/admin"' + BASE_API: '"https://www.menethil.com.cn/admin"' } diff --git a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCatalogController.java b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCatalogController.java index b8e79d45..bb685795 100644 --- a/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCatalogController.java +++ b/litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCatalogController.java @@ -1,8 +1,8 @@ package org.linlinjava.litemall.wx.web; +import org.linlinjava.litemall.core.util.ResponseUtil; import org.linlinjava.litemall.db.domain.LitemallCategory; import org.linlinjava.litemall.db.service.LitemallCategoryService; -import org.linlinjava.litemall.core.util.ResponseUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -22,24 +22,24 @@ public class WxCatalogController { /** * 分类栏目 * - * @param id 分类类目ID - * 如果分类类目ID是空,则选择第一个分类类目。 - * 需要注意,这里分类类目是一级类目 + * @param id 分类类目ID + * 如果分类类目ID是空,则选择第一个分类类目。 + * 需要注意,这里分类类目是一级类目 * @param page 分页页数 * @param size 分页大小 * @return 分类栏目 - * 成功则 - * { - * errno: 0, - * errmsg: '成功', - * data: - * { - * categoryList: xxx, - * currentCategory: xxx, - * currentSubCategory: xxx - * } - * } - * 失败则 { errno: XXX, errmsg: XXX } + * 成功则 + * { + * errno: 0, + * errmsg: '成功', + * data: + * { + * categoryList: xxx, + * currentCategory: xxx, + * currentSubCategory: xxx + * } + * } + * 失败则 { errno: XXX, errmsg: XXX } */ @GetMapping("index") public Object index(Integer id, @@ -51,10 +51,9 @@ public class WxCatalogController { // 当前一级分类目录 LitemallCategory currentCategory = null; - if(id != null){ + if (id != null) { currentCategory = categoryService.findById(id); - } - else{ + } else { currentCategory = l1CatList.get(0); } @@ -71,26 +70,61 @@ public class WxCatalogController { return ResponseUtil.ok(data); } + /** + * 一次性获取全部分类数据 + * + * @return + */ + @GetMapping("all") + public Object queryAll() { + // 所有一级分类目录 + List l1CatList = categoryService.queryL1(); + + //所有子分类列表 + Map> allList = new HashMap<>(); + List sub; + for (LitemallCategory category : l1CatList) { + sub = categoryService.queryByPid(category.getId()); + allList.put(category.getId(), sub); + } + + // 当前一级分类目录 + LitemallCategory currentCategory = l1CatList.get(0); + + // 当前一级分类目录对应的二级分类目录 + List currentSubCategory = null; + if (null != currentCategory) { + currentSubCategory = categoryService.queryByPid(currentCategory.getId()); + } + + Map data = new HashMap(); + data.put("categoryList", l1CatList); + data.put("allList", allList); + data.put("currentCategory", currentCategory); + data.put("currentSubCategory", currentSubCategory); + return ResponseUtil.ok(data); + } + /** * 当前分类栏目 * * @param id 分类类目ID * @return 当前分类栏目 - * 成功则 - * { - * errno: 0, - * errmsg: '成功', - * data: - * { - * currentCategory: xxx, - * currentSubCategory: xxx - * } - * } - * 失败则 { errno: XXX, errmsg: XXX } + * 成功则 + * { + * errno: 0, + * errmsg: '成功', + * data: + * { + * currentCategory: xxx, + * currentSubCategory: xxx + * } + * } + * 失败则 { errno: XXX, errmsg: XXX } */ @GetMapping("current") public Object current(Integer id) { - if(id == null){ + if (id == null) { return ResponseUtil.badArgument(); }