Browse Source

fix:新增环境变量随系统变量一起更新的问题

dist.1.3.0
pref_mail@163.com 9 months ago
parent
commit
e35d9540f7
  1. 2
      blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
  2. 4
      blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/aspect/AsyncAnnotationAspect.java
  3. 4
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/AsyncAnnotationAspect.java
  4. 4
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/aspect/AnnotationAspect.java
  5. 4
      blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/AsyncAnnotationAspect.java
  6. 21
      blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java
  7. 5
      blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java
  8. 4
      blade-service/logpm-patch/src/main/java/com/logpm/patch/aspect/AsyncAnnotationAspect.java

2
blade-biz-common/src/main/java/org/springblade/common/constant/LauncherConstant.java

@ -237,7 +237,7 @@ public interface LauncherConstant {
static String loginAddr(String profile) {
switch (profile) {
case (AppConstant.PROD_CODE):
case (AppConstant.DEV_CODE):
return APPLICATION_DEV_LOGIN_ADDR;
case (AppConstant.TEST_CODE):
return APPLICATION_TEST_LOGIN_ADDR;

4
blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/aspect/AsyncAnnotationAspect.java

@ -16,6 +16,7 @@ import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.scheduling.annotation.Async;
@ -33,6 +34,7 @@ import java.util.Objects;
@AllArgsConstructor
public class AsyncAnnotationAspect {
private final BladeRedis bladeRedis;
private final Environment environment;
/**
* 定义一个切点匹配所有带有@Async("asyncExecutor")注解的方法
* 注意实际上Spring Framework自带对@Async("asyncExecutor")的处理直接这样配置可能会导致预期之外的行为
@ -96,7 +98,7 @@ public class AsyncAnnotationAspect {
String account ="shujutongbu";
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account);
if(Objects.isNull(data)){
String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token";
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token";
HttpRequest urlRequest = HttpRequest.post(url);
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
urlRequest.header("Tenant-Id", "627683");

4
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/aspect/AsyncAnnotationAspect.java

@ -16,6 +16,7 @@ import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.scheduling.annotation.Async;
@ -33,6 +34,7 @@ import java.util.Objects;
@AllArgsConstructor
public class AsyncAnnotationAspect {
private final BladeRedis bladeRedis;
private final Environment environment;
/**
* 定义一个切点匹配所有带有@Async("asyncExecutor")注解的方法
* 注意实际上Spring Framework自带对@Async("asyncExecutor")的处理直接这样配置可能会导致预期之外的行为
@ -94,7 +96,7 @@ public class AsyncAnnotationAspect {
String account ="shujutongbu";
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account);
if(Objects.isNull(data)){
String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token";
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token";
HttpRequest urlRequest = HttpRequest.post(url);
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
urlRequest.header("Tenant-Id", "627683");

4
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/aspect/AnnotationAspect.java

@ -14,6 +14,7 @@ import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.stereotype.Component;
@ -29,6 +30,7 @@ import java.util.Objects;
@AllArgsConstructor
public class AnnotationAspect {
private final BladeRedis bladeRedis;
private final Environment environment;
/**
* 该方法为一个切面用于对标记了@RabbitListener注解的方法进行增强主要增加了日志记录和数据源上下文处理的功能
*
@ -90,7 +92,7 @@ public class AnnotationAspect {
String account ="shujutongbu";
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account);
if(Objects.isNull(data)){
String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token";
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token";
HttpRequest urlRequest = HttpRequest.post(url);
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
urlRequest.header("Tenant-Id", "627683");

4
blade-service/logpm-factory/src/main/java/com/logpm/factory/aspect/AsyncAnnotationAspect.java

@ -23,6 +23,7 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.scheduling.annotation.Async;
@ -41,6 +42,7 @@ import java.util.Objects;
@AllArgsConstructor
public class AsyncAnnotationAspect {
private final BladeRedis bladeRedis;
private final Environment environment;
/**
* 该方法为一个切面用于对标记了@RabbitListener注解的方法进行增强主要增加了日志记录和数据源上下文处理的功能
*
@ -105,7 +107,7 @@ public class AsyncAnnotationAspect {
String account ="shujutongbu";
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account);
if(Objects.isNull(data)){
String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token";
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token";
cn.hutool.http.HttpRequest urlRequest = HttpRequest.post(url);
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
urlRequest.header("Tenant-Id", "627683");

21
blade-service/logpm-factory/src/main/java/com/logpm/factory/config/InterceptorAdapterConfig.java

@ -5,21 +5,24 @@ import com.logpm.factory.interceptor.FactoryAccountsInterceptor;
import com.logpm.factory.interceptor.LocalServerLoginAccountsInterceptor;
import com.logpm.factory.interceptor.ZbFactoryAccountsInterceptor;
import com.logpm.factory.props.ZbFactoryProperties;
import lombok.AllArgsConstructor;
import org.springblade.core.redis.cache.BladeRedis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@AllArgsConstructor
public class InterceptorAdapterConfig implements WebMvcConfigurer {
@Autowired
IFactoryTokenService factoryTokenService;
private final IFactoryTokenService factoryTokenService;
@Autowired
private BladeRedis redis;
private final BladeRedis redis;
private final Environment environment;
@Override
@ -30,13 +33,7 @@ public class InterceptorAdapterConfig implements WebMvcConfigurer {
excludePathPatterns("/factory/oupai/**").
excludePathPatterns("/factory/zb/**")
.excludePathPatterns("/factory/common/**");
registry=interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis));
// registry.addPathPatterns("/factory/**").
// excludePathPatterns("/factory/auth/token").
// excludePathPatterns("/factory/oupai/**").
// excludePathPatterns("/factory/zb/**")
// .excludePathPatterns("/factory/common/**");
// InterceptorRegistration registryZbFactory = interceptorRegistry.addInterceptor(new ZbFactoryAccountsInterceptor(zbFactoryProperties));
// registryZbFactory.addPathPatterns("/factory/zb/**");
registry=interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis,environment));
}
}

5
blade-service/logpm-factory/src/main/java/com/logpm/factory/interceptor/LocalServerLoginAccountsInterceptor.java

@ -19,6 +19,7 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -39,7 +40,7 @@ import java.util.Objects;
public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapter {
private final BladeRedis bladeRedis;
private final Environment environment;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException {
@ -49,7 +50,7 @@ public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapt
String account ="shujutongbu";
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account);
if(Objects.isNull(data)){
String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token";
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token";
cn.hutool.http.HttpRequest urlRequest = HttpRequest.post(url);
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
urlRequest.header("Tenant-Id", "627683");

4
blade-service/logpm-patch/src/main/java/com/logpm/patch/aspect/AsyncAnnotationAspect.java

@ -14,6 +14,7 @@ import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ThreadLocalUtil;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.stereotype.Component;
@ -29,6 +30,7 @@ import java.util.Objects;
@AllArgsConstructor
public class AsyncAnnotationAspect {
private final BladeRedis bladeRedis;
private final Environment environment;
/**
* 该方法为一个切面用于对标记了@RabbitListener注解的方法进行增强主要增加了日志记录和数据源上下文处理的功能
*
@ -93,7 +95,7 @@ public class AsyncAnnotationAspect {
String account ="shujutongbu";
JSONObject data =bladeRedis.get(CacheNames.LOCAL_SERVER_USER+account);
if(Objects.isNull(data)){
String url = "http://"+ LauncherConstant.loginAddr(AppConstant.DEV_CODE)+"/blade-auth/oauth/token";
String url = "http://"+ LauncherConstant.loginAddr(Objects.requireNonNull(environment.getActiveProfiles()[0]))+"/blade-auth/oauth/token";
HttpRequest urlRequest = HttpRequest.post(url);
urlRequest.header("Authorization", "Basic c2FiZXI6c2FiZXJfc2VjcmV0");
urlRequest.header("Tenant-Id", "627683");

Loading…
Cancel
Save