Cui Zhi Feng
2024-08-29 50898a908596dac25cbe8f4d0c402d54290ed81d
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.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.dto.BatchDTO;
import com.mzl.flower.dto.request.point.PointGoodDTO;
import com.mzl.flower.dto.request.point.PointGoodQueryDTO;
import com.mzl.flower.dto.response.point.PointGoodVO;
import com.mzl.flower.service.point.PointGoodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.constraints.NotNull;
 
@RestController
@RequestMapping("/api/point")
@Api(value = "积分商品管理", tags = "积分商品管理")
@Validated
@Slf4j
@RequiredArgsConstructor
public class PointGoodController extends BaseController {
 
 
    private final PointGoodService pointGoodService;
 
 
 
    @PostMapping("/good/save")
    @ApiOperation(value = "新增", notes = "新增")
    public ResponseEntity<ReturnDataDTO> save(@Validated @RequestBody PointGoodDTO pointGoodDTO) {
        pointGoodService.save(pointGoodDTO);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @PostMapping("/good/update")
    @ApiOperation(value = "修改", notes = "修改")
    public ResponseEntity<ReturnDataDTO> update(@Validated @RequestBody PointGoodDTO pointGoodDTO) {
        pointGoodService.update(pointGoodDTO);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @PostMapping("/good/delete/batch")
    @ApiOperation(value = "批量删除", notes = "批量删除")
    public ResponseEntity<ReturnDataDTO> batchDelete(@Validated @RequestBody BatchDTO dto) {
        pointGoodService.batchDelete(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @PostMapping("/good/publish/batch")
    @ApiOperation(value = "批量上架", notes = "批量上架")
    public ResponseEntity<ReturnDataDTO> batchPublish(@Validated @RequestBody BatchDTO dto) {
        pointGoodService.batchPublish(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @PostMapping("/good/off/batch")
    @ApiOperation(value = "批量下架", notes = "批量下架")
    public ResponseEntity<ReturnDataDTO> batchoff(@Validated @RequestBody BatchDTO dto) {
        pointGoodService.batchOff(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
 
    @GetMapping("/good/delete")
    @ApiOperation(value = "删除", notes = "删除")
    public ResponseEntity<ReturnDataDTO> delete(@NotNull(message = "id不能为空") Long id) {
        pointGoodService.delete(id);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
 
    @GetMapping("/good/copy")
    @ApiOperation(value = "复制", notes = "复制")
    public ResponseEntity<ReturnDataDTO> copy(@NotNull(message = "id不能为空") Long id) {
        pointGoodService.delete(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/good/view")
    @ApiOperation(value = "详情", notes = "详情")
    public ResponseEntity<ReturnDataDTO<PointGoodVO>> detail(@NotNull(message = "id不能为空") Long id) {
        return returnData(R.SUCCESS.getCode(),pointGoodService.detail(id));
    }
 
    @GetMapping("/good/page")
    @ApiOperation(value = "查询-分页", notes = "查询-分页")
    public ResponseEntity<ReturnDataDTO<Page<PointGoodVO>>> queryPage(PointGoodQueryDTO dto, Page page) {
        return returnData(R.SUCCESS.getCode(), pointGoodService.queryPage(dto,page));
    }
 
    @GetMapping("/good/changeStatus")
    @ApiOperation(value = "修改上架下架状态", notes = "修改上架下架状态")
    public ResponseEntity<ReturnDataDTO> changeStatus(@NotNull(message = "id不能为空") Long id) {
        pointGoodService.changeStatus(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
}