Pu Zhibing
2025-05-08 41600563b0ee8cfad746c359c4d3971169d1c931
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
package com.ruoyi.other.controller;
 
 
import com.alibaba.fastjson.JSON;
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.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.security.annotation.Logical;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.other.api.domain.TSystemConfiguration;
import com.ruoyi.other.service.TSystemConfigurationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-08-06
 */
@RestController
@RequestMapping("/t-system-configuration")
public class TSystemConfigurationController {
 
    private final TSystemConfigurationService systemConfigurationService;
 
    @Autowired
    public TSystemConfigurationController(TSystemConfigurationService systemConfigurationService) {
        this.systemConfigurationService = systemConfigurationService;
    }
 
    /**
     * 查看系统设置
     */
    @RequiresPermissions(value = {"/customerServiceInformation", "/systemContentSetting"}, logical = Logical.OR)
    @ApiOperation(tags = {"后台-内容设置"},value = "联系客服,查询设置")
    @GetMapping(value = "/getDetailById")
    public AjaxResult<TSystemConfiguration> getDetailById(@RequestParam("type")@ApiParam(value = "1=客服信息,2=系统设置") Integer type) {
        return AjaxResult.ok(systemConfigurationService.getOne(Wrappers.lambdaQuery(TSystemConfiguration.class)
                .eq(TSystemConfiguration::getType, type)));
    }
    
    
    /**
     * 查看系统设置
     */
    @ApiOperation(tags = {"小程序-系统设置"},value = "联系客服,查询设置")
    @GetMapping(value = "/getDetailById1")
    public AjaxResult<TSystemConfiguration> getDetailById1(@RequestParam("type")@ApiParam(value = "1=客服信息,2=系统设置") Integer type) {
        return AjaxResult.ok(systemConfigurationService.getOne(Wrappers.lambdaQuery(TSystemConfiguration.class)
                .eq(TSystemConfiguration::getType, type)));
    }
    
    
    
    @RequiresPermissions(value = {"/customerServiceInformation", "/systemContentSetting"}, logical = Logical.OR)
    @ApiOperation(tags = {"后台-内容设置"},value = "客户信息,系统内容设置")
    @PostMapping(value = "/save")
    @Log(title = "【系统内容设置】保存系统内容设置", businessType = BusinessType.INSERT)
    public AjaxResult getDetailById(@RequestBody TSystemConfiguration systemConfiguration) {
        systemConfigurationService.saveOrUpdate(systemConfiguration);
        return AjaxResult.success();
    }
    
    
    /**
     * 获取客服电话
     * @return
     */
    @PostMapping(value = "/getServerPhone")
    public R<String> getServerPhone(){
        TSystemConfiguration one = systemConfigurationService.getOne(new LambdaQueryWrapper<TSystemConfiguration>().eq(TSystemConfiguration::getType, 1));
        if(null != one){
            return R.ok(JSON.parseObject(one.getContent()).getString("phone"));
        }
        return R.ok();
    }
 
}