From ec65b1f7ec0e3c973151d4f6bc351ba0ffab2f4a Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 1 Apr 2020 14:01:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=AF=B7=E6=B1=82params?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=B8=BAdata=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/login.js | 2 +- .../ruoyi/framework/security/LoginBody.java | 69 +++++++++++++++++++ .../system/controller/SysLoginController.java | 7 +- 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java diff --git a/ruoyi-ui/src/api/login.js b/ruoyi-ui/src/api/login.js index faa7bbe7..9971357e 100644 --- a/ruoyi-ui/src/api/login.js +++ b/ruoyi-ui/src/api/login.js @@ -11,7 +11,7 @@ export function login(username, password, code, uuid) { return request({ url: '/login', method: 'post', - params: data + data: data }) } diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java b/ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java new file mode 100644 index 00000000..59860537 --- /dev/null +++ b/ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java @@ -0,0 +1,69 @@ +package com.ruoyi.framework.security; + +/** + * 用户登录对象 + * + * @author ruoyi + */ +public class LoginBody +{ + /** + * 用户名 + */ + private String username; + + /** + * 用户密码 + */ + private String password; + + /** + * 验证码 + */ + private String code; + + /** + * 唯一标识 + */ + private String uuid = ""; + + public String getUsername() + { + return username; + } + + public void setUsername(String username) + { + this.username = username; + } + + public String getPassword() + { + return password; + } + + public void setPassword(String password) + { + this.password = password; + } + + public String getCode() + { + return code; + } + + public void setCode(String code) + { + this.code = code; + } + + public String getUuid() + { + return uuid; + } + + public void setUuid(String uuid) + { + this.uuid = uuid; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java index d7bf9235..6871d836 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java @@ -5,9 +5,11 @@ import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.utils.ServletUtils; +import com.ruoyi.framework.security.LoginBody; import com.ruoyi.framework.security.LoginUser; import com.ruoyi.framework.security.service.SysLoginService; import com.ruoyi.framework.security.service.SysPermissionService; @@ -47,11 +49,12 @@ public class SysLoginController * @return 结果 */ @PostMapping("/login") - public AjaxResult login(String username, String password, String code, String uuid) + public AjaxResult login(@RequestBody LoginBody loginBody) { AjaxResult ajax = AjaxResult.success(); // 生成令牌 - String token = loginService.login(username, password, code, uuid); + String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), + loginBody.getUuid()); ajax.put(Constants.TOKEN, token); return ajax; }