fix: default dispatchStatus/empStatus for employee create

This commit is contained in:
pray4skylark
2026-06-05 19:37:12 +09:00
parent 9ca9d83e80
commit 40415fc6dc
2 changed files with 10 additions and 3 deletions
@@ -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);
}