Kaynağa Gözat

将 userId 的类型设置为 String

reghao 3 yıl önce
ebeveyn
işleme
2644785ac3

+ 2 - 6
web/src/main/java/cn/reghao/jutil/web/ServletUtil.java

@@ -16,13 +16,9 @@ import java.io.IOException;
  * @date 2021-06-02 13:16:58
  */
 public class ServletUtil {
-    public static Long getUserId() {
+    public static String getUserId() {
         String userId = getRequest().getHeader("x-user-id");
-        if (userId != null) {
-            return Long.parseLong(userId);
-        }
-
-        return -1L;
+        return  userId != null ? userId : "-1";
     }
 
     public static HttpSession getSession() {