From 996b2f16afaa271ce8aad6abf6858aa5db503eb3 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期六, 25 四月 2026 14:07:34 +0800
Subject: [PATCH] 代码生成
---
server/services/src/main/java/com/doumee/config/jwt/WebMvcConfig.java | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 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 5792dcd..289102e 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
@@ -10,6 +10,7 @@
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.model.ShopInfo;
import io.jsonwebtoken.JwtException;
+import lombok.extern.log4j.Log4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
@@ -26,6 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Objects;
+import java.util.logging.Logger;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@@ -74,19 +76,19 @@
}
}else if (beanType.isAnnotationPresent(LoginShopRequired.class)) {
//鑾峰彇token
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY); // 浠� http 璇锋眰澶翠腑鍙栧嚭 token
+ String token = request.getHeader(JwtTokenUtil.SHOP_HEADER_KEY); // 浠� http 璇锋眰澶翠腑鍙栧嚭 token
if (StringUtils.isNotBlank(token)) {
- checkShopLogin(request,response);
+ checkShopLogin(token,request,response);
} else {
- throw new BusinessException(ResponseStatus.BE_OVERDUE.getCode(),"鏈櫥褰�");
+ throw new BusinessException(ResponseStatus.SHOP_BE_OVERDUE.getCode(),"鏈櫥褰�");
}
}else if (handlerMethod.hasMethodAnnotation(LoginShopRequired.class)){
//鑾峰彇token
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY); // 浠� http 璇锋眰澶翠腑鍙栧嚭 token
+ String token = request.getHeader(JwtTokenUtil.SHOP_HEADER_KEY); // 浠� http 璇锋眰澶翠腑鍙栧嚭 token
if (StringUtils.isNotBlank(token)) {
- checkShopLogin(request,response);
+ checkShopLogin(token,request,response);
} else {
- throw new BusinessException(ResponseStatus.BE_OVERDUE.getCode(),"鏈櫥褰�");
+ throw new BusinessException(ResponseStatus.SHOP_BE_OVERDUE.getCode(),"鏈櫥褰�");
}
}else if (beanType.isAnnotationPresent(LoginDriverRequired.class)) {
//鑾峰彇token
@@ -115,6 +117,7 @@
public Boolean checkMemberLogin(HttpServletRequest request, HttpServletResponse response){
String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ System.out.println("浼氬憳token:=========>{}"+token);
try {
if(!token.startsWith(Constants.ZERO+"")){
throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME);
@@ -144,19 +147,19 @@
}
- public Boolean checkShopLogin(HttpServletRequest request, HttpServletResponse response){
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ public Boolean checkShopLogin(String token,HttpServletRequest request, HttpServletResponse response){
+ System.out.println("闂ㄥ簵token:=========>{}"+token);
try {
if(!token.startsWith(Constants.TWO+"")){
- throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME);
+ throw new BusinessException(ResponseStatus.SHOP_TOKEN_EXCEED_TIME);
}
String tokenRedis = (String) redisTemplate.opsForValue().get(Constants.REDIS_TOKEN_KEY+token);
if(StringUtils.isBlank(tokenRedis)){
- throw new BusinessException(ResponseStatus.BE_OVERDUE);
+ throw new BusinessException(ResponseStatus.SHOP_BE_OVERDUE);
}
ShopInfo shop = JSONObject.parseObject(tokenRedis, ShopInfo.class);
if(Objects.isNull(shop)){
- throw new BusinessException(ResponseStatus.BE_OVERDUE);
+ throw new BusinessException(ResponseStatus.SHOP_BE_OVERDUE);
}
String openid = shop.getOpenid();
Integer shopId = getTokenId(token);
@@ -170,22 +173,23 @@
}
String dbOpenid = dao.queryForObject(" select ifnull(openid,'') from shop_info where id = ?", String.class, shopId);
if(StringUtils.isBlank(dbOpenid)||!openid.equals(dbOpenid)){
- throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME);
+ throw new BusinessException(ResponseStatus.SHOP_TOKEN_EXCEED_TIME);
}
Integer count = dao.queryForObject("select count(1) from shop_info where id = ?", Integer.class, shopId);
if (count != null && count > 0) {
request.setAttribute(JwtTokenUtil.SHOP_ID, shop.getId());
return true;
}else{
- throw new BusinessException(ResponseStatus.BE_OVERDUE.getCode(),"鐢ㄦ埛淇℃伅鍑洪敊");
+ throw new BusinessException(ResponseStatus.SHOP_BE_OVERDUE.getCode(),"鐢ㄦ埛淇℃伅鍑洪敊");
}
} catch (IllegalArgumentException | JwtException e) {
- throw new BusinessException(ResponseStatus.BE_OVERDUE);
+ throw new BusinessException(ResponseStatus.SHOP_BE_OVERDUE);
}
}
public Boolean checkDriverLogin(HttpServletRequest request, HttpServletResponse response){
String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ System.out.println("鍙告満token:=========>{}"+token);
try {
if(!token.startsWith(Constants.ONE+"")){
throw new BusinessException(ResponseStatus.TOKEN_EXCEED_TIME);
--
Gitblit v1.9.3