liusuyi
2024-10-10 38f29e38fcc668171dc05c53d40a36b895c86102
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
package com.ruoyi.common.utils;
 
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.spring.SpringUtils;
 
import java.util.Map;
 
 
/**
 * @Description: 配置工具类
 * @ClassName: ConfigUtils
 * @Author: 刘苏义
 * @Date: 2023年08月23日16:12:09
 * @Version: 1.0
 **/
public class ConfigUtils {
    /**
     * 根据配置key获取配置value值
     *
     * @return configValue 配置value值
     */
    public static String getConfigValue(String key) {
        String configValue = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
        if (StringUtils.isNotNull(configValue)) {
            return configValue;
        }
        return null;
    }
 
    /**
     * 设置cache key
     *
     * @param configKey 参数键
     * @return 缓存键key
     */
    private static String getCacheKey(String configKey) {
        return CacheConstants.SYS_CONFIG_KEY + configKey;
    }
 
}