From 9a7978c3a82ce66c87be2a42ca15beeb4617a096 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 20 八月 2025 14:42:24 +0800
Subject: [PATCH] 修改bug
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/aop/SsoAspect.java | 44 ++------------------------------------------
1 files changed, 2 insertions(+), 42 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/aop/SsoAspect.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/aop/SsoAspect.java
index 2619ddc..ebd9d33 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/aop/SsoAspect.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/aop/SsoAspect.java
@@ -14,13 +14,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.util.UriComponentsBuilder;
import java.lang.reflect.Method;
import java.util.Objects;
@@ -34,15 +28,8 @@
@Value("${pipIrr.global.dev}")
public String isDevStage ;//鏄惁涓哄紑鍙戦樁娈�
- @Value("${pipIrr.sso.checkUrl}")
- public String ssoCheckUrl;
-
- private RestTemplate restTemplate;
-
@Autowired
- public void setRestTemplate(RestTemplate restTemplate){
- this.restTemplate = restTemplate ;
- }
+ private SsoCheck ssoCheck ;
@Pointcut("@annotation(com.dy.common.aop.SsoAop)")
public void ssoPointCut() {
@@ -58,7 +45,7 @@
SsoAop aop = method.getAnnotation(SsoAop.class) ;
if (Objects.nonNull(aop)){
String token = UserTokenContext.get() ;
- Object rObj = this.check(token);
+ Object rObj = this.ssoCheck.check(token);
if(rObj != null){
if(rObj instanceof SsoVo ssoVo){
if(ssoVo.logined){
@@ -93,32 +80,5 @@
}
}
- /**
- * 璋冪敤SSO绯荤粺杩涜楠岃瘉
- * @param token Header涓殑鐢ㄦ埛token
- * @return 杩斿洖瀵硅薄
- */
- private Object check(String token){
- if(!StringUtils.isNullOrEmpty(ssoCheckUrl)){
- String url = UriComponentsBuilder.fromUriString(ssoCheckUrl)
- .queryParam("token", token)
- .build()
- .toUriString();
- // 鐢变簬鑾峰彇student鎺ュ彛鍜变滑璁剧疆浜哹asicauth锛屾墍浠ラ渶瑕佸湪璇锋眰鏃堕厤缃�
- HttpHeaders headers = new HttpHeaders();
- HttpEntity<?> httpEntity = new HttpEntity<>(headers);
- ResponseEntity<SsoVo> response = null;
- try {
- // 閫氳繃Get鏂瑰紡璋冪敤鎺ュ彛
- response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, SsoVo.class);
- } catch (Exception e) {
- e.printStackTrace();
- }
- assert response != null;
- return response.getBody();
- }else {
- return BaseResponseUtils.buildError("鍚庣绯荤粺鍑洪敊锛屾湭寰楀埌SsoCheckUrl");
- }
- }
}
--
Gitblit v1.8.0