ProductApi.java 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package com.caimei.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.model.ResponseJson;
  4. import com.caimei.model.vo.CmHeHeImageVo;
  5. import com.caimei.service.ProductService;
  6. import com.caimei.util.HttpRequest;
  7. import com.caimei.util.OkHttpUtil;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiImplicitParam;
  10. import io.swagger.annotations.ApiImplicitParams;
  11. import io.swagger.annotations.ApiOperation;
  12. import lombok.RequiredArgsConstructor;
  13. import org.springframework.beans.factory.annotation.Value;
  14. import org.springframework.web.bind.annotation.GetMapping;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestParam;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import java.util.List;
  19. /**
  20. * Description
  21. *
  22. * @author : plf
  23. * @date : 2021/4/22
  24. */
  25. @Api(tags = "商品管理API")
  26. @RestController
  27. @RequiredArgsConstructor
  28. @RequestMapping("/product")
  29. public class ProductApi {
  30. private final ProductService productService;
  31. @Value("${caimei.cloudApi}")
  32. private String cloudApi;
  33. @ApiOperation("轮播图")
  34. @GetMapping("/carousel")
  35. public String carouselFigure() throws Exception {
  36. String url = cloudApi + "/commodity/hehe/home/carousel";
  37. return HttpRequest.sendGet(url);
  38. }
  39. @ApiOperation("首页楼层")
  40. @GetMapping("/home/init")
  41. @ApiImplicitParam(name = "userId", required = true, value = "用户id")
  42. public String gethomeData(Integer userId) throws Exception {
  43. String url = cloudApi + "/commodity/hehe/home/init?userId=" + userId;
  44. return HttpRequest.sendGet(url);
  45. }
  46. @ApiOperation("商品列表")
  47. @ApiImplicitParams({
  48. @ApiImplicitParam(name = "listType", value = "列表类型:1首页搜索商品列表,2首页分类商品列表,3首页楼层商品列表.4二级分类商品列表,5优惠券商品列表,6活动商品列表", required = false),
  49. @ApiImplicitParam(name = "name", value = "搜索商品名称(1)", required = false),
  50. @ApiImplicitParam(name = "homeTypeId", value = "首页分类id(2)", required = false),
  51. @ApiImplicitParam(name = "homeFloorId", value = "首页楼层id(3)", required = false),
  52. @ApiImplicitParam(name = "smallTypeId", value = "二级分类id(4)", required = false),
  53. @ApiImplicitParam(name = "couponId", value = "优惠券id(5)", required = false),
  54. @ApiImplicitParam(name = "activityId", value = "活动id(6)", required = false),
  55. @ApiImplicitParam(name = "userId", value = "用户id", required = false),
  56. @ApiImplicitParam(name = "sortType", value = "排序类型:1综合,2价格升序,3价格降序,4最新", required = false),
  57. @ApiImplicitParam(name = "productIds", value = "综合排序已查出的商品id,以,隔开", required = false),
  58. @ApiImplicitParam(name = "pageNum", value = "页码", required = false),
  59. @ApiImplicitParam(name = "pageSize", value = "每页数量", required = false)
  60. })
  61. @GetMapping("/list")
  62. public String productList(@RequestParam(value = "listType", defaultValue = "1") Integer listType,
  63. @RequestParam(value = "name", defaultValue = "") String name,
  64. @RequestParam(value = "homeTypeId", defaultValue = "0") Integer homeTypeId,
  65. @RequestParam(value = "homeFloorId", defaultValue = "0") Integer homeFloorId,
  66. @RequestParam(value = "smallTypeId", defaultValue = "0") Integer smallTypeId,
  67. @RequestParam(value = "couponId", defaultValue = "0") Integer couponId,
  68. @RequestParam(value = "activityId", defaultValue = "0") Integer activityId,
  69. @RequestParam(value = "userId", defaultValue = "0") Integer userId,
  70. @RequestParam(value = "productIds", defaultValue = "") String productIds,
  71. @RequestParam(value = "sortType", defaultValue = "4") Integer sortType,
  72. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  73. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
  74. String url = cloudApi + "/commodity/hehe/product/list?listType=" + listType + "&homeTypeId=" + homeTypeId +
  75. "&homeFloorId=" + homeFloorId + "&smallTypeId=" + smallTypeId + "&name=" + name + "&couponId=" + couponId +
  76. "&activityId=" + activityId + "&userId=" + userId + "&sortType=" + sortType + "&productIds=" + productIds +
  77. "&pageNum=" + pageNum + "&pageSize=" + pageSize;
  78. return OkHttpUtil.sendGet(url);
  79. }
  80. @ApiOperation("商品详情")
  81. @ApiImplicitParams({
  82. @ApiImplicitParam(name = "productId", required = true, value = "商品Id"),
  83. @ApiImplicitParam(name = "userId", required = true, value = "机构用户Id")
  84. })
  85. @GetMapping("/details")
  86. public String productDetails(Integer productId, Integer userId) throws Exception {
  87. String url = cloudApi + "/commodity/hehe/details?productId=" + productId + "&userId=" + userId;
  88. return HttpRequest.sendGet(url);
  89. }
  90. @ApiOperation("商品搜索历史记录")
  91. @ApiImplicitParam(name = "userId", required = true, value = "用户id")
  92. @GetMapping("/search/history")
  93. public String searchHistory(Integer userId) throws Exception {
  94. String url = cloudApi + "/commodity/search/query/history?userId=" + userId;
  95. return HttpRequest.sendGet(url);
  96. }
  97. @ApiOperation("删除搜索历史记录")
  98. @ApiImplicitParam(name = "userId", required = true, value = "用户id")
  99. @GetMapping("/delete/history")
  100. public String deleteHistory(Integer userId) throws Exception {
  101. String url = cloudApi + "/commodity/search/query/history/delete?userId=" + userId;
  102. return HttpRequest.sendGet(url);
  103. }
  104. @ApiOperation("活动专区(旧:/product/activityArea)")
  105. @ApiImplicitParams({
  106. @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
  107. @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
  108. @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
  109. })
  110. @GetMapping("/activity/list")
  111. public String activityArea(Integer userId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  112. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
  113. String url = cloudApi + "/commodity/hehe/activity/list?userId=" + userId + "&pageNum=" + pageNum + "&pageSize=" + pageSize;
  114. return HttpRequest.sendGet(url);
  115. }
  116. @ApiOperation("活动详情")
  117. @ApiImplicitParams({
  118. @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
  119. @ApiImplicitParam(name = "activityId", value = "活动id", required = true),
  120. @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
  121. @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
  122. })
  123. @GetMapping("/activity/details")
  124. public String activityDetails(Integer userId, Integer activityId,
  125. @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
  126. @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) throws Exception {
  127. String url = cloudApi + "/commodity/hehe/activity/details?userId=" + userId + "&activityId=" + activityId+ "&pageNum=" + pageNum + "&pageSize=" + pageSize;
  128. return HttpRequest.sendGet(url);
  129. }
  130. @ApiOperation("首页分类列表")
  131. @GetMapping("/home/type")
  132. public String getHomeTypeList() throws Exception {
  133. String url = cloudApi + "/commodity/hehe/home/type";
  134. return HttpRequest.sendGet(url);
  135. }
  136. @ApiOperation("分类列表")
  137. @GetMapping("/classify")
  138. public String getClassify() throws Exception {
  139. String url = cloudApi + "/commodity/classify?typeSort=3&mallType=2&source=crm";
  140. return HttpRequest.sendGet(url);
  141. }
  142. }