|
@@ -0,0 +1,64 @@
|
|
|
|
+package com.jpsoft.machinery.modules.open;
|
|
|
|
+
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
+import com.jpsoft.machinery.modules.base.entity.Catalogues;
|
|
|
|
+import com.jpsoft.machinery.modules.base.entity.Commodity;
|
|
|
|
+import com.jpsoft.machinery.modules.base.service.CataloguesService;
|
|
|
|
+import com.jpsoft.machinery.modules.base.service.CommodityService;
|
|
|
|
+import com.jpsoft.machinery.modules.common.dto.MessageResult;
|
|
|
|
+import com.jpsoft.machinery.modules.common.dto.Sort;
|
|
|
|
+import com.jpsoft.machinery.modules.common.utils.PojoUtils;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/open/commodityApi")
|
|
|
|
+@Api(description = "商品接口")
|
|
|
|
+public class CommodityApiController {
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommodityService commodityService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CataloguesService cataloguesService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation(value="商品列表")
|
|
|
|
+ @RequestMapping(value = "commodityList",method = RequestMethod.POST)
|
|
|
|
+ public List<Map> commodityList(){
|
|
|
|
+ List<Map> listResult = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ 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"));
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<Commodity> commodityPage = commodityService.pageSearch(searchParamsEx,1,1000,false,sortListEx);
|
|
|
|
+
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("name", catalogues.getTitle());
|
|
|
|
+ map.put("list", commodityPage.getResult());
|
|
|
|
+ listResult.add(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return listResult;
|
|
|
|
+ }
|
|
|
|
+}
|