陶杰
2025-01-07 23ae87b2b99947e89cfa5fde81937870279e3180
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
package com.mzl.flower.web.v2.configParam;
 
 
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.request.configParam.ConfigParamDTO;
import com.mzl.flower.dto.request.configParam.QueryConfigParamDTO;
import com.mzl.flower.dto.request.configParam.UpdateConfigParamDTO;
import com.mzl.flower.dto.response.configParam.ConfigParamVO;
import com.mzl.flower.entity.configParam.ConfigParamGroupDO;
import com.mzl.flower.service.ConfigParamGroupService;
import com.mzl.flower.service.ConfigParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.util.Map;
 
/**
* @author @TaoJie
* @since 2024-12-02
*/
@RestController
@RequestMapping("/v2/config-param")
@Api(value = "系统配置-分组-参数值", tags = "系统配置-分组-参数值")
public class ConfigParamController extends BaseController {
 
    @Autowired
    private ConfigParamService configParamService;
 
    @Autowired
    private ConfigParamGroupService configParamGroupService;
 
    @PostMapping("/new")
    @ApiOperation(value = "新增", notes = "新增")
    public ResponseEntity<ReturnDataDTO> create(@Validated @RequestBody ConfigParamDTO dto) {
        ConfigParamGroupDO configParamGroupDO = configParamGroupService.getById(dto.getParamGroupId());
        dto.setParamGroup(configParamGroupDO.getParamGroup());
        dto.setParamGroupName(configParamGroupDO.getParamGroupName());
        configParamService.saveConfigParam(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping("/edit")
    @ApiOperation(value = "修改", notes = "修改")
    public ResponseEntity<ReturnDataDTO> update(@Validated @RequestBody ConfigParamDTO dto) {
        ConfigParamGroupDO configParamGroupDO = configParamGroupService.getById(dto.getParamGroupId());
        dto.setParamGroup(configParamGroupDO.getParamGroup());
        dto.setParamGroupName(configParamGroupDO.getParamGroupName());
        configParamService.updateConfigParam(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping(value = "/delete")
    @ApiOperation(value = "删除系统配置配置 ", httpMethod = "GET", notes = "ID")
    public ResponseEntity<ReturnDataDTO> delete(@NotNull(message = "id不能为空") Long id) {
        configParamService.deleteConfigParam(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/config/list")
    @ApiOperation(value = "配置查询-列表", notes = "配置查询-列表")
    public ResponseEntity<ReturnDataDTO<Page<ConfigParamVO>>> configlist(Page page, QueryConfigParamDTO dto) {
        return returnData(R.SUCCESS.getCode(), configParamService.queryPage(dto, page));
    }
 
    @GetMapping("/list")
    @ApiOperation(value = "查询-列表", notes = "查询-列表")
    public ResponseEntity<ReturnDataDTO<Page<ConfigParamVO>>> list(QueryConfigParamDTO dto) {
        return returnData(R.SUCCESS.getCode(), configParamService.getList(dto));
    }
 
    @PutMapping("/update/batch")
    @ApiOperation(value = "批量修改", notes = "批量修改")
    public ResponseEntity<ReturnDataDTO> updateBath(@Validated @RequestBody UpdateConfigParamDTO dto) {
        configParamService.updateConfigParamBatch(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/{id}")
    @ApiOperation(value = "详情", notes = "详情")
    public ResponseEntity<ReturnDataDTO> get(@PathVariable(value = "id") @Positive(message = "{id.positive}") Integer id) {
        return returnData(R.SUCCESS.getCode(), null);
    }
 
 
    @GetMapping("/page")
    @ApiOperation(value = "查询-分页", notes = "查询-分页")
    public ResponseEntity<ReturnDataDTO<Page<ConfigParamVO>>> page(Page page, QueryConfigParamDTO dto) {
        // 设置只查询活动优惠券的
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/base/info")
    @ApiOperation(value = "查询-备案信息", notes = "查询-备案信息" )
    public ResponseEntity<ReturnDataDTO<Map<String,Object>>> getBaseInfo() {
        // 设置只查询活动优惠券的
        return returnData(R.SUCCESS.getCode(), configParamService.getBaseInfo());
    }
 
    @GetMapping(value = "/base/getBaseString")
    @ApiOperation(value = "获取配置信息 ", httpMethod = "GET", notes = "ID")
    public ResponseEntity getBaseString(@NotNull(message = "paramGroup") String paramGroup, @NotNull(message = "paramKey") String paramKey) {
        return returnData(R.SUCCESS.getCode(), configParamService.getBaseString(paramGroup, paramKey));
    }
 
 
}