From 212a59db0f342924c0ad72e8ec640684de514702 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期二, 17 三月 2026 10:01:00 +0800
Subject: [PATCH] 123
---
server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java | 35 +++++++++++++++++++++++++++++------
1 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java b/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
index 3082db6..87fb6f5 100644
--- a/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
+++ b/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
@@ -1,10 +1,13 @@
package com.doumee.config.Jwt;
+import com.alibaba.fastjson.JSONObject;
import com.doumee.config.annotation.LoginRequired;
import com.doumee.config.annotation.LoginShopRequired;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.utils.Constants;
+import com.doumee.dao.business.model.Member;
+import com.doumee.dao.business.model.Shop;
import io.jsonwebtoken.JwtException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +23,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.lang.reflect.Method;
+import java.util.Objects;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@@ -103,16 +106,28 @@
if(StringUtils.isBlank(tokenRedis)){
throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
}
+ Member member = JSONObject.parseObject(tokenRedis, Member.class);
+ if(Objects.isNull(member)||StringUtils.isBlank(member.getOpenId())){
+ throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
+ }
+ String openid = member.getOpenId();
Integer memberId = getTokenId(token);
- Integer isDeleted = dao.queryForObject(" select COALESCE(ISDELETED,0) from Member where id = ?", Integer.class, memberId);
+ Integer isDeleted = dao.queryForObject(" select COALESCE(ISDELETED,0) from member where 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 id = ?", Integer.class, memberId);
- if(isForbidden== Constants.ONE){
+ Integer isForbidden = dao.queryForObject(" select COALESCE(STATUS,0) from member where 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 id = ?", Integer.class, memberId);
+ if(isForbidden == Constants.TWO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸叉敞閿�,璇疯仈绯荤鐞嗗憳");
+ }
+ String dbOpenid = dao.queryForObject(" select ifnull(open_id,'') from member where id = ?", String.class, memberId);
+ if(StringUtils.isBlank(dbOpenid)||!openid.equals(dbOpenid)){
+ throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�");
+ }
+ Integer count = dao.queryForObject("select count(1) from member where id = ?", Integer.class, memberId);
if (count != null && count > 0) {
request.setAttribute(JwtTokenUtil.UserId_Name, memberId);
return true;
@@ -135,6 +150,11 @@
if(StringUtils.isBlank(tokenRedis)){
throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
}
+ Shop shop = JSONObject.parseObject(tokenRedis, Shop.class);
+ if(Objects.isNull(shop)||StringUtils.isBlank(shop.getOpenId())){
+ throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
+ }
+ String openid = shop.getOpenId();
Integer shopId = getTokenId(token);
Integer isDeleted = dao.queryForObject(" select COALESCE(ISDELETED,0) from shop where id = ?", Integer.class, shopId);
if(isDeleted== Constants.ONE){
@@ -143,6 +163,10 @@
Integer isForbidden = dao.queryForObject(" select COALESCE(STATUS,0) from shop where id = ?", Integer.class, shopId);
if(isForbidden== Constants.ONE){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸茬鐢�,璇疯仈绯荤鐞嗗憳");
+ }
+ String dbOpenid = dao.queryForObject(" select ifnull(open_id,'') from shop where id = ?", String.class, shopId);
+ if(StringUtils.isBlank(dbOpenid)||!openid.equals(dbOpenid)){
+ throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�");
}
Integer count = dao.queryForObject("select count(1) from shop where id = ?", Integer.class, shopId);
if (count != null && count > 0) {
@@ -155,7 +179,6 @@
throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
}
}
-
public Integer getTokenId(String token){
try {
--
Gitblit v1.9.3