From ab9cd2c82bd64de8e33510db1d1e78a5b3b4de70 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期一, 20 四月 2026 19:37:20 +0800
Subject: [PATCH] 代码生成

---
 server/services/src/main/java/com/doumee/config/jwt/WebMvcConfig.java |   55 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/config/jwt/WebMvcConfig.java b/server/services/src/main/java/com/doumee/config/jwt/WebMvcConfig.java
index 6a3bcd9..3c85107 100644
--- a/server/services/src/main/java/com/doumee/config/jwt/WebMvcConfig.java
+++ b/server/services/src/main/java/com/doumee/config/jwt/WebMvcConfig.java
@@ -1,6 +1,7 @@
 package com.doumee.config.jwt;
 
 import com.alibaba.fastjson.JSONObject;
+import com.doumee.core.annotation.LoginDriverRequired;
 import com.doumee.core.annotation.LoginRequired;
 import com.doumee.core.annotation.LoginShopRequired;
 import com.doumee.core.constants.Constants;
@@ -87,6 +88,22 @@
                     } else {
                         throw new BusinessException(ResponseStatus.BE_OVERDUE.getCode(),"鏈櫥褰�");
                     }
+                }else if (beanType.isAnnotationPresent(LoginDriverRequired.class)) {
+                    //鑾峰彇token
+                    String token = request.getHeader(JwtTokenUtil.HEADER_KEY);  // 浠� http 璇锋眰澶翠腑鍙栧嚭 token
+                    if (StringUtils.isNotBlank(token)) {
+                        checkDriverLogin(request,response);
+                    } else {
+                        throw new BusinessException(ResponseStatus.BE_OVERDUE.getCode(),"鏈櫥褰�");
+                    }
+                }else if (handlerMethod.hasMethodAnnotation(LoginDriverRequired.class)){
+                    //鑾峰彇token
+                    String token = request.getHeader(JwtTokenUtil.HEADER_KEY);  // 浠� http 璇锋眰澶翠腑鍙栧嚭 token
+                    if (StringUtils.isNotBlank(token)) {
+                        checkDriverLogin(request,response);
+                    } else {
+                        throw new BusinessException(ResponseStatus.BE_OVERDUE.getCode(),"鏈櫥褰�");
+                    }
                 }
                 return true;
             }
@@ -99,11 +116,10 @@
     public Boolean checkMemberLogin(HttpServletRequest request, HttpServletResponse response){
         String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
         try {
-
             if(!token.startsWith(Constants.ZERO+"")){
                 throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME);
             }
-            String tokenRedis = (String) redisTemplate.opsForValue().get(token);
+            String tokenRedis = (String) redisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY+token);
             if(StringUtils.isBlank(tokenRedis)){
                 throw new BusinessException(ResponseStatus.BE_OVERDUE);
             }
@@ -117,7 +133,6 @@
             }
             Integer count = dao.queryForObject("select count(1) from member where id  = ?", Integer.class, member.getId());
             if (count != null && count > 0) {
-                request.setAttribute(JwtTokenUtil.MEMBER_INFO, JSONObject.toJSONString(member));
                 request.setAttribute(JwtTokenUtil.MEMBER_ID, member.getId());
                 return true;
             }else{
@@ -135,7 +150,7 @@
             if(!token.startsWith(Constants.TWO+"")){
                 throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME);
             }
-            String tokenRedis = (String) redisTemplate.opsForValue().get(token);
+            String tokenRedis = (String) redisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY+token);
             if(StringUtils.isBlank(tokenRedis)){
                 throw new BusinessException(ResponseStatus.BE_OVERDUE);
             }
@@ -159,7 +174,6 @@
             }
             Integer count = dao.queryForObject("select count(1) from shop where id  = ?", Integer.class, shopId);
             if (count != null && count > 0) {
-                request.setAttribute(JwtTokenUtil.SHOP_INFO, JSONObject.toJSONString(shop));
                 request.setAttribute(JwtTokenUtil.SHOP_ID, shop.getId());
                 return true;
             }else{
@@ -170,6 +184,37 @@
         }
     }
 
+    public Boolean checkDriverLogin(HttpServletRequest request, HttpServletResponse response){
+        String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+        try {
+            if(!token.startsWith(Constants.ONE+"")){
+                throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME);
+            }
+            String tokenRedis = (String) redisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY+token);
+            if(StringUtils.isBlank(tokenRedis)){
+                throw new BusinessException(ResponseStatus.BE_OVERDUE);
+            }
+            Integer memberId = getTokenId(token);
+            Integer isDeleted = dao.queryForObject(" select COALESCE(DELETED,1)  from member where user_type = 1 and   id  = ?", Integer.class, memberId);
+            if(isDeleted== Constants.ONE){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍙告満淇℃伅宸插垹闄�,璇疯仈绯荤鐞嗗憳");
+            }
+            Integer isForbidden = dao.queryForObject(" select COALESCE(STATUS,0)  from member where user_type = 1 and  id  = ?", Integer.class, memberId);
+            if(isForbidden == Constants.ONE){
+                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍙告満淇℃伅宸茬鐢�,璇疯仈绯荤鐞嗗憳");
+            }
+            Integer count = dao.queryForObject("select count(1) from member where  user_type = 1  and id  = ?", Integer.class, memberId);
+            if (count != null && count > 0) {
+                request.setAttribute(JwtTokenUtil.DRIVER_ID, memberId);
+                return true;
+            }else{
+                throw new BusinessException(ResponseStatus.BE_OVERDUE.getCode(),"鍙告満淇℃伅鍑洪敊");
+            }
+        } catch (IllegalArgumentException | JwtException e) {
+            throw new BusinessException(ResponseStatus.BE_OVERDUE);
+        }
+    }
+
 
     public Integer getTokenId(String token){
         try {

--
Gitblit v1.9.3