苍穹外卖--员工管理--编辑员工功能实现

This commit is contained in:
2025-11-10 13:50:08 +08:00
parent 7554054fe7
commit 1241b73752
5 changed files with 49 additions and 1 deletions

View File

@@ -108,4 +108,21 @@ public class EmployeeController {
return Result.success();
}
@ApiOperation("根据ID查询员工")
@GetMapping("/{id}")
public Result<Employee> getById(@PathVariable Long id){
log.info("根据ID查询员工:{}",id);
Employee employee = employeeService.getById(id);
return Result.success(employee);
}
@ApiOperation("编辑员工")
@PutMapping
public Result update(@RequestBody EmployeeDTO employeeDTO){
log.info("编辑员工:{}",employeeDTO);
employeeService.update(employeeDTO);
return Result.success();
}
}

View File

@@ -29,4 +29,7 @@ public interface EmployeeMapper {
Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);
void update(Employee employee);
@Select("select * from employee where id = #{id}")
Employee getById(Long id);
}

View File

@@ -31,4 +31,14 @@ public interface EmployeeService {
启用禁用员工账号
*/
void startOrStop(Integer status, Long id);
/*
根据ID查询员工
*/
Employee getById(Long id);
/*
编辑员工
*/
void update(EmployeeDTO employeeDTO);
}

View File

@@ -132,4 +132,22 @@ public class EmployeeServiceImpl implements EmployeeService {
employeeMapper.update(employee);
}
@Override
public Employee getById(Long id) {
Employee employee = employeeMapper.getById(id);
employee.setPassword("****");
return employee;
}
@Override
public void update(EmployeeDTO employeeDTO) {
Employee employee = new Employee();
//属性拷贝
BeanUtils.copyProperties(employeeDTO,employee);
//补充属性
employee.setUpdateUser(BaseContext.getCurrentId());
employee.setUpdateTime(LocalDateTime.now());
employeeMapper.update(employee);
}
}

View File

@@ -34,6 +34,6 @@ sky:
# 设置jwt签名加密时使用的秘钥
admin-secret-key: inmind
# 设置jwt过期时间
admin-ttl: 7200000
admin-ttl: 72000000
# 设置前端传递过来的令牌名称
admin-token-name: token