|
@@ -1,11 +1,14 @@
|
|
|
package cn.cslg.pas.common.utils;
|
|
|
|
|
|
+import cn.cslg.pas.exception.ExceptionEnum;
|
|
|
+import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.context.request.RequestAttributes;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
+
|
|
|
import java.util.List;
|
|
|
|
|
|
@Component
|
|
@@ -29,9 +32,17 @@ public class LoginUtils {
|
|
|
}
|
|
|
|
|
|
public Integer getId() {
|
|
|
- String oriToken = LoginUtils.getToken();
|
|
|
+ String oriToken = null;
|
|
|
+ try {
|
|
|
+ oriToken = LoginUtils.getToken();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.LOGIN_NO_LOGIN, "未登录");
|
|
|
+ }
|
|
|
String q = "token:login:" + oriToken.replace("=", ":");
|
|
|
String IdS = redisUtil.get(q);
|
|
|
+ if (IdS == null) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.LOGIN_NO_LOGIN, "未登录");
|
|
|
+ }
|
|
|
return Integer.parseInt(IdS);
|
|
|
}
|
|
|
}
|