登录成功返回用户名称
This commit is contained in:
parent
17199c1573
commit
596b2b7f09
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.hisense.monitormanage.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserLoginDto {
|
||||
private String username;
|
||||
private String status;
|
||||
}
|
|
@ -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<UserLogin> {
|
||||
public interface UserLoginMapper extends BaseMapper<UserLoginMapper> {
|
||||
|
||||
@Select("select * from t_user_login")
|
||||
UserLogin getUserByName();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue