gongzuming
2024-09-19 a768dc3daa04d35fedfbe75c0a59b9b2545b85c4
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
package com.mzl.flower.web.point;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.point.PointGoodsCreateDTO;
import com.mzl.flower.dto.request.point.PointGoodsQueryDTO;
import com.mzl.flower.dto.request.point.PointGoodsUpdateDTO;
import com.mzl.flower.dto.response.point.PointGoodsDTO;
import com.mzl.flower.dto.response.point.PointGoodsListDTO;
import com.mzl.flower.service.point.PointGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping("/api/point/goods")
@Api(value = "积分商品管理-运营端", tags = "积分商品管理-运营端")
@Validated
@Slf4j
public class PointGoodsController extends BaseController {
 
    @Autowired
    private PointGoodsService pointGoodsService;
 
    @PostMapping("/list/new")
    @ApiOperation(value = "新增商品")
    public ResponseEntity<ReturnDataDTO> addPointGoods(@RequestBody PointGoodsCreateDTO dto) {
        return returnData(R.SUCCESS.getCode(), pointGoodsService.addPointGoods(dto));
    }
 
    @PostMapping("/list/edit")
    @ApiOperation(value = "编辑商品")
    public ResponseEntity<ReturnDataDTO> updatePointGoods(@RequestBody PointGoodsUpdateDTO dto) {
        return returnData(R.SUCCESS.getCode(), pointGoodsService.updatePointGoods(dto));
    }
 
    @GetMapping("/list")
    @ApiOperation(value = "商品列表")
    public ResponseEntity<ReturnDataDTO<Page<PointGoodsListDTO>>> selectGoodsList(Page page, PointGoodsQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), pointGoodsService.selectGoodsList(page, dto));
    }
 
    @GetMapping("/list/view")
    @ApiOperation(value = "商品详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<PointGoodsDTO>> getGoodsInfo(Long id) {
        return returnData(R.SUCCESS.getCode(), pointGoodsService.getGoodsInfo(id));
    }
 
    @GetMapping("/list/delete")
    @ApiOperation(value = "商品删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> deletePointGoods(String id) {
        pointGoodsService.deletePointGoods(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list/on")
    @ApiOperation(value = "商品上架")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> upGoods(String id) {
        pointGoodsService.updateStatus(id, Constants.POINT_GOODS_STATUS.A.name());
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list/off")
    @ApiOperation(value = "商品下架")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> offGoods(String id) {
        pointGoodsService.updateStatus(id, Constants.POINT_GOODS_STATUS.I.name());
        return returnData(R.SUCCESS.getCode(), null);
    }
}