Browse Source
# Conflicts: # epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.javadev_shibei_match
8 changed files with 82 additions and 14 deletions
@ -0,0 +1,70 @@ |
|||
package com.epmet.commons.tools.enums; |
|||
|
|||
import com.epmet.commons.tools.utils.SpringContextUtils; |
|||
import org.springframework.core.env.Environment; |
|||
|
|||
/** |
|||
* 系统环境变量枚举类 |
|||
* dev|test|prod |
|||
* |
|||
* @author jianjun liu |
|||
* @date 2020-07-03 11:14 |
|||
**/ |
|||
public enum KongCunCustomerEnvEnum { |
|||
/** |
|||
* 环境变量枚举 |
|||
*/ |
|||
DEV("dev", "开发环境", "613cc61a6b8ce4c70d21bd413dac72cc"), |
|||
TEST("test", "体验环境", "b272625617e53620b2b3cbc65d1ecbbb"), |
|||
PROD("prod", "生产环境", "6f203e30de1a65aab7e69c058826cd80"), |
|||
UN_KNOWN("prod", "生产环境", "6f203e30de1a65aab7e69c058826cd80") |
|||
; |
|||
|
|||
private String code; |
|||
private String name; |
|||
private String customerId; |
|||
|
|||
|
|||
|
|||
KongCunCustomerEnvEnum(String code, String name, String customerId) { |
|||
this.code = code; |
|||
this.name = name; |
|||
this.customerId = customerId; |
|||
} |
|||
|
|||
public static KongCunCustomerEnvEnum getEnum(String code) { |
|||
KongCunCustomerEnvEnum[] values = KongCunCustomerEnvEnum.values(); |
|||
for (KongCunCustomerEnvEnum value : values) { |
|||
if (value.getCode().equals(code)) { |
|||
return value; |
|||
} |
|||
} |
|||
return KongCunCustomerEnvEnum.UN_KNOWN; |
|||
} |
|||
|
|||
public static KongCunCustomerEnvEnum getCurrentEnv(){ |
|||
try { |
|||
Environment environment = SpringContextUtils.getBean(Environment.class); |
|||
String[] activeProfiles = environment.getActiveProfiles(); |
|||
if (activeProfiles.length > 0) { |
|||
return getEnum(activeProfiles[0]); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return KongCunCustomerEnvEnum.UN_KNOWN; |
|||
} |
|||
|
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getName() { |
|||
return name; |
|||
} |
|||
|
|||
public String getCustomerId(){ |
|||
return customerId; |
|||
} |
|||
} |
Loading…
Reference in new issue