cloudroam
2024-12-10 9b774a0d10e522323a51053ae9b79e02af3accae
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
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.base.annotation.OperationLog;
import com.mzl.flower.dto.request.flower.*;
import com.mzl.flower.dto.response.flower.FlowerParamDTO;
import com.mzl.flower.dto.response.flower.FlowerParamItemDTO;
import com.mzl.flower.dto.response.flower.FlowerParamListDTO;
import com.mzl.flower.entity.flower.FlowerParam;
import com.mzl.flower.entity.flower.FlowerParamItem;
import com.mzl.flower.entity.log.OperationRecord;
import com.mzl.flower.service.flower.FlowerParamService;
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/param")
@Api(value = "商品参数管理", tags = "商品参数管理")
@Validated
@Slf4j
public class FlowerParamController extends BaseController {
 
    @Autowired
    private FlowerParamService paramService;
 
    @PostMapping("/list/new")
    @ApiOperation(value = "新增商品参数集")
    public ResponseEntity<ReturnDataDTO> addParam(@RequestBody FlowerParamCreateDTO dto) {
        return returnData(R.SUCCESS.getCode(), paramService.addParam(dto));
    }
 
    @PostMapping("/list/edit")
    @OperationLog(value = "编辑商品参数集", type = "flower_param")
    @ApiOperation(value = "编辑商品参数集")
    public ResponseEntity<ReturnDataDTO> updateParam(@RequestBody FlowerParamUpdateDTO dto) {
        String content = "";
        content = "编辑商品参数集id:【" + dto.getId() + "】参数模板名称:【" + dto.getName() + "】,排序:【" + dto.getSortBy() + "】";
        OperationRecord operationRecord = getOperationRecord(content);
        return returnData(R.SUCCESS.getCode(), paramService.updateParam(dto), operationRecord);
 
    }
 
    @GetMapping("/list/view")
    @ApiOperation(value = "查询商品参数详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品参数集id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<FlowerParamDTO>> getParam(Long id){
        return returnData(R.SUCCESS.getCode(), paramService.getParam(id));
    }
    
    @GetMapping("/list")
    @ApiOperation(value = "获取商品参数列表")
    public ResponseEntity<ReturnDataDTO<Page<FlowerParamListDTO>>> selectParamList(Page page, FlowerParamQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), paramService.selectParamList(page, dto));
    }
 
    @GetMapping("/list/delete")
    @OperationLog(value = "删除商品参数集", type = "flower_param")
    @ApiOperation(value = "删除商品参数集")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品参数集id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> deleteParam(Long id){
        FlowerParam flowerParam = paramService.selectFlowerParamById(id);
        paramService.deleteParam(id);
        String content = "删除商品参数集:参数id:【" + id + "】,参数模板名称【" + flowerParam.getName() + "】,排序:【" + flowerParam.getSortBy() + "】";
        OperationRecord operationRecord = getOperationRecord(content);
        return returnData(R.SUCCESS.getCode(), null, operationRecord);
    }
 
    @GetMapping("/list/items")
    @ApiOperation(value = "获取参数集参数列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品参数集id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<List<FlowerParamItemDTO>>> getParamItems(Long id){
        return returnData(R.SUCCESS.getCode(), paramService.getParamItems(id));
    }
 
    @GetMapping("/list/items/view")
    @ApiOperation(value = "获取参数详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "参数id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<FlowerParamItemDTO>> getParamItem(Long id){
        return returnData(R.SUCCESS.getCode(), paramService.getParamItem(id));
    }
 
    @GetMapping("/list/items/delete")
    @OperationLog(value = "删除参数", type = "flower_param")
    @ApiOperation(value = "删除参数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "参数id", required = true, dataType = "Long", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> deleteParamItem(Long id) {
        FlowerParamItem flowerParamItem = paramService.selectFlowerParamItemById(id);
        paramService.deleteParamItem(id);
        String content = "删除参数:参数id:【" + flowerParamItem.getParamId() + "】,参数名称【" + flowerParamItem.getName() + "】,参数值:【" + flowerParamItem.getContent() + "】,排序:【" + flowerParamItem.getSortBy() + "】";
        OperationRecord operationRecord = getOperationRecord(content);
        return returnData(R.SUCCESS.getCode(), null, operationRecord);
    }
 
    @PostMapping("/list/items/new")
    @OperationLog(value = "新增参数", type = "flower_param")
    @ApiOperation(value = "新增参数")
    public ResponseEntity<ReturnDataDTO> addParamItem(@RequestBody FlowerParamItemCreateDTO dto) {
        String content = "新增参数:参数id:【" + dto.getParamId() + "】,参数名称【" + dto.getName() + "】,参数值:【" + dto.getContent() + "】,排序:【" + dto.getSortBy() + "】";
        OperationRecord operationRecord = getOperationRecord(content);
        return returnData(R.SUCCESS.getCode(),  paramService.addParamItem(dto), operationRecord);
    }
 
    @PostMapping("/list/items/edit")
    @OperationLog(value = "编辑参数", type = "flower_param")
    @ApiOperation(value = "编辑参数")
    public ResponseEntity<ReturnDataDTO> updateParamItem(@RequestBody FlowerParamItemUpdateDTO dto) {
        String content = "编辑参数:参数id:【" + dto.getParamId() + "】,参数名称【" + dto.getName() + "】,参数值:【" + dto.getContent() + "】,排序:【" + dto.getSortBy() + "】";
        OperationRecord operationRecord = getOperationRecord(content);
        return returnData(R.SUCCESS.getCode(),  paramService.updateParamItem(dto), operationRecord);
    }
}