xiaoyong931011
2021-06-25 9f947ed231edeb18fb16a03cbd437aa28be93631
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.xzx.gc.shop.controller;
 
 
import com.github.pagehelper.PageInfo;
import com.xzx.gc.model.JsonResult;
import com.xzx.gc.shop.dto.XcxGoodsListDto;
import com.xzx.gc.shop.service.GoodsService;
import com.xzx.gc.shop.vo.GoodsCategoryVo;
import com.xzx.gc.shop.vo.XcxGoodsDetailVo;
import com.xzx.gc.shop.vo.XcxGoodsListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
@RestController
@Api(tags = {"积分商城--API商品管理"})
@Slf4j
public class ApiGoodsController {
 
    @Autowired
    private GoodsService goodsService;
 
    @ApiOperation("分类列表")
    @ApiResponses(
            @ApiResponse(code = 200, message = "success", response = GoodsCategoryVo.class)
    )
    @GetMapping(value = "/goods/goodsCategory")
    public JsonResult<List<GoodsCategoryVo>> goodsCategory() {
        return JsonResult.success(goodsService.findCategoryWithChildren());
    }
 
    @ApiOperation("商品列表")
    @ApiResponses(
            @ApiResponse(code = 200, message = "success", response = XcxGoodsListVo.class)
    )
    @PostMapping(value = "/goods/goodsList")
    public JsonResult<PageInfo<XcxGoodsListVo>> goodsList(@RequestBody XcxGoodsListDto xcxGoodsListDto, HttpServletRequest request) {
        return JsonResult.success(goodsService.findGoodsListInPage(xcxGoodsListDto));
    }
 
    @ApiOperation("商品详情")
    @ApiResponses(
            @ApiResponse(code = 200, message = "success", response = XcxGoodsDetailVo.class)
    )
    @PostMapping(value = "/goods/goodsDetails/{id}")
    public JsonResult<XcxGoodsDetailVo> goodsDetails(@PathVariable("id") Long id) {
        return JsonResult.success(goodsService.findGoodsDetails(id));
    }
 
}