package com.cyksj.common; import lombok.Getter; import lombok.Setter; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; /* *项目名: netflix *文件名: EnvCommon *创建者: JavaZou *创建时间:2022/10/26 17:10 */ @Component @Getter @Setter public class EnvCommonService { public static final String active = "dev"; public static final String active_prd = "prd"; public static String DISTRIBUTE_DEFAULT_URL_PREFIX; public static String DISTRIBUTE_DESIGN_URL_PREFIX; @Value(value = "${spring.profiles.active}") private String env; @Value(value = "${wechat.domain}") private String domain; public String getHost() { return domain; } public String getDomain() { return this.getHost().substring(0, this.getHost().indexOf("8081")); } public String getDomain2() { return this.getHost().substring(0, this.getHost().indexOf("/8081")); } public Boolean isPrdEnv() { return EnvCommonService.active_prd.equals(getEnv()); } @PostConstruct public void getDistributeUrl() { DISTRIBUTE_DEFAULT_URL_PREFIX = getDomain(); if (!DISTRIBUTE_DEFAULT_URL_PREFIX.endsWith("/")) { DISTRIBUTE_DEFAULT_URL_PREFIX += "/"; } if (!isPrdEnv()) { DISTRIBUTE_DEFAULT_URL_PREFIX += "yinhe/web"; } DISTRIBUTE_DEFAULT_URL_PREFIX += "?sharedId=%s"; DISTRIBUTE_DESIGN_URL_PREFIX = DISTRIBUTE_DEFAULT_URL_PREFIX.replace("sharedId", "dsCode"); } }