Kaynağa Gözat

考试,练习,课程学习查询改为不必须登录

yangfeng 1 yıl önce
ebeveyn
işleme
cad09bcc9b

+ 4 - 1
web/src/main/java/com/ynfy/app/api/v1/interceptor/AuthorizationInterceptor.java

@@ -4,8 +4,10 @@ import com.auth0.jwt.exceptions.TokenExpiredException;
 import com.ynfy.app.api.v1.annoation.IgnoreAuth;
 import com.ynfy.app.api.v1.util.TokenUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.jeecg.common.exception.JeecgBoot401Exception;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.util.JwtUtil;
+import org.jeecg.common.util.SpringContextUtils;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.stereotype.Component;
@@ -50,7 +52,8 @@ public class AuthorizationInterceptor implements HandlerInterceptor {
         //获取token
         String token = TokenUtil.getToken(request);
         if (StringUtils.isBlank(token)) {
-            throw new JeecgBootException("请先登录");
+            JwtUtil.responseError(SpringContextUtils.getHttpServletResponse(),401,"请先登录");
+            return false;
         }
         String userName = TokenUtil.getUserName(token);