From caa18ac5993ccbb93b3efc0668dcd757480728cb Mon Sep 17 00:00:00 2001 From: diaobisong Date: Thu, 25 Jan 2024 18:33:21 +0800 Subject: [PATCH] fix code --- .../src/main/java/com/java3y/austin/web/config/JwtConfig.java | 3 +-- .../java/com/java3y/austin/web/controller/UserController.java | 4 +++- austin-web/src/main/resources/application.properties | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/austin-web/src/main/java/com/java3y/austin/web/config/JwtConfig.java b/austin-web/src/main/java/com/java3y/austin/web/config/JwtConfig.java index f79905c..bc61902 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/config/JwtConfig.java +++ b/austin-web/src/main/java/com/java3y/austin/web/config/JwtConfig.java @@ -8,10 +8,9 @@ import java.util.Set; @Data @Component -@ConfigurationProperties(prefix = "jwt") public class JwtConfig { - private String key; + private String key = "3a79fb4970284e1b849b3ff26e7e1248"; } diff --git a/austin-web/src/main/java/com/java3y/austin/web/controller/UserController.java b/austin-web/src/main/java/com/java3y/austin/web/controller/UserController.java index 8a57751..c199db9 100644 --- a/austin-web/src/main/java/com/java3y/austin/web/controller/UserController.java +++ b/austin-web/src/main/java/com/java3y/austin/web/controller/UserController.java @@ -1,6 +1,7 @@ package com.java3y.austin.web.controller; +import com.alibaba.fastjson.JSON; import com.java3y.austin.web.annotation.AustinAspect; import com.java3y.austin.web.annotation.AustinResult; import com.java3y.austin.web.config.JwtConfig; @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -43,7 +45,7 @@ public class UserController { Map resultMap = new HashMap(); resultMap.put("creator", creator); - String token = JwtUtil.createToken(creator, jwtConfig.getKey(), 24 * 60 * 60); + String token = JwtUtil.createToken(JSON.toJSONString(Collections.singletonMap("creator", creator)), jwtConfig.getKey(), 24 * 60 * 60); resultMap.put("token", token); return ResponseEntity.ok(resultMap); } diff --git a/austin-web/src/main/resources/application.properties b/austin-web/src/main/resources/application.properties index 3357622..ac977ce 100644 --- a/austin-web/src/main/resources/application.properties +++ b/austin-web/src/main/resources/application.properties @@ -132,6 +132,4 @@ management.health.rabbit.enabled=false ########################################## system start ########################################## server.shutdown=graceful -########################################## system end ########################################## - -jwt.key: 3a79fb4970284e1b849b3ff26e7e1248 +########################################## system end ########################################## \ No newline at end of file