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,31 +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();
            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");
        }
    }
}