jiangping
2024-07-17 718d62b2bd5df79cd130514f5aa6a77a7e26d93f
server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
@@ -13,6 +13,7 @@
import io.jsonwebtoken.JwtException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
@@ -40,6 +41,12 @@
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;
    /**
     * 是否开发者
     */
    @Value("${debug_model}")
    private Boolean isDebug;
    /**
     * 添加拦截器
@@ -111,6 +118,7 @@
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已禁用,请联系管理员");
            }
            request.setAttribute(JwtTokenUtil.UserId_Name, memberId);
            request.setAttribute(JwtTokenUtil.UserType, Constants.CUSTOMER);
            return true;
        } catch (IllegalArgumentException | JwtException e) {
            throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"未登录");
@@ -120,6 +128,9 @@
    public Boolean checkPersonnelLogin(HttpServletRequest request, HttpServletResponse response){
        String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
        try {
            if(isDebug){
                return  true;
            }
            //判断Token是否超时
            boolean expiration = JwtTokenUtil.isTokenExpired(token);
            if (expiration) {
@@ -142,6 +153,7 @@
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户已禁用,请联系管理员");
            }
            request.setAttribute(JwtTokenUtil.UserId_Name, userId);
            request.setAttribute(JwtTokenUtil.UserType, Constants.BUSINESS);
            return true;
        } catch (IllegalArgumentException | JwtException e) {
            throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"未登录");