Ver código fonte

优化:去掉多余的类

lijie 3 anos atrás
pai
commit
6c6ff9af08

+ 0 - 1
src/main/java/com/persagy/proxy/common/config/AdmMiddlewareWebConfigurer.java

@@ -3,7 +3,6 @@ package com.persagy.proxy.common.config;
 import com.persagy.dmp.auth.client.EmsSaasWebFallbackFactory;
 import com.persagy.dmp.auth.handler.AppContextHandler;
 import com.persagy.dmp.auth.service.AuthService;
-import com.persagy.proxy.common.handler.AdmContextHandler;
 import com.persagy.proxy.common.service.impl.EmsAuthServiceImpl;
 import com.persagy.proxy.common.service.impl.NoneAuthServiceImpl;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

+ 0 - 70
src/main/java/com/persagy/proxy/common/handler/AdmContextHandler.java

@@ -1,70 +0,0 @@
-package com.persagy.proxy.common.handler;
-
-import cn.hutool.core.util.StrUtil;
-import com.persagy.dmp.auth.service.AuthService;
-import com.persagy.dmp.auth.service.AuthServiceFactory;
-import com.persagy.dmp.common.constant.CommonConstant;
-import com.persagy.dmp.common.context.AppContext;
-import com.persagy.dmp.common.helper.SpringHelper;
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
-
-import javax.security.auth.message.AuthException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * 上下文 拦截器
- * @author Charlie Yu
- * @date 2021-09-13
- */
-public class AdmContextHandler extends HandlerInterceptorAdapter {
-
-    private final static String MIDDLEWARE_GROUP_CODE = "middleware.group.code";
-
-    @Override
-    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-        AuthService authService = AuthServiceFactory.getAuthService();
-        // 登录校验
-        boolean isSuccess = authService.validateLogin(request, response);
-        if(!isSuccess) {
-            // 鉴权器处理
-            authService.loginFailure(request, response);
-            throw new AuthException("登录认证失败!");
-        }
-        // 登录成功处理
-        authService.loginSuccess(request, response);
-        return true;
-    }
-
-    /**
-     * 从请求参数中获取上下文
-     * @param request
-     */
-    private void accessRequestInfo(HttpServletRequest request) {
-        AppContext.getContext().setGroupCode(request.getHeader("groupCode"));
-        AppContext.getContext().setProjectId(request.getHeader("projectId"));
-        AppContext.getContext().setAppId(request.getHeader("appId"));
-        String userId = request.getHeader("userId");
-        // 无用户时,默认为默认系统用户
-        if(StrUtil.isBlank(userId)) {
-            userId = CommonConstant.DEFAULT_ID;
-        }
-        AppContext.getContext().setAccountId(userId);
-        // 无集团编码时,默认为配置的集团编码
-        String groupCode = request.getHeader("groupCode");
-        if(StrUtil.isBlank(groupCode)) {
-            AppContext.getContext().setGroupCode(SpringHelper.getString(MIDDLEWARE_GROUP_CODE));
-        }
-    }
-
-    @Override
-    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
-        AppContext.unload();
-    }
-
-    @Override
-    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
-        AppContext.unload();
-    }
-}