SpuController.java 1.6 KB
Newer Older
郝先瑞 已提交
1 2 3 4 5
package com.youlai.mall.pms.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youlai.common.result.Result;
import com.youlai.mall.pms.pojo.query.SpuPageQuery;
郝先瑞 已提交
6 7
import com.youlai.mall.pms.pojo.vo.GoodsPageVO;
import com.youlai.mall.pms.pojo.vo.GoodsDetailVO;
郝先瑞 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
import com.youlai.mall.pms.service.IPmsSpuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "「移动端」商品信息")
@RestController("appSpuController")
@RequestMapping("/app-api/v1/spu")
@RequiredArgsConstructor
public class SpuController {

    private final IPmsSpuService iPmsSpuService;

    @ApiOperation(value = "商品分页列表")
    @GetMapping("/page")
郝先瑞 已提交
30 31
    public Result<List<GoodsPageVO>> listGoodsWithPage(SpuPageQuery queryParams) {
        IPage<GoodsPageVO> result = iPmsSpuService.listAppSpuWithPage(queryParams);
郝先瑞 已提交
32 33 34 35 36
        return Result.success(result.getRecords(), result.getTotal());
    }

    @ApiOperation(value = "获取商品详情")
    @GetMapping("/{spuId}")
郝先瑞 已提交
37
    public Result<GoodsDetailVO> getGoodsDetail(
郝先瑞 已提交
38 39
            @ApiParam("商品ID") @PathVariable Long spuId
    ) {
郝先瑞 已提交
40 41
        GoodsDetailVO goodsDetailVO = iPmsSpuService.getAppSpuDetail(spuId);
        return Result.success(goodsDetailVO);
郝先瑞 已提交
42 43 44
    }

}