fix: default dispatchStatus/empStatus for employee create
This commit is contained in:
@@ -44,17 +44,20 @@ public class Employee extends BaseEntity {
|
||||
@Column(name = "phone", length = 20)
|
||||
private String phone;
|
||||
|
||||
@Builder.Default
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "role_code", nullable = false, length = 20)
|
||||
private RoleCode roleCode;
|
||||
private RoleCode roleCode = RoleCode.EMPLOYEE;
|
||||
|
||||
@Builder.Default
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "emp_status", nullable = false, length = 20)
|
||||
private EmpStatus empStatus;
|
||||
private EmpStatus empStatus = EmpStatus.ACTIVE;
|
||||
|
||||
@Builder.Default
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "dispatch_status", nullable = false, length = 20)
|
||||
private DispatchStatus dispatchStatus;
|
||||
private DispatchStatus dispatchStatus = DispatchStatus.WAITING;
|
||||
|
||||
@Column(name = "joined_date")
|
||||
private LocalDate joinedDate;
|
||||
|
||||
@@ -80,6 +80,10 @@ public class EmployeeService {
|
||||
throw new BusinessException(ErrorCode.DUPLICATE_LOGIN_ID);
|
||||
}
|
||||
|
||||
if (employee.getRoleCode() == null) employee.setRoleCode(RoleCode.EMPLOYEE);
|
||||
if (employee.getEmpStatus() == null) employee.setEmpStatus(EmpStatus.ACTIVE);
|
||||
if (employee.getDispatchStatus() == null) employee.setDispatchStatus(DispatchStatus.WAITING);
|
||||
|
||||
employee.setPassword(passwordEncoder.encode(employee.getPassword()));
|
||||
return employeeRepository.save(employee);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user