From 7dc29ed74ebaa8a0e66f68264d9a13f95dc3af21 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 02 八月 2024 11:09:06 +0800
Subject: [PATCH] aa

---
 server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java |   42 +++++++++++++++++++-----------------------
 1 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
index f7d6ad6..33811d7 100644
--- a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
+++ b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
@@ -66,30 +66,19 @@
 
                 Class<?> beanType = handlerMethod.getBeanType();
                 Boolean checkFlag = false;
-                if(!(
-                    beanType.isAnnotationPresent(LoginRequired.class) || handlerMethod.hasMethodAnnotation(LoginRequired.class)
-                            || beanType.isAnnotationPresent(UserLoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class))
+                if(!( handlerMethod.hasMethodAnnotation(LoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class))
                 ){
                     return true;
                 }
-                // 鏈� @LoginRequired 娉ㄨВ锛岄渶瑕佺櫥褰曡璇� 瀹㈡埛绔娇鐢�
-                if (!checkFlag && (beanType.isAnnotationPresent(LoginRequired.class) || handlerMethod.hasMethodAnnotation(LoginRequired.class))) {
-                    String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
-                    if(StringUtils.isBlank(token)){
-                        throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
-                    }
-                    if (StringUtils.isNotBlank(token)) {
-                        checkFlag = checkLogin(request,response,token);
-                    }
+                String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+                if(StringUtils.isBlank(token)){
+                    throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
                 }
-                if(!checkFlag && (beanType.isAnnotationPresent(UserLoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class))){
-                    String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
-                    if(StringUtils.isBlank(token)){
-                        throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
-                    }
-                    if (StringUtils.isNotBlank(token)) {
+                if (handlerMethod.hasMethodAnnotation(LoginRequired.class)) {
+                        checkFlag = checkLogin(request,response,token);
+                }
+                if(!checkFlag && handlerMethod.hasMethodAnnotation(UserLoginRequired.class)){
                         checkFlag = checkPersonnelLogin(request,response,token);
-                    }
                 }
                 if(!checkFlag){
                     throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
@@ -112,14 +101,19 @@
             if(Objects.isNull(member)){
                 throw new BusinessException(ResponseStatus.DATA_EMPTY);
             }
+            if(Objects.isNull(member.getOpenid())){
+                throw new BusinessException(ResponseStatus.USER_DISABLE_TIME.getCode(),"鐢ㄦ埛宸叉敞閿�,璇烽噸鏂扮櫥褰�");
+            }
             if(Constants.equalsInteger(member.getIsdeleted(),Constants.ONE)){
-                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸插垹闄�,璇疯仈绯荤鐞嗗憳");
+                throw new BusinessException(ResponseStatus.USER_DISABLE_TIME.getCode(),"鐢ㄦ埛宸插垹闄�,璇疯仈绯荤鐞嗗憳");
             }
             if(!Constants.equalsInteger(member.getStatus(),Constants.ZERO)){
-                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸茬鐢�,璇疯仈绯荤鐞嗗憳");
+                throw new BusinessException(ResponseStatus.USER_DISABLE_TIME.getCode(),"鐢ㄦ埛宸茬鐢�,璇疯仈绯荤鐞嗗憳");
             }
             request.setAttribute(JwtTokenUtil.UserId_Name, memberId);
             request.setAttribute(JwtTokenUtil.UserType, ZTConstants.CUSTOMER);
+            request.setAttribute(JwtTokenUtil.HEADER_KEY, ZTConstants.CUSTOMER+"_"+token);
+            request.setAttribute(JwtTokenUtil.UserInfo, tokenRedis);
             return true;
         } catch (IllegalArgumentException | JwtException e) {
             throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
@@ -138,13 +132,15 @@
                 throw new BusinessException(ResponseStatus.DATA_EMPTY);
             }
             if(Constants.equalsInteger(users.getIsdeleted(),Constants.ONE)){
-                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸插垹闄�,璇疯仈绯荤鐞嗗憳");
+                throw new BusinessException(ResponseStatus.USER_DISABLE_TIME.getCode(),"鐢ㄦ埛宸插垹闄�,璇疯仈绯荤鐞嗗憳");
             }
             if(!StringUtils.equals(users.getStatus(),Constants.ONE+"")){
-                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸茬鐢�,璇疯仈绯荤鐞嗗憳");
+                throw new BusinessException(ResponseStatus.USER_DISABLE_TIME.getCode(),"鐢ㄦ埛鐘舵�佸紓甯�,璇烽噸鏂扮櫥褰�");
             }
             request.setAttribute(JwtTokenUtil.UserId_Name, userId);
             request.setAttribute(JwtTokenUtil.UserType, ZTConstants.BUSINESS);
+            request.setAttribute(JwtTokenUtil.HEADER_KEY, ZTConstants.CUSTOMER+"_"+token);
+            request.setAttribute(JwtTokenUtil.UserInfo, tokenRedis);
             return true;
         } catch (IllegalArgumentException | JwtException e) {
             throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");

--
Gitblit v1.9.3