|
@@ -1,16 +1,20 @@
|
|
|
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 io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -32,19 +36,27 @@ import java.util.Map;
|
|
|
public class ProductApi {
|
|
|
private final ProductService productService;
|
|
|
|
|
|
+ @Value("${caimei.cloudApi}")
|
|
|
+ private String cloudApi;
|
|
|
+
|
|
|
@ApiOperation("轮播图")
|
|
|
@GetMapping("/carousel")
|
|
|
- public ResponseJson<List<String>> carouselFigure() {
|
|
|
+ public ResponseJson<List<CmHeHeImageVo>> carouselFigure() {
|
|
|
return productService.carouselFigure();
|
|
|
}
|
|
|
|
|
|
@ApiOperation("首页楼层")
|
|
|
- @GetMapping("/floor")
|
|
|
+ @GetMapping("/home/init")
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "用户id")
|
|
|
- public ResponseJson<List<FloorVo>> productFloor(Integer userId) {
|
|
|
- return productService.productFloor(userId);
|
|
|
+ public ResponseJson<String> gethomeData(Integer userId) throws Exception {
|
|
|
+ String url = cloudApi + "/commodity/hehe/home/init?userId=" + userId;
|
|
|
+ String parameters = HttpRequest.sendGet(url);
|
|
|
+ return getResponseJson(parameters);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 废弃
|
|
|
+ */
|
|
|
@ApiOperation("首页楼层详情")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "floorId", value = "楼层Id", required = true),
|
|
@@ -61,15 +73,28 @@ public class ProductApi {
|
|
|
|
|
|
@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 = "userId", value = "用户id", required = false),
|
|
|
- @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
|
|
|
- @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
|
|
|
+ @ApiImplicitParam(name = "sortType", value = "排序类型:1综合,2价格升序,3价格降序,4最新", required = false),
|
|
|
+ @ApiImplicitParam(name = "productIds", value = "综合排序已查出的商品id,以,隔开", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageNum", value = "页码", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageSize", value = "每页数量", required = false)
|
|
|
})
|
|
|
@GetMapping("/list")
|
|
|
- public ResponseJson<PageInfo<ProductVo>> productList(String name, Integer userId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
- return productService.productList(name, userId, pageNum, pageSize);
|
|
|
+ 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 {
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("商品详情")
|
|
@@ -78,43 +103,42 @@ public class ProductApi {
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "机构用户Id")
|
|
|
})
|
|
|
@GetMapping("/details")
|
|
|
- public ResponseJson<ProductVo> productDetails(Integer productId, Integer userId) {
|
|
|
- return productService.productDetails(productId, userId);
|
|
|
+ public ResponseJson<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);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("商品搜索历史记录")
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "用户id")
|
|
|
@GetMapping("/search/history")
|
|
|
- public ResponseJson<List<String>> searchHistory(Integer userId) {
|
|
|
- if (userId == null) {
|
|
|
- return ResponseJson.error("参数异常", null);
|
|
|
- }
|
|
|
- return productService.searchHistory(userId);
|
|
|
+ public ResponseJson<String> searchHistory(Integer userId) throws Exception {
|
|
|
+ String url = cloudApi + "/commodity/search/query/history?userId=" + userId;
|
|
|
+ String parameters = HttpRequest.sendGet(url);
|
|
|
+ return getResponseJson(parameters);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("删除搜索历史记录")
|
|
|
@ApiImplicitParam(name = "userId", required = true, value = "用户id")
|
|
|
@GetMapping("/delete/history")
|
|
|
- public ResponseJson<String> deleteHistory(Integer userId) {
|
|
|
- if (userId == null) {
|
|
|
- return ResponseJson.error("参数异常", null);
|
|
|
- }
|
|
|
- return productService.deleteHistory(userId);
|
|
|
+ public ResponseJson<String> deleteHistory(Integer userId) throws Exception {
|
|
|
+ String url = cloudApi + "/commodity/search/query/history/delete?userId=" + userId;
|
|
|
+ String parameters = HttpRequest.sendGet(url);
|
|
|
+ return getResponseJson(parameters);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("活动专区")
|
|
|
+ @ApiOperation("活动专区(旧:/product/activityArea)")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
|
|
|
@ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
|
|
|
@ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
|
|
|
})
|
|
|
- @GetMapping("/activityArea")
|
|
|
- public ResponseJson<PageInfo<HeHeActivityVo>> activityArea(Integer userId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
- if (userId == null) {
|
|
|
- return ResponseJson.error("参数异常", null);
|
|
|
- }
|
|
|
- return productService.activityArea(userId, pageNum, pageSize);
|
|
|
+ @GetMapping("/activity/list")
|
|
|
+ public ResponseJson<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);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("活动详情")
|
|
@@ -125,12 +149,26 @@ public class ProductApi {
|
|
|
@ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
|
|
|
})
|
|
|
@GetMapping("/activity/details")
|
|
|
- public ResponseJson<Map<String, Object>> activityDetails(Integer userId, Integer activityId,
|
|
|
+ public ResponseJson<String> activityDetails(Integer userId, Integer activityId,
|
|
|
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
- @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
- if (userId == null || activityId == null) {
|
|
|
- return ResponseJson.error("参数异常", null);
|
|
|
- }
|
|
|
- return productService.activityDetails(userId, activityId, pageNum, pageSize);
|
|
|
+ @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);}
|
|
|
+
|
|
|
+ @ApiOperation("首页分类列表")
|
|
|
+ @GetMapping("/home/type")
|
|
|
+ public ResponseJson<String> getHomeTypeList() throws Exception {
|
|
|
+ String url = cloudApi + "/commodity/hehe/home/type";
|
|
|
+ String parameters = HttpRequest.sendGet(url);
|
|
|
+ return getResponseJson(parameters);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|