Commit 02500678 authored by 李洪明's avatar 李洪明

添加登录

parent 25155307
Pipeline #1276 canceled with stages
...@@ -25,7 +25,7 @@ public class LoginConfig { ...@@ -25,7 +25,7 @@ public class LoginConfig {
public static String token = ""; public static String token = "";
@PostConstruct @PostConstruct
public void getLogin() throws Exception { public String getLogin() throws Exception {
Map<String, Object> body = new HashMap<>(); Map<String, Object> body = new HashMap<>();
body.put("username", USERNAME); body.put("username", USERNAME);
body.put("password", PASSWORD); body.put("password", PASSWORD);
...@@ -41,6 +41,7 @@ public class LoginConfig { ...@@ -41,6 +41,7 @@ public class LoginConfig {
JSONObject resultObject = JSONObject.parseObject(result); JSONObject resultObject = JSONObject.parseObject(result);
token = resultObject.getString("token"); token = resultObject.getString("token");
} }
return token;
} }
} }
...@@ -9,7 +9,7 @@ public class LoginService { ...@@ -9,7 +9,7 @@ public class LoginService {
@Autowired @Autowired
private LoginConfig loginConfig; private LoginConfig loginConfig;
public void login() throws Exception { public String login() throws Exception {
loginConfig.getLogin(); return loginConfig.getLogin();
} }
} }
...@@ -20,7 +20,7 @@ public class AuthController { ...@@ -20,7 +20,7 @@ public class AuthController {
@GetMapping("") @GetMapping("")
public CommonResult getAuthToken() throws Exception { public CommonResult getAuthToken() throws Exception {
loginService.login(); String token = loginService.login();
return CommonResult.success("成功"); return CommonResult.success("成功", token);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment