|
@@ -31,34 +31,47 @@ public class CommodityApiController {
|
|
|
|
|
|
@ApiOperation(value="商品列表")
|
|
@ApiOperation(value="商品列表")
|
|
@RequestMapping(value = "commodityList",method = RequestMethod.POST)
|
|
@RequestMapping(value = "commodityList",method = RequestMethod.POST)
|
|
- public List<Map> commodityList(){
|
|
|
|
- List<Map> listResult = new ArrayList<>();
|
|
|
|
|
|
+ public MessageResult<List<Map>> commodityList(){
|
|
|
|
+ MessageResult<List<Map>> msgResult = new MessageResult<>();
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
|
- searchParams.put("parentId", "6b91395e-d5f5-47c2-bca2-1a79b1f1e646");
|
|
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
+ searchParams.put("parentId", "6b91395e-d5f5-47c2-bca2-1a79b1f1e646");
|
|
|
|
|
|
- List<Sort> sortList = new ArrayList<>();
|
|
|
|
- sortList.add(new Sort("sort_","asc"));
|
|
|
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort("sort_", "asc"));
|
|
|
|
|
|
- Page<Catalogues> page = cataloguesService.pageSearch(searchParams,1,1000,false,sortList);
|
|
|
|
- for(Catalogues catalogues : page.getResult()){
|
|
|
|
- List<String> cataloguesIds = cataloguesService.findListBySortAll(catalogues.getSort() + "%");
|
|
|
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
|
+ Page<Catalogues> page = cataloguesService.pageSearch(searchParams, 1, 1000, false, sortList);
|
|
|
|
+ for (Catalogues catalogues : page.getResult()) {
|
|
|
|
+ List<String> cataloguesIds = cataloguesService.findListBySortAll(catalogues.getSort() + "%");
|
|
|
|
|
|
- List<Sort> sortListEx = new ArrayList<>();
|
|
|
|
- sortList.add(new Sort("create_time","asc"));
|
|
|
|
- Map<String,Object> searchParamsEx = new HashMap<>();
|
|
|
|
- if(cataloguesIds.size() > 0) {
|
|
|
|
- searchParamsEx.put("cataloguesIds", cataloguesIds);
|
|
|
|
- }
|
|
|
|
|
|
+ List<Sort> sortListEx = new ArrayList<>();
|
|
|
|
+ sortList.add(new Sort("create_time", "asc"));
|
|
|
|
+ Map<String, Object> searchParamsEx = new HashMap<>();
|
|
|
|
+ if (cataloguesIds.size() > 0) {
|
|
|
|
+ searchParamsEx.put("cataloguesIds", cataloguesIds);
|
|
|
|
+ }
|
|
|
|
|
|
- Page<Commodity> commodityPage = commodityService.pageSearch(searchParamsEx,1,1000,false,sortListEx);
|
|
|
|
|
|
+ Page<Commodity> commodityPage = commodityService.pageSearch(searchParamsEx, 1, 1000, false, sortListEx);
|
|
|
|
+ if(commodityPage.size() > 0) {
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("name", catalogues.getTitle());
|
|
|
|
+ map.put("list", commodityPage.getResult());
|
|
|
|
+ mapList.add(map);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- Map map = new HashMap();
|
|
|
|
- map.put("name", catalogues.getTitle());
|
|
|
|
- map.put("list", commodityPage.getResult());
|
|
|
|
- listResult.add(map);
|
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ msgResult.setCode(200);
|
|
|
|
+ msgResult.setData(mapList);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex){
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setCode(400);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
- return listResult;
|
|
|
|
|
|
+ return msgResult;
|
|
}
|
|
}
|
|
}
|
|
}
|