From 596b2b7f09d2124bafd44ecaa229525442a30828 Mon Sep 17 00:00:00 2001 From: wuweida <2918581207@qq.com> Date: Thu, 23 Jun 2022 17:27:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=88=90=E5=8A=9F=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../monitormanage/controller/UserLoginController.java | 3 ++- .../com/hisense/monitormanage/dto/UserLoginDto.java | 9 +++++++++ .../hisense/monitormanage/mapper/UserLoginMapper.java | 3 +-- .../monitormanage/service/UserLoginService.java | 11 ++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/hisense/monitormanage/dto/UserLoginDto.java diff --git a/src/main/java/com/hisense/monitormanage/controller/UserLoginController.java b/src/main/java/com/hisense/monitormanage/controller/UserLoginController.java index 51f05b1..0a6d999 100644 --- a/src/main/java/com/hisense/monitormanage/controller/UserLoginController.java +++ b/src/main/java/com/hisense/monitormanage/controller/UserLoginController.java @@ -1,5 +1,6 @@ package com.hisense.monitormanage.controller; +import com.hisense.monitormanage.dto.UserLoginDto; import com.hisense.monitormanage.entity.Result; import com.hisense.monitormanage.service.UserLoginService; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +17,7 @@ public class UserLoginController { @PostMapping("login") public Result login(String username,String password){ - String login = userLoginService.login(username, password); + UserLoginDto login = userLoginService.login(username, password); Result success = Result.success(login); return success; } diff --git a/src/main/java/com/hisense/monitormanage/dto/UserLoginDto.java b/src/main/java/com/hisense/monitormanage/dto/UserLoginDto.java new file mode 100644 index 0000000..5bf0061 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/dto/UserLoginDto.java @@ -0,0 +1,9 @@ +package com.hisense.monitormanage.dto; + +import lombok.Data; + +@Data +public class UserLoginDto { + private String username; + private String status; +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/UserLoginMapper.java b/src/main/java/com/hisense/monitormanage/mapper/UserLoginMapper.java index 0fdaeb2..d432825 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/UserLoginMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/UserLoginMapper.java @@ -2,10 +2,9 @@ package com.hisense.monitormanage.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hisense.monitormanage.entity.UserLogin; -import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; -public interface UserLoginMapper extends BaseMapper { +public interface UserLoginMapper extends BaseMapper { @Select("select * from t_user_login") UserLogin getUserByName(); diff --git a/src/main/java/com/hisense/monitormanage/service/UserLoginService.java b/src/main/java/com/hisense/monitormanage/service/UserLoginService.java index d1be78e..1877d2c 100644 --- a/src/main/java/com/hisense/monitormanage/service/UserLoginService.java +++ b/src/main/java/com/hisense/monitormanage/service/UserLoginService.java @@ -1,6 +1,7 @@ package com.hisense.monitormanage.service; import cn.hutool.crypto.SecureUtil; +import com.hisense.monitormanage.dto.UserLoginDto; import com.hisense.monitormanage.entity.UserLogin; import com.hisense.monitormanage.mapper.UserLoginMapper; import lombok.extern.log4j.Log4j2; @@ -14,11 +15,15 @@ public class UserLoginService { @Autowired private UserLoginMapper userLoginMapper; - public String login(String username,String password){ + public UserLoginDto login(String username, String password){ UserLogin user = userLoginMapper.getUserByName(); + UserLoginDto userLoginDto = new UserLoginDto(); if (user.getUsername().equals(username) && user.getPassword().equals(SecureUtil.md5(password))){ - return "登录成功"; + userLoginDto.setUsername(username); + userLoginDto.setStatus("登录成功"); + return userLoginDto; } - return "账号或密码错误"; + userLoginDto.setStatus("账号或密码错误"); + return userLoginDto; } }