lyhzzz 1 年之前
父节点
当前提交
4b2481f884

+ 6 - 0
pom.xml

@@ -62,6 +62,12 @@
             <version>0.9.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>4.3.0</version>
+        </dependency>
+
 
         <!--        uploadToOssUtil-->
         <dependency>

+ 1 - 0
src/main/java/com/cdf/service/impl/FdkkSceneService.java

@@ -2,6 +2,7 @@ package com.cdf.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.auth0.jwt.interfaces.DecodedJWT;
 import com.cdf.common.PageInfo;
 import com.cdf.common.ResultCode;
 import com.cdf.entity.FdkkUser;

+ 6 - 4
src/main/java/com/cdf/util/JwtUtil.java

@@ -1,5 +1,7 @@
 package com.cdf.util;
 
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.interfaces.DecodedJWT;
 import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.JwtBuilder;
 import io.jsonwebtoken.Jwts;
@@ -85,12 +87,12 @@ public class JwtUtil {
 
 
     public static String getPhone(String token){
-        Claims claims = parseJWT(token);
-        return claims.get("phone",String.class);
+        DecodedJWT jwt = JWT.decode(token);
+        return jwt.getClaim("phone").asString();
     }
     public static Integer getId(String token){
-        Claims claims = parseJWT(token);
-        return claims.get("id",Integer.class);
+        DecodedJWT jwt = JWT.decode(token);
+        return jwt.getClaim("id").asInt();
     }
 
     public static String getKey(){

+ 3 - 2
src/main/resources/application-local.yaml

@@ -14,10 +14,11 @@ spring:
       username: root
       password: 4Dage@zhongmian#@168
   redis:
-    host: 120.25.146.52
+    database: 1
+    host: 18.156.200.112
     port: 6379
     timeout: 6000ms
-    password:
+    password: JK20220120%4dkk
     # cluster:
     #   max-redirects: 3  # 获取失败 最大重定向次数
     #   nodes: