|
@@ -3,12 +3,9 @@ package com.caimei.controller;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.caimei.model.ResponseJson;
|
|
|
import com.caimei.model.vo.CmHeHeImageVo;
|
|
|
-import com.caimei.model.vo.FloorVo;
|
|
|
-import com.caimei.model.vo.HeHeActivityVo;
|
|
|
-import com.caimei.model.vo.ProductVo;
|
|
|
import com.caimei.service.ProductService;
|
|
|
import com.caimei.util.HttpRequest;
|
|
|
-import com.github.pagehelper.PageInfo;
|
|
|
+import com.caimei.util.OkHttpUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -21,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -48,20 +44,21 @@ public class ProductApi {
|
|
|
@ApiOperation("首页楼层")
|
|
|
@GetMapping("/home/init")
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "用户id")
|
|
|
- public ResponseJson<String> gethomeData(Integer userId) throws Exception {
|
|
|
+ public String gethomeData(Integer userId) throws Exception {
|
|
|
String url = cloudApi + "/commodity/hehe/home/init?userId=" + userId;
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
|
|
|
@ApiOperation("商品列表")
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "listType", value = "列表类型:1首页搜索商品列表,2首页分类商品列表,3首页楼层商品列表.4二级分类商品列表", required = false),
|
|
|
- @ApiImplicitParam(name = "homeTypeId", value = "首页分类id", required = false),
|
|
|
- @ApiImplicitParam(name = "homeFloorId", value = "首页楼层id", required = false),
|
|
|
- @ApiImplicitParam(name = "smallTypeId", value = "二级分类id", required = false),
|
|
|
- @ApiImplicitParam(name = "name", value = "搜索商品名称", required = false),
|
|
|
+ @ApiImplicitParam(name = "listType", value = "列表类型:1首页搜索商品列表,2首页分类商品列表,3首页楼层商品列表.4二级分类商品列表,5优惠券商品列表,6活动商品列表", required = false),
|
|
|
+ @ApiImplicitParam(name = "name", value = "搜索商品名称(1)", required = false),
|
|
|
+ @ApiImplicitParam(name = "homeTypeId", value = "首页分类id(2)", required = false),
|
|
|
+ @ApiImplicitParam(name = "homeFloorId", value = "首页楼层id(3)", required = false),
|
|
|
+ @ApiImplicitParam(name = "smallTypeId", value = "二级分类id(4)", required = false),
|
|
|
+ @ApiImplicitParam(name = "couponId", value = "优惠券id(5)", required = false),
|
|
|
+ @ApiImplicitParam(name = "activityId", value = "活动id(6)", required = false),
|
|
|
@ApiImplicitParam(name = "userId", value = "用户id", required = false),
|
|
|
@ApiImplicitParam(name = "sortType", value = "排序类型:1综合,2价格升序,3价格降序,4最新", required = false),
|
|
|
@ApiImplicitParam(name = "productIds", value = "综合排序已查出的商品id,以,隔开", required = false),
|
|
@@ -69,16 +66,23 @@ public class ProductApi {
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页数量", required = false)
|
|
|
})
|
|
|
@GetMapping("/list")
|
|
|
- public ResponseJson<String> productList(@RequestParam(value = "listType", defaultValue = "1") Integer listType, Integer homeTypeId,
|
|
|
- Integer homeFloorId, Integer smallTypeId, String name, Integer userId, String productIds,
|
|
|
- @RequestParam(value = "sortType", defaultValue = "4") Integer sortType,
|
|
|
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
|
|
|
+ public String productList(@RequestParam(value = "listType", defaultValue = "1") Integer listType,
|
|
|
+ @RequestParam(value = "name", defaultValue = "") String name,
|
|
|
+ @RequestParam(value = "homeTypeId", defaultValue = "0") Integer homeTypeId,
|
|
|
+ @RequestParam(value = "homeFloorId", defaultValue = "0") Integer homeFloorId,
|
|
|
+ @RequestParam(value = "smallTypeId", defaultValue = "0") Integer smallTypeId,
|
|
|
+ @RequestParam(value = "couponId", defaultValue = "0") Integer couponId,
|
|
|
+ @RequestParam(value = "activityId", defaultValue = "0") Integer activityId,
|
|
|
+ @RequestParam(value = "userId", defaultValue = "0") Integer userId,
|
|
|
+ @RequestParam(value = "productIds", defaultValue = "") String productIds,
|
|
|
+ @RequestParam(value = "sortType", defaultValue = "4") Integer sortType,
|
|
|
+ @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
String url = cloudApi + "/commodity/hehe/product/list?listType=" + listType + "&homeTypeId=" + homeTypeId +
|
|
|
- "&homeFloorId=" + homeFloorId + "&smallTypeId=" + smallTypeId+ "&name=" + name + "&userId=" + userId +
|
|
|
- "&sortType=" + sortType + "&productIds=" + productIds + "&pageNum=" + pageNum + "&pageSize=" + pageSize;
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ "&homeFloorId=" + homeFloorId + "&smallTypeId=" + smallTypeId + "&name=" + name + "&couponId=" + couponId +
|
|
|
+ "&activityId=" + activityId + "&userId=" + userId + "&sortType=" + sortType + "&productIds=" + productIds +
|
|
|
+ "&pageNum=" + pageNum + "&pageSize=" + pageSize;
|
|
|
+ return OkHttpUtil.sendGet(url);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("商品详情")
|
|
@@ -87,28 +91,25 @@ public class ProductApi {
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "机构用户Id")
|
|
|
})
|
|
|
@GetMapping("/details")
|
|
|
- public ResponseJson<String> productDetails(Integer productId, Integer userId) throws Exception {
|
|
|
+ public String productDetails(Integer productId, Integer userId) throws Exception {
|
|
|
String url = cloudApi + "/commodity/hehe/details?productId=" + productId + "&userId=" + userId;
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("商品搜索历史记录")
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "用户id")
|
|
|
@GetMapping("/search/history")
|
|
|
- public ResponseJson<String> searchHistory(Integer userId) throws Exception {
|
|
|
+ public String searchHistory(Integer userId) throws Exception {
|
|
|
String url = cloudApi + "/commodity/search/query/history?userId=" + userId;
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("删除搜索历史记录")
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "用户id")
|
|
|
@GetMapping("/delete/history")
|
|
|
- public ResponseJson<String> deleteHistory(Integer userId) throws Exception {
|
|
|
+ public String deleteHistory(Integer userId) throws Exception {
|
|
|
String url = cloudApi + "/commodity/search/query/history/delete?userId=" + userId;
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("活动专区(旧:/product/activityArea)")
|
|
@@ -118,11 +119,10 @@ public class ProductApi {
|
|
|
@ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
|
|
|
})
|
|
|
@GetMapping("/activity/list")
|
|
|
- public ResponseJson<String> activityArea(Integer userId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
+ public String activityArea(Integer userId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
|
|
|
String url = cloudApi + "/commodity/hehe/activity/list?userId=" + userId + "&pageNum=" + pageNum + "&pageSize=" + pageSize;
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("活动详情")
|
|
@@ -133,35 +133,44 @@ public class ProductApi {
|
|
|
@ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
|
|
|
})
|
|
|
@GetMapping("/activity/details")
|
|
|
- public ResponseJson<String> activityDetails(Integer userId, Integer activityId,
|
|
|
+ public String activityDetails(Integer userId, Integer activityId,
|
|
|
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
|
|
|
String url = cloudApi + "/commodity/hehe/activity/details?userId=" + userId + "&activityId=" + activityId+ "&pageNum=" + pageNum + "&pageSize=" + pageSize;
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("首页分类列表")
|
|
|
@GetMapping("/home/type")
|
|
|
- public ResponseJson<String> getHomeTypeList() throws Exception {
|
|
|
+ public String getHomeTypeList() throws Exception {
|
|
|
String url = cloudApi + "/commodity/hehe/home/type";
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("一级分类列表")
|
|
|
- @GetMapping("/type/first")
|
|
|
- public ResponseJson<String> getBigTypeSelect() throws Exception {
|
|
|
- String url = cloudApi + "/commodity/type/first?mallType=2";
|
|
|
- String parameters = HttpRequest.sendGet(url);
|
|
|
- return getResponseJson(parameters);
|
|
|
+ @ApiOperation("分类列表")
|
|
|
+ @GetMapping("/classify")
|
|
|
+ public String getClassify() throws Exception {
|
|
|
+ String url = cloudApi + "/commodity/classify?typeSort=3&mallType=2";
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
}
|
|
|
|
|
|
+ /*@ApiOperation("二级分类列表")
|
|
|
+ @ApiImplicitParam(name = "bigTypeId", value = "一级分类Id", required = true)
|
|
|
+ @GetMapping("/type/second")
|
|
|
+ public String getSmallTypeSelect(Integer bigTypeId) throws Exception {
|
|
|
+ String url = cloudApi + "/commodity/type/second?bigTypeId=" + bigTypeId;
|
|
|
+ return HttpRequest.sendGet(url);
|
|
|
+ }*/
|
|
|
+
|
|
|
private ResponseJson<String> getResponseJson(String parameters) {
|
|
|
JSONObject object = JSONObject.parseObject(parameters);
|
|
|
- Integer code = object.getInteger("code");
|
|
|
- String msg = object.getString("msg");
|
|
|
- String data = object.getString("data");
|
|
|
- return ResponseJson.success(code, msg, data);
|
|
|
+ if (null != object) {
|
|
|
+ Integer code = object.getInteger("code");
|
|
|
+ String msg = object.getString("msg");
|
|
|
+ String data = object.getString("data");
|
|
|
+ return ResponseJson.success(code, msg, data);
|
|
|
+ } else {
|
|
|
+ return ResponseJson.success(null);
|
|
|
+ }
|
|
|
}
|
|
|
}
|