jiangqs
2023-06-06 92da9546e1b37b06f78671b34389b1dec9dfadfc
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
package com.ruoyi.system.service.impl.config;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.api.constant.ConfigEnum;
import com.ruoyi.system.domain.dto.MgtServiceMobileEditDto;
import com.ruoyi.system.domain.pojo.config.CustomConfig;
import com.ruoyi.system.mapper.config.CustomConfigMapper;
import com.ruoyi.system.service.config.CustomConfigService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
 
/**
 * <p>
 * 系统配置 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-04-25
 */
@Service
public class CustomConfigServiceImpl extends ServiceImpl<CustomConfigMapper, CustomConfig> implements CustomConfigService {
 
    @Resource
    private CustomConfigMapper customConfigMapper;
 
    /**
     * @description  通过key获取系统自定义配置
     * @author  jqs
     * @date    2023/6/6 11:55
     * @param key
     * @return  CustomConfig
     */
    @Override
    public CustomConfig getByKey(String key){
        return customConfigMapper.getByKey(key);
    }
 
 
    /**
     * @description  修改客服号码
     * @author  jqs
     * @date    2023/6/6 11:53
     * @param mgtServiceMobileEditDto
     * @return  void
     */
    @Override
    public void editServiceMobile(MgtServiceMobileEditDto mgtServiceMobileEditDto) {
        // 获取平台服务电话的配置
        CustomConfig customConfig = getByKey(ConfigEnum.PLATFORM_SERVICE_PHONE.getKey());
        // 如果配置不存在,则创建一个新的配置
        if (customConfig == null) {
            customConfig = new CustomConfig();
            customConfig.setCreateTime(new Date());
        }
        // 设置配置的类型、键、名称、值和更新时间
        customConfig.setType(ConfigEnum.PLATFORM_SERVICE_PHONE.getKeyType());
        customConfig.setKey(ConfigEnum.PLATFORM_SERVICE_PHONE.getKey());
        customConfig.setName(ConfigEnum.PLATFORM_SERVICE_PHONE.getKeyName());
        customConfig.setValue(mgtServiceMobileEditDto.getServiceMobile());
        customConfig.setUpdateTime(new Date());
        // 保存或更新配置
        this.saveOrUpdate(customConfig);
    }
}