jiangqs
2023-06-13 d6e5d5a71112fb1f0a7361485e80692cc03bc4c3
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.ruoyi.goods.controller.management;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.goods.domain.dto.*;
import com.ruoyi.goods.domain.vo.MgtGoodsPageVo;
import com.ruoyi.goods.domain.vo.MgtGoodsTotalVo;
import com.ruoyi.goods.service.goods.GoodsService;
import com.ruoyi.system.api.domain.dto.MgtBaseDto;
import com.ruoyi.system.api.domain.dto.MgtBaseGetDto;
import com.ruoyi.system.api.domain.vo.MgtSelectGoodsPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @author jqs34
 * @ClassName MgtGoodsController
 * @description: TODO
 * @date 2023年06月01日
 * @version: 1.0
 */
@Api(value = "平台端商品相关接口", tags = "平台端商品相关接口", description = "平台端商品相关接口")
@RestController
@RequestMapping("/mgt/goods")
public class MgtGoodsController {
 
    @Resource
    private GoodsService goodsService;
 
    @RequestMapping(value = "/pageMgtGoods", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取商品列表")
    public R<Page<MgtGoodsPageVo>> pageMgtGoods(@RequestBody MgtGoodsPageDto mgtGoodsPageDto) {
        Page<MgtGoodsPageVo> page = new Page<>();
        page.setSize(mgtGoodsPageDto.getPageSize());
        page.setCurrent(mgtGoodsPageDto.getPageNum());
        page.setOptimizeCountSql(false);
        List<MgtGoodsPageVo> mgtGoodsPageVoList = goodsService.pageMgtGoods(page,mgtGoodsPageDto);
        return R.ok(page.setRecords(mgtGoodsPageVoList));
    }
 
    @RequestMapping(value = "/getMgtGoodsTotal", method = RequestMethod.POST)
    @ApiOperation(value = "获取商品统计")
    public R<MgtGoodsTotalVo> getMgtGoodsTotal(@RequestBody MgtBaseDto mgtBaseDto) {
        Long userId = SecurityUtils.getUserId();
        mgtBaseDto.setUserId(userId);
        MgtGoodsTotalVo mgtGoodsTotalVo = goodsService.getMgtGoodsTotal();
        return R.ok(mgtGoodsTotalVo);
    }
 
    @RequestMapping(value = "/editMgtGoods", method = RequestMethod.POST)
    @ApiOperation(value = "平台编辑商品")
    public R editMgtGoods(@RequestBody MgtGoodsEditDto mgtGoodsEditDto) {
        Long userId = SecurityUtils.getUserId();
        mgtGoodsEditDto.setUserId(userId);
        goodsService.editMgtGoods(mgtGoodsEditDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/upDownMgtGoods", method = RequestMethod.POST)
    @ApiOperation(value = "平台上下架商品")
    public R upDownMgtGoods(@RequestBody MgtGoodsUpDownDto mgtGoodsUpDownDto) {
        Long userId = SecurityUtils.getUserId();
        mgtGoodsUpDownDto.setUserId(userId);
        goodsService.upDownMgtGoods(mgtGoodsUpDownDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/recommendMgtGoods", method = RequestMethod.POST)
    @ApiOperation(value = "平台推荐商品")
    public R recommendMgtGoods(@RequestBody MgtGoodsRecommendDto mgtGoodsRecommendDto) {
        Long userId = SecurityUtils.getUserId();
        mgtGoodsRecommendDto.setUserId(userId);
        goodsService.recommendMgtGoods(mgtGoodsRecommendDto);
        return R.ok();
    }
 
    @RequestMapping(value = "/deleteMgtGoods", method = RequestMethod.POST)
    @ApiOperation(value = "平台推荐商品")
    public R deleteMgtGoods(@RequestBody MgtBaseGetDto mgtBaseGetDto) {
        Long userId = SecurityUtils.getUserId();
        mgtBaseGetDto.setUserId(userId);
        goodsService.deleteMgtGoods(mgtBaseGetDto.getId(),userId);
        return R.ok();
    }
 
    @RequestMapping(value = "/pageMgtSelectGoods", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取商品选择列表")
    public R<Page<MgtSelectGoodsPageVo>> pageMgtSelectGoods(@RequestBody MgtSelectGoodsPageDto mgtSelectGoodsPageDto) {
        Page<MgtSelectGoodsPageVo> page = new Page<>();
        page.setSize(mgtSelectGoodsPageDto.getPageSize());
        page.setCurrent(mgtSelectGoodsPageDto.getPageNum());
        page.setOptimizeCountSql(false);
        List<MgtSelectGoodsPageVo> mgtSelectGoodsPageVos = goodsService.pageMgtSelectGoods(page,mgtSelectGoodsPageDto);
        return R.ok(page.setRecords(mgtSelectGoodsPageVos));
    }
}