41 lines
1.0 KiB
Java
41 lines
1.0 KiB
Java
package com.example.caseData.utils;
|
|
|
|
import com.example.caseData.config.EnvConfig;
|
|
import com.example.caseData.config.JwtConfig;
|
|
import jakarta.annotation.PostConstruct;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
public class EnvUtil {
|
|
private static EnvConfig envConfig;
|
|
|
|
public EnvUtil(EnvConfig envConfig ){
|
|
EnvUtil.envConfig = envConfig;
|
|
}
|
|
|
|
// private static String activeProfile;
|
|
|
|
// @Value("${spring.profiles.active:default}")
|
|
// private String active;
|
|
//
|
|
// @PostConstruct
|
|
// public void init() {
|
|
// activeProfile = active;
|
|
// }
|
|
|
|
/**
|
|
* 判断是否为正式环境
|
|
*/
|
|
public static boolean isProd() {
|
|
return "prod".equalsIgnoreCase(envConfig.getActive());
|
|
}
|
|
|
|
/**
|
|
* 判断是否为测试环境
|
|
*/
|
|
public static boolean isDev() {
|
|
return "dev".equalsIgnoreCase(envConfig.getActive()) || "test".equalsIgnoreCase(envConfig.getActive());
|
|
}
|
|
} |