123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- package com.caimei.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.vo.CmHeHeImageVo;
- import com.caimei.service.ProductService;
- import com.caimei.util.HttpRequest;
- import com.caimei.util.OkHttpUtil;
- 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;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- /**
- * Description
- *
- * @author : plf
- * @date : 2021/4/22
- */
- @Api(tags = "商品管理API")
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/product")
- public class ProductApi {
- private final ProductService productService;
- @Value("${caimei.cloudApi}")
- private String cloudApi;
- @ApiOperation("轮播图")
- @GetMapping("/carousel")
- public String carouselFigure() throws Exception {
- String url = cloudApi + "/commodity/hehe/home/carousel";
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("首页楼层")
- @GetMapping("/home/init")
- @ApiImplicitParam(name = "userId", required = true, value = "用户id")
- public String gethomeData(Integer userId) throws Exception {
- String url = cloudApi + "/commodity/hehe/home/init?userId=" + userId;
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("商品列表")
- @ApiImplicitParams({
- @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),
- @ApiImplicitParam(name = "pageNum", value = "页码", required = false),
- @ApiImplicitParam(name = "pageSize", value = "每页数量", required = false)
- })
- @GetMapping("/list")
- 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 + "&couponId=" + couponId +
- "&activityId=" + activityId + "&userId=" + userId + "&sortType=" + sortType + "&productIds=" + productIds +
- "&pageNum=" + pageNum + "&pageSize=" + pageSize;
- return OkHttpUtil.sendGet(url);
- }
- @ApiOperation("商品详情")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "productId", required = true, value = "商品Id"),
- @ApiImplicitParam(name = "userId", required = true, value = "机构用户Id")
- })
- @GetMapping("/details")
- public String productDetails(Integer productId, Integer userId) throws Exception {
- String url = cloudApi + "/commodity/hehe/details?productId=" + productId + "&userId=" + userId;
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("商品搜索历史记录")
- @ApiImplicitParam(name = "userId", required = true, value = "用户id")
- @GetMapping("/search/history")
- public String searchHistory(Integer userId) throws Exception {
- String url = cloudApi + "/commodity/search/query/history?userId=" + userId;
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("删除搜索历史记录")
- @ApiImplicitParam(name = "userId", required = true, value = "用户id")
- @GetMapping("/delete/history")
- public String deleteHistory(Integer userId) throws Exception {
- String url = cloudApi + "/commodity/search/query/history/delete?userId=" + userId;
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("活动专区(旧:/product/activityArea)")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
- @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
- @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
- })
- @GetMapping("/activity/list")
- 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;
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("活动详情")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
- @ApiImplicitParam(name = "activityId", value = "活动id", required = true),
- @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
- @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
- })
- @GetMapping("/activity/details")
- 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;
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("首页分类列表")
- @GetMapping("/home/type")
- public String getHomeTypeList() throws Exception {
- String url = cloudApi + "/commodity/hehe/home/type";
- return HttpRequest.sendGet(url);
- }
- @ApiOperation("分类列表")
- @GetMapping("/classify")
- public String getClassify() throws Exception {
- String url = cloudApi + "/commodity/classify?typeSort=3&mallType=2&source=crm";
- return HttpRequest.sendGet(url);
- }
- }
|