陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package com.mzl.flower.web.flower;
 
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.flower.*;
import com.mzl.flower.dto.request.flower.FlowerTagMultipleDTO;
import com.mzl.flower.dto.response.flower.*;
import com.mzl.flower.service.flower.FlowerParamService;
import com.mzl.flower.service.flower.FlowerService;
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.*;
 
import java.util.List;
 
@RestController
@RequestMapping("/api/flower")
@Api(value = "商品管理-运营端", tags = "商品管理-运营端")
@Validated
@Slf4j
public class FlowerController extends BaseController {
 
    @Autowired
    private FlowerService flowerService;
 
    @Autowired
    private FlowerParamService paramService;
 
    @GetMapping("/list")
    @ApiOperation(value = "商品列表")
    public ResponseEntity<ReturnDataDTO<Page<FlowerListDTO>>> selectFlowerList(Page page, FlowerQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), flowerService.selectFlowerList(page, dto));
    }
 
    @GetMapping("/list/view")
    @ApiOperation(value = "商品详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<FlowerDTO>> getFlowerDetail(Long id) {
        return returnData(R.SUCCESS.getCode(), flowerService.getFlowerDetail(id));
    }
 
    @PostMapping("/list/pass")
    @ApiOperation(value = "审核通过")
    public ResponseEntity<ReturnDataDTO> passFlower(@RequestBody FlowerAuditDTO dto) {
        flowerService.auditFlower(dto.getId(), dto.getAuditRemarks(), Constants.FLOWER_STATUS.UP.name());
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/reject")
    @ApiOperation(value = "审核驳回")
    public ResponseEntity<ReturnDataDTO> rejectFlower(@RequestBody FlowerAuditDTO dto) {
        flowerService.auditFlower(dto.getId(), dto.getAuditRemarks(), Constants.FLOWER_STATUS.REJECT.name());
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/pass/multi")
    @ApiOperation(value = "批量审核通过")
    public ResponseEntity<ReturnDataDTO> passFlowers(@RequestBody FlowerAuditMultipleDTO dto) {
        flowerService.auditFlowers(dto, Constants.FLOWER_STATUS.UP.name());
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/reject/multi")
    @ApiOperation(value = "批量审核驳回")
    public ResponseEntity<ReturnDataDTO> rejectFlowers(@RequestBody FlowerAuditMultipleDTO dto) {
        flowerService.auditFlowers(dto, Constants.FLOWER_STATUS.REJECT.name());
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/tags")
    @ApiOperation(value = "批量设置标签")
    public ResponseEntity<ReturnDataDTO> setFlowersTags(@RequestBody FlowerTagMultipleDTO dto) {
        flowerService.setFlowersTags(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/zones")
    @ApiOperation(value = "批量设置专区")
    public ResponseEntity<ReturnDataDTO> setFlowerZone(@RequestBody FlowerZoneBatchDTO dto) {
        flowerService.setFlowerZone(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/off")
    @ApiOperation(value = "批量强制下架")
    public ResponseEntity<ReturnDataDTO> setFlowersForceOff(@RequestBody FlowerOffDTO dto) {
        flowerService.setFlowersForceOff(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list/delete")
    @ApiOperation(value = "商品删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> deleteFlower(Long id) {
        flowerService.deleteFlower(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/params")
    @ApiOperation(value = "获取分类参数列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "categoryId", value = "商品分类id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<List<ParamItemDTO>>> getParamItemListByCategoryId(Long categoryId){
        return returnData(R.SUCCESS.getCode(), paramService.getParamItemListByCategoryId(categoryId));
    }
 
    @PostMapping("/list/edit")
    @ApiOperation(value = "编辑商品")
    public ResponseEntity<ReturnDataDTO> editFlowerAdmin(@RequestBody FlowerUpdateAdminDTO dto) {
        return returnData(R.SUCCESS.getCode(), flowerService.editFlowerAdmin(dto));
    }
 
    @PostMapping("/list/recommend/set")
    @ApiOperation(value = "批量设置推荐")
    public ResponseEntity<ReturnDataDTO> setFlowerRecommend(@RequestBody FlowerRecommendMultipleDTO dto) {
        flowerService.setFlowerRecommend(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/list/recommend/cancel")
    @ApiOperation(value = "批量取消推荐")
    public ResponseEntity<ReturnDataDTO> cancelFlowerRecommend(@RequestBody FlowerRecommendMultipleDTO dto) {
        flowerService.cancelFlowerRecommend(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
 
    @PostMapping("/list/recommend/set/rank")
    @ApiOperation(value = "设置推荐排序")
    public ResponseEntity<ReturnDataDTO> setFlowerRecommendRank(@RequestBody FlowerRecommendRankDTO dto) {
        flowerService.setFlowerRecommendRank(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
 
    @GetMapping("/list/shown")
    @ApiOperation(value = "显示商品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> showFlower(Long id){
        flowerService.setFlowerShown(id, true);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list/hidden")
    @ApiOperation(value = "隐藏商品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> hideFlower(Long id){
        flowerService.setFlowerShown(id, false);
        return returnData(R.SUCCESS.getCode(), null);
    }
}