tlias管理系统--员工管理--修改员工-查询回显功能

This commit is contained in:
2025-11-23 15:44:48 +08:00
parent edfed44518
commit 2292c6a75a
4 changed files with 38 additions and 0 deletions

View File

@@ -51,4 +51,14 @@ public class EmpController {
empService.save(emp);
return Result.success();
}
/*
查询回显功能
*/
@GetMapping("/{id}")
public Result getEmpById(@PathVariable Integer id){
log.info("根据id查询员工{}",id);
Emp emp = empService.getEmpById(id);
return Result.success(emp);
}
}

View File

@@ -48,4 +48,12 @@ public interface EmpMapper {
@Insert("insert into emp(username,name,gender,image,job,entrydate,create_time,update_time) " +
"values(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{createTime},#{updateTime})")
void save(Emp emp);
/**
* 根据id查询员工
* @param id
* @return
*/
@Select("select * from emp where id = #{id}")
Emp getEmpById(Integer id);
}

View File

@@ -31,4 +31,12 @@ public interface EmpService {
* @param emp
*/
void save(Emp emp);
/**
* 根据id查询员工
* @param id
* @return
*/
Emp getEmpById(Integer id);
}

View File

@@ -89,4 +89,16 @@ public class EmpServiceImpl implements EmpService {
emp.setUpdateTime(LocalDateTime.now());
empMapper.save(emp);
}
/**
* 根据id查询员工
* @param id
* @return
*/
@Override
public Emp getEmpById(Integer id) {
/* Emp emp = empMapper.getEmpById(id);
return emp;*/
return empMapper.getEmpById(id);
}
}