pull/60/head
diaobisong 2 years ago
parent baa6ae094e
commit caa18ac599

@ -8,10 +8,9 @@ import java.util.Set;
@Data @Data
@Component @Component
@ConfigurationProperties(prefix = "jwt")
public class JwtConfig { public class JwtConfig {
private String key; private String key = "3a79fb4970284e1b849b3ff26e7e1248";
} }

@ -1,6 +1,7 @@
package com.java3y.austin.web.controller; package com.java3y.austin.web.controller;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.web.annotation.AustinAspect; import com.java3y.austin.web.annotation.AustinAspect;
import com.java3y.austin.web.annotation.AustinResult; import com.java3y.austin.web.annotation.AustinResult;
import com.java3y.austin.web.config.JwtConfig; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -43,7 +45,7 @@ public class UserController {
Map resultMap = new HashMap(); Map resultMap = new HashMap();
resultMap.put("creator", creator); 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); resultMap.put("token", token);
return ResponseEntity.ok(resultMap); return ResponseEntity.ok(resultMap);
} }

@ -132,6 +132,4 @@ management.health.rabbit.enabled=false
########################################## system start ########################################## ########################################## system start ##########################################
server.shutdown=graceful server.shutdown=graceful
########################################## system end ########################################## ########################################## system end ##########################################
jwt.key: 3a79fb4970284e1b849b3ff26e7e1248
Loading…
Cancel
Save