liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
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
package com.xiaopeng.common.core.utils;
 
 
import com.xiaopeng.common.core.constant.TokenConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
 
@Component
public class ConfigUtils {
 
    @Value("${token.secret:${spring.token.secret:}}")
    private String secret;
 
 
    private static ConfigUtils instance;
 
    @PostConstruct
    public void init() {
        instance = this;
        TokenConstants.setSecret(secret);
    }
 
    public static String getTokenSecret() {
        if (instance == null) {
            return TokenConstants.getSecret();
        }
        return instance.secret;
    }
 
    public static void setTokenSecret(String value) {
        if (instance != null) {
            instance.secret = value;
        }
        TokenConstants.setSecret(value);
    }
}