wisdomisite-java/src/main/java/com/zhgd/xmgl/util/EnvironmentUtil.java
2024-06-15 14:25:52 +08:00

147 lines
2.9 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.zhgd.xmgl.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.stream.Stream;
/**
* 环境判断
*/
@Component
@Slf4j
public class EnvironmentUtil {
/**
* 激活的环境
*/
private static String activeEnvironment;
public static String getActiveEnvironment() {
return activeEnvironment;
}
@Value("${active.environment.name}")
public void setActiveEnvironment(String activeEnvironment) {
EnvironmentUtil.activeEnvironment = activeEnvironment;
}
/**
* 是否本地开发环境
*
* @return
*/
public boolean isDev() {
return "dev".equals(activeEnvironment);
}
/**
* 是否jlw生产环境
*
* @return
*/
public boolean isJlwProd() {
return "ljw-prod".equals(activeEnvironment);
}
/**
* 是否jlw环境
*
* @return
*/
public boolean isJlw() {
return Stream.of("ljw-prod", "ljw-dev").anyMatch(s -> s.equals(activeEnvironment));
}
/**
* 是否sj本地环境
*
* @return
*/
public boolean isSjjtGsxDev() {
return "sjjt-dev".equals(activeEnvironment);
}
/**
* 是否sj环境包括本地、测试、生产
*
* @return
*/
public boolean isSjjt() {
return Stream.of("sjjt-dev", "sjjt-prod").anyMatch(s -> s.equals(activeEnvironment));
}
/**
* 是否zjsj生产环境
*
* @return
*/
public boolean isZjsjProd() {
return "zjsj-prod".equals(activeEnvironment);
}
/**
* 是否zjsj环境
*
* @return
*/
public boolean isZjsj() {
return Stream.of("zjsj-dev", "zjsj-prod").anyMatch(s -> s.equals(activeEnvironment));
}
/**
* 是否zjsj沙湖环境
*
* @return
*/
public boolean isShahu() {
return Stream.of("shahu-dev", "shahu-prod").anyMatch(s -> s.equals(activeEnvironment));
}
/**
* 是否ylww生产环境
*
* @return
*/
public boolean isYlwwProd() {
return "ylww-prod".equals(activeEnvironment);
}
/**
* 是否gxlt生产环境
*
* @return
*/
public boolean isGxltProd() {
return "gxlt-prod".equals(activeEnvironment);
}
/**
* 是否gxlt环境
*
* @return
*/
public boolean isGxlt() {
return Stream.of("gxlt-prod", "gxlt-dev").anyMatch(s -> s.equals(activeEnvironment));
}
/**
* 是否baise环境
*
* @return
*/
public boolean isBaise() {
return Stream.of("baise").anyMatch(s -> s.equals(activeEnvironment));
}
/**
* 是否星纵环境
*
* @return
*/
public static boolean isXingZong() {
return Stream.of("xingzong", "xingzong-test").anyMatch(s -> s.equals(activeEnvironment));
}
}