提交 e21cfd15 authored 作者: 马晨俊's avatar 马晨俊

mcj:将主服务器ip抽成变量

上级 f2dbedd3
......@@ -11,6 +11,7 @@ import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
......@@ -42,12 +43,15 @@ public class AopIntercept {
public void doPointCut() {
}
@Value("${address}")
private String address;
@Around("doPointCut()")
public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
String sessionId = request.getHeader("session");
String url = "http://120.55.57.35:12345/user/getLogin/"+sessionId;
String url = "http://"+address+":12345/user/getLogin/"+sessionId;
ServerResponse serverResponse = restTemplate.getForObject(url, ServerResponse.class);
if(serverResponse!=null && serverResponse.getCode()!=200){
ResponseEntity.status(403).build();
......
......@@ -65,4 +65,5 @@ spring.freemarker.template-loader-path=classpath:/templates
##Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
#spring.redis.port=6379
##Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
#spring.redis.password=
\ No newline at end of file
#spring.redis.password=
address=120.55.57.35
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论