From c7212662b1421ca34c828b9ec17e254591123c0c Mon Sep 17 00:00:00 2001 From: ly19960718 <1622779752@qq.com> Date: Thu, 28 Jan 2021 17:26:31 +0800 Subject: [PATCH] Merge branch 'main' of D:\CF_work\ideaWorkSpace\business-card with conflicts. --- ...eckAuth.java => CheckAuthInterceptor.java} | 41 +++---------------- ...nfig.java => LoginConfigInterceptors.java} | 7 ++-- 2 files changed, 8 insertions(+), 40 deletions(-) rename src/main/java/cn/com/tenlion/config/{CheckAuth.java => CheckAuthInterceptor.java} (68%) rename src/main/java/cn/com/tenlion/config/{LoginConfig.java => LoginConfigInterceptors.java} (81%) diff --git a/src/main/java/cn/com/tenlion/config/CheckAuth.java b/src/main/java/cn/com/tenlion/config/CheckAuthInterceptor.java similarity index 68% rename from src/main/java/cn/com/tenlion/config/CheckAuth.java rename to src/main/java/cn/com/tenlion/config/CheckAuthInterceptor.java index ab51530..ecc18d2 100644 --- a/src/main/java/cn/com/tenlion/config/CheckAuth.java +++ b/src/main/java/cn/com/tenlion/config/CheckAuthInterceptor.java @@ -3,24 +3,18 @@ package cn.com.tenlion.config; import cn.com.tenlion.accesstokenmanager.AccessTokenManager; import cn.com.tenlion.pojo.dtos.carduser.CardUserDTO; +import cn.com.tenlion.pojo.vos.carduser.CardUserVO; import cn.com.tenlion.service.carduser.ICardUserService; import cn.com.tenlion.util.AesUtil; -import cn.com.tenlion.util.annotation.AccessRightsCheck; -import cn.com.tenlion.util.enumeration.Auth; import com.github.pagehelper.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedType; -import java.lang.reflect.Method; +import java.io.IOException; /** * TODO @@ -44,33 +38,8 @@ public class CheckAuth implements HandlerInterceptor { if(path.contains("release")){ return true; } - /** - * 2021年1月28日10:28:38 - * CBC Start - * 通过Controller中方法上的注解进行权限控制与放行 - */ - // 获得类的请求 - HandlerMethod handlerMethod = null; - if(handler instanceof HandlerMethod) { - handlerMethod = (HandlerMethod) handler; - }else{ - return true; - } - // 权限校验的注解 - Method m = handlerMethod.getMethod(); - AccessRightsCheck accessRightsCheck = m.getAnnotation(AccessRightsCheck.class); - if(accessRightsCheck != null) { - if(accessRightsCheck != null) { - // 不校验 - if(Auth.NOCHECK.equals(accessRightsCheck.auth())) { - return true; - } - } - } - /** - * 2021年1月28日10:34:47 - * CBC End - */ + + String token = request.getHeader("token"); if(token == null || StringUtil.isEmpty(token)){ // response.setStatus(response.SC_METHOD_NOT_ALLOWED); diff --git a/src/main/java/cn/com/tenlion/config/LoginConfig.java b/src/main/java/cn/com/tenlion/config/LoginConfigInterceptors.java similarity index 81% rename from src/main/java/cn/com/tenlion/config/LoginConfig.java rename to src/main/java/cn/com/tenlion/config/LoginConfigInterceptors.java index aa0fcc6..26814da 100644 --- a/src/main/java/cn/com/tenlion/config/LoginConfig.java +++ b/src/main/java/cn/com/tenlion/config/LoginConfigInterceptors.java @@ -1,6 +1,5 @@ package cn.com.tenlion.config; -import org.apache.catalina.startup.UserConfig; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistration; @@ -14,7 +13,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; * @date 2021/1/27 12:34 */ @Configuration -public class LoginConfig implements WebMvcConfigurer { +public class LoginConfigInterceptors implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { @@ -24,8 +23,8 @@ public class LoginConfig implements WebMvcConfigurer { } @Bean - private static CheckAuth checkAuth() { - return new CheckAuth(); + private static CheckAuthInterceptor checkAuth() { + return new CheckAuthInterceptor(); } }