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; } }