ソースを参照

特价产品tab

jz.kai 4 年 前
コミット
e7a5d0cbaf

+ 50 - 0
web/src/main/java/com/jpsoft/machinery/modules/open/CataloguesApiController.java

@@ -0,0 +1,50 @@
+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.service.CataloguesService;
+import com.jpsoft.machinery.modules.common.dto.MessageResult;
+import com.jpsoft.machinery.modules.common.dto.QueryListDTO;
+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/cataloguesApi")
+@Api(description = "商品类型")
+public class CataloguesApiController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private CataloguesService cataloguesService;
+
+    @ApiOperation(value="根据父ID获取列表")
+    @RequestMapping(value = "findListByParentId",method = RequestMethod.POST)
+    public MessageResult<List<Catalogues>> findListByParentId(String parentId){
+        MessageResult<List<Catalogues>> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("sort_","asc"));
+
+        if (StringUtils.isNotEmpty(parentId) && !"null".equals(parentId)) {
+            searchParams.put("parentId",parentId);
+        }
+
+        Page<Catalogues> page = cataloguesService.pageSearch(searchParams,1,100,false,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(page.getResult());
+
+        return msgResult;
+    }
+}

+ 28 - 0
web/src/main/java/com/jpsoft/machinery/modules/open/CommodityApiController.java

@@ -79,4 +79,32 @@ public class CommodityApiController {
 
 
         return msgResult;
         return msgResult;
     }
     }
+
+    @ApiOperation(value="商品列表")
+    @RequestMapping(value = "findListByCataloguesId",method = RequestMethod.POST)
+    public MessageResult<List<Commodity>> findListByCataloguesId(String cataloguesId){
+        MessageResult<List<Commodity>> msgResult = new MessageResult<>();
+
+        try {
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("create_time", "asc"));
+            Map<String, Object> searchParams = new HashMap<>();
+            if(StringUtils.isNotEmpty(cataloguesId)) {
+                searchParams.put("cataloguesId", cataloguesId);
+            }
+
+            Page<Commodity> commodityPage = commodityService.pageSearch(searchParams, 1, 1000, false, sortList);
+
+            msgResult.setResult(true);
+            msgResult.setCode(200);
+            msgResult.setData(commodityPage.getResult());
+        }
+        catch (Exception ex){
+            msgResult.setResult(false);
+            msgResult.setCode(400);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }
 }