tlias管理系统-普通登录功能
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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.getEmpByUserNameAndPassWord(emp);
|
||||
return e != null?Result.success():Result.error("用户名或密码错误");
|
||||
}
|
||||
}
|
||||
@@ -40,4 +40,7 @@ public interface EmpMapper {
|
||||
Emp getEmpById(Integer id);
|
||||
|
||||
void updateEmp(Emp emp);
|
||||
|
||||
@Select("select * from emp where username =#{username} and password = #{password} ")
|
||||
Emp getEmpByUserNameAndPassWord(Emp emp);
|
||||
}
|
||||
|
||||
@@ -21,4 +21,7 @@ public interface EmpService {
|
||||
|
||||
//修改员工信息
|
||||
void updateEmp(Emp emp);
|
||||
|
||||
//根据用户名和密码查询员工信息
|
||||
Emp getEmpByUserNameAndPassWord(Emp emp);
|
||||
}
|
||||
|
||||
@@ -77,4 +77,10 @@ public class EmpServiceImpl implements EmpService {
|
||||
emp.setUpdateTime(LocalDateTime.now());
|
||||
empMapper.updateEmp(emp);
|
||||
}
|
||||
|
||||
//根据用户名和密码查询员工信息
|
||||
@Override
|
||||
public Emp getEmpByUserNameAndPassWord(Emp emp) {
|
||||
return empMapper.getEmpByUserNameAndPassWord(emp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user