Commit ba507599 authored by Menethil's avatar Menethil
Browse files

增加一次性获取全部分类数据接口

parent e73f061a
module.exports = { module.exports = {
NODE_ENV: '"production"', NODE_ENV: '"production"',
ENV_CONFIG: '"dep"', ENV_CONFIG: '"dep"',
BASE_API: '"http://122.152.206.172:8083/admin"' BASE_API: '"https://www.menethil.com.cn/admin"'
} }
package org.linlinjava.litemall.wx.web; 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.domain.LitemallCategory;
import org.linlinjava.litemall.db.service.LitemallCategoryService; import org.linlinjava.litemall.db.service.LitemallCategoryService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -51,10 +51,9 @@ public class WxCatalogController { ...@@ -51,10 +51,9 @@ public class WxCatalogController {
// 当前一级分类目录 // 当前一级分类目录
LitemallCategory currentCategory = null; LitemallCategory currentCategory = null;
if(id != null){ if (id != null) {
currentCategory = categoryService.findById(id); currentCategory = categoryService.findById(id);
} } else {
else{
currentCategory = l1CatList.get(0); currentCategory = l1CatList.get(0);
} }
...@@ -71,6 +70,41 @@ public class WxCatalogController { ...@@ -71,6 +70,41 @@ public class WxCatalogController {
return ResponseUtil.ok(data); return ResponseUtil.ok(data);
} }
/**
* 一次性获取全部分类数据
*
* @return
*/
@GetMapping("all")
public Object queryAll() {
// 所有一级分类目录
List<LitemallCategory> l1CatList = categoryService.queryL1();
//所有子分类列表
Map<Integer, List<LitemallCategory>> allList = new HashMap<>();
List<LitemallCategory> sub;
for (LitemallCategory category : l1CatList) {
sub = categoryService.queryByPid(category.getId());
allList.put(category.getId(), sub);
}
// 当前一级分类目录
LitemallCategory currentCategory = l1CatList.get(0);
// 当前一级分类目录对应的二级分类目录
List<LitemallCategory> currentSubCategory = null;
if (null != currentCategory) {
currentSubCategory = categoryService.queryByPid(currentCategory.getId());
}
Map<String, Object> data = new HashMap();
data.put("categoryList", l1CatList);
data.put("allList", allList);
data.put("currentCategory", currentCategory);
data.put("currentSubCategory", currentSubCategory);
return ResponseUtil.ok(data);
}
/** /**
* 当前分类栏目 * 当前分类栏目
* *
...@@ -90,7 +124,7 @@ public class WxCatalogController { ...@@ -90,7 +124,7 @@ public class WxCatalogController {
*/ */
@GetMapping("current") @GetMapping("current")
public Object current(Integer id) { public Object current(Integer id) {
if(id == null){ if (id == null) {
return ResponseUtil.badArgument(); return ResponseUtil.badArgument();
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment