编辑员工信息

This commit is contained in:
bunny 2024-01-05 23:56:39 +08:00
parent b94e61e388
commit e7d6f8bd2f
4 changed files with 55 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import com.sky.vo.EmployeeLoginVO;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -130,4 +131,12 @@ public class EmployeeController {
Employee employee = employeeService.getById(id);
return Result.success(employee);
}
@Operation(summary = "编辑员工信息")
@PutMapping()
public Result update(@RequestBody EmployeeDTO employeeDTO) {
log.info("编辑员工信息:{}", employeeDTO);
employeeService.update(employeeDTO);
return Result.success();
}
}

View File

@ -41,4 +41,10 @@ public interface EmployeeService {
* @return Employee
*/
Employee getById(Integer id);
/**
* 编辑员工信息
* @param employeeDTO EmployeeDTO
*/
void update(EmployeeDTO employeeDTO);
}

View File

@ -141,4 +141,19 @@ public class EmployeeServiceImpl implements EmployeeService {
employee.setPassword("密码?你也想看?");
return employee;
}
/**
* 编辑员工信息
* @param employeeDTO EmployeeDTO
*/
@Override
public void update(EmployeeDTO employeeDTO) {
Employee employee = new Employee();
BeanUtils.copyProperties(employeeDTO, employee);
employee.setUpdateTime(LocalDateTime.now());
employee.setUpdateUser(BaseContext.getCurrentId());
employeeMapper.update(employee);
}
}

View File

@ -15,8 +15,32 @@
<update id="update" parameterType="Employee">
update employee
<set>
<if test="name != null">
name = #{name},
</if>
<if test="username != null">
username = #{username},
</if>
<if test="password != null">
password = #{password},
</if>
<if test="phone != null">
phone = #{phone},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="idNumber != null">
id_number = #{idNumber},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="updateUser != null">
update_user = #{updateUser},
</if>
<if test="status != null">
status =#{status}
status =#{status},
</if>
</set>
where id=#{id}