jinglun-cloud
18 小时以前 1ef1063281497f32fcfa4f14b07d99399c0bb765
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
package com.zy.core.network.fake;
 
import com.zy.system.service.ConfigService;
import com.core.common.SpringUtils;
 
public final class FakeConfigSupport {
 
    private FakeConfigSupport() {
    }
 
    public static String getString(String code) {
        return getString(code, FakeConfigKeys.DEFAULTS.get(code));
    }
 
    public static String getString(String code, String defaultValue) {
        ConfigService configService = SpringUtils.getBean(ConfigService.class);
        if (configService == null) {
            return defaultValue;
        }
        return configService.getConfigValue(code, defaultValue);
    }
 
    public static long getLong(String code) {
        String defaultValue = FakeConfigKeys.DEFAULTS.get(code);
        long fallback = 0L;
        if (defaultValue != null) {
            try {
                fallback = Long.parseLong(defaultValue);
            } catch (Exception ignore) {
            }
        }
        return getLong(code, fallback);
    }
 
    public static long getLong(String code, long defaultValue) {
        ConfigService configService = SpringUtils.getBean(ConfigService.class);
        if (configService == null) {
            return defaultValue;
        }
        return configService.getConfigLongValue(code, defaultValue);
    }
}