mitao
2025-03-10 9dbb6c26c81e94e8f969805b40b0e183bf306f83
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
package com.ruoyi.system.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.CustomConfig;
import com.ruoyi.system.api.domain.dto.MgtAfterSaleSettingDTO;
import com.ruoyi.system.domain.dto.PointsConfigDTO;
import com.ruoyi.system.domain.vo.CustomConfigVO;
import com.ruoyi.system.domain.vo.WishSettingVO;
import com.ruoyi.system.service.ICustomConfigService;
import io.swagger.annotations.*;
 
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * <p>
 * 系统配置 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-05-21
 */
@Validated
@RestController
@RequestMapping("/custom-config")
@Api(value = "系统配置接口", tags = "系统配置接口")
public class CustomConfigController {
    @Resource
    private ICustomConfigService iCustomConfigService;
    @GetMapping(value = "/{configId}")
    @ApiOperation("获取配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "configId", value = "配置键", required = true)})
    public R<CustomConfig> getconfig(@PathVariable String configId)
    {
        LambdaQueryWrapper<CustomConfig> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(CustomConfig::getConfigKey, configId);
        CustomConfig one = iCustomConfigService.getOne(wrapper);
        return R.ok(one);
    }
 
    /**
     * 获取积分设置
     *
     * @return List<CustomConfig>
     */
    @ApiOperation("获取积分设置")
    @GetMapping("/points")
    public R<PointsConfigDTO> getPointsConfig() {
        return R.ok(iCustomConfigService.getPointsConfig());
    }
    /**
     * 保存积分设置
     *
     * @param dto 积分配置数据传输对象
     */
    @ApiOperation(value = "保存积分设置")
    @PostMapping("/save-points")
    public R<?> savePointsSettings(@Validated @RequestBody PointsConfigDTO dto) {
        iCustomConfigService.savePointsSettings(dto);
        return R.ok();
    }
 
    /**
     * 获取订单说明设置
     *
     * @return CustomConfigVO
     */
    @ApiOperation("获取订单说明设置")
    @GetMapping("/order-desc")
    public R<CustomConfigVO> getOrderDesc() {
        return R.ok(iCustomConfigService.getOrderDesc());
    }
 
    /**
     * 订单说明设置
     *
     * @param description 订单说明
     */
    @ApiOperation(value = "订单说明设置")
    @PostMapping("/save-order-desc")
    public R<?> saveOrderDescription(
            @RequestParam(value = "description", required = true) String description) {
        iCustomConfigService.saveOrderDescription(description);
        return R.ok();
    }
 
    /**
     * 售后设置
     *
     * @param dto 售后设置对象
     */
    @ApiOperation(value = "售后设置")
    @PostMapping("/save-after-sale-setting")
    public R<?> saveAfterSaleSetting(@Validated @RequestBody MgtAfterSaleSettingDTO dto) {
        iCustomConfigService.saveAfterSaleSetting(dto);
        return R.ok();
    }
 
    /**
     * 获取售后设置
     *
     * @return List<CustomConfigVO>
     */
    @ApiOperation("获取售后设置")
    @GetMapping("/get-after-sale-setting")
    public R<MgtAfterSaleSettingDTO> getAfterSaleSetting() {
        return R.ok(iCustomConfigService.getAfterSaleSetting());
    }
 
    /**
     * 获取客服电话
     *
     * @return 客服电话
     */
    @ApiOperation("获取客服电话")
    @GetMapping("/service-phone")
    public R<String> servicePhone() {
        return R.ok(iCustomConfigService.getServicePhone());
    }
 
    /**
     * 保存客服电话
     *
     * @param phone 客服电话
     */
    @ApiOperation("保存客服电话")
    @PostMapping("/save-service-phone")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "客服电话", example = "18888888888", required = true)})
    public R<?> servicePhone(@RequestParam(value = "phone", required = true) String phone) {
        iCustomConfigService.updateServicePhone(phone);
        return R.ok();
    }
 
    /**
     * 删除客户电话
     *
     * @param phone 客服电话
     */
    @ApiOperation("删除客服电话")
    @PostMapping("/delete-service-phone")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "客服电话", example = "18888888888", required = true)})
    public R<?> deleteServicePhone(@RequestParam(value = "phone", required = true) String phone) {
        iCustomConfigService.deleteServicePhone(phone);
        return R.ok();
    }
 
    /**
     * 获取心愿求购说明
     *
     * @return
     */
    @ApiOperation("获取心愿求购说明、分享配置")
    @GetMapping("/wish-setting")
    public R<WishSettingVO> getWishSetting() {
        return R.ok(iCustomConfigService.getWishSetting());
    }
 
    /**
     * 保存心愿求购设置
     *
     * @param vo 保存心愿求购设置
     */
    @ApiOperation(value = "保存心愿设置")
    @PostMapping("/save-wish-setting")
    public R<?> saveWishDescription(@Valid @RequestBody WishSettingVO vo) {
        iCustomConfigService.saveWishDescription(vo);
        return R.ok();
    }
 
    /**
     * 保存保证金退还设置
     */
    @ApiOperation(value = "保存保证金退还设置")
    @PostMapping("/save-refund-of-deposit")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "refundOfDeposit", value = "保证金退还文案", required = true)})
    public R<?> saveRefundOfDeposit(
            @RequestParam(value = "refundOfDeposit") String refundOfDeposit) {
        iCustomConfigService.saveRefundOfDeposit(refundOfDeposit);
        return R.ok();
    }
}