回显员工信息功能
**Controller层**
@ApiOperation("根据id查询员工信息")
@GetMapping("/{id}")
public Result<Employee> GetById(@PathVariable Long id){
log.info("开始根据id查询员工信息");
Employee employee=employeeService.GetById(id);
return Result.success(employee);
}
Service层实现类
@Override
public Employee GetById(Long id) {
return employeeMapper.GetById(id);
}
Mapper层
@Select("select * from employee where id =#{id}")
Employee GetById(Long id);
修改员工信息功能
Controller层
@ApiOperation("修改员工信息")
@PutMapping
public Result Update(@RequestBody EmployeeDTO employeeDTO){
log.info("开始修改员工信息");
employeeService.UPdate(employeeDTO);
return Result.success();
}
Service层接口
public void update(EmployeeDTO employeeDTO) {
Employee employee = new Employee();
BeanUtils.copyProperties(employeeDTO, employee);
employee.setUpdateTime(LocalDateTime.now());
employee.setUpdateUser(BaseContext.getCurrentId());
employeeMapper.update(employee);
}