| | |
| | | package com.rongyichuang.employee.dto.response; |
| | | |
| | | import com.rongyichuang.employee.entity.Employee; |
| | | import com.rongyichuang.user.entity.User; |
| | | |
| | | /** |
| | | * 员工响应DTO |
| | |
| | | private String phone; |
| | | private String roleId; |
| | | private String description; |
| | | private Integer state; |
| | | private String createTime; |
| | | private String updateTime; |
| | | |
| | | // 构造函数 |
| | | public EmployeeResponse() {} |
| | | |
| | | /** |
| | | * @deprecated 此构造函数已废弃,请使用 EmployeeResponse(Employee, User) 构造函数 |
| | | */ |
| | | @Deprecated |
| | | public EmployeeResponse(Employee employee) { |
| | | this.id = employee.getId(); |
| | | this.name = employee.getName(); |
| | | this.phone = employee.getPhone(); |
| | | this.phone = employee.getPhone(); // 这里会返回null,因为phone字段已废弃 |
| | | this.roleId = employee.getRoleId(); |
| | | this.description = employee.getDescription(); |
| | | this.state = employee.getState(); |
| | | this.createTime = employee.getCreateTime() != null ? employee.getCreateTime().toString() : null; |
| | | this.updateTime = employee.getUpdateTime() != null ? employee.getUpdateTime().toString() : null; |
| | | } |
| | | |
| | | /** |
| | | * 推荐使用的构造函数,从User对象获取phone信息 |
| | | */ |
| | | public EmployeeResponse(Employee employee, User user) { |
| | | this.id = employee.getId(); |
| | | this.name = employee.getName(); |
| | | this.phone = user != null ? user.getPhone() : null; // 从User对象获取phone |
| | | this.roleId = employee.getRoleId(); |
| | | this.description = employee.getDescription(); |
| | | this.state = employee.getState(); |
| | | this.createTime = employee.getCreateTime() != null ? employee.getCreateTime().toString() : null; |
| | | this.updateTime = employee.getUpdateTime() != null ? employee.getUpdateTime().toString() : null; |
| | | } |
| | |
| | | this.description = description; |
| | | } |
| | | |
| | | public Integer getState() { |
| | | return state; |
| | | } |
| | | |
| | | public void setState(Integer state) { |
| | | this.state = state; |
| | | } |
| | | |
| | | public String getCreateTime() { |
| | | return createTime; |
| | | } |