tlias管理系统--登录功能

This commit is contained in:
2025-11-30 12:13:05 +08:00
parent 1040f5f6fe
commit 62e2d5eaab
4 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package com.inmind.controller;
import com.inmind.pojo.Emp;
import com.inmind.pojo.Result;
import com.inmind.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
public class LoginController {
@Autowired
private EmpService empService;
@PostMapping("/login")
public Result login(@RequestBody Emp emp) {
log.info("登录操作:参数为:{}",emp);
//调用业务层的登录操作
Emp e = empService.login(emp);
//此时要根据返回的数据,进行登录成功和失败的判断
return e == null? Result.error("用户名或密码错误"):Result.success();
}
}

View File

@@ -62,4 +62,7 @@ public interface EmpMapper {
* @param emp
*/
void update(Emp emp);
@Select("select * from emp where username = #{username} and password = #{password} ")
Emp getEmpByUserNameAndPassword(Emp emp);
}

View File

@@ -44,4 +44,11 @@ public interface EmpService {
* @param emp
*/
void update(Emp emp);
/**
* 员工登录
* @param emp
* @return
*/
Emp login(Emp emp);
}

View File

@@ -112,4 +112,14 @@ public class EmpServiceImpl implements EmpService {
//调用mapper执行update语句
empMapper.update(emp);
}
/**
* 员工登录
* @param emp
* @return
*/
@Override
public Emp login(Emp emp) {
return empMapper.getEmpByUserNameAndPassword(emp);
}
}