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);
|
}
|
}
|