diff --git a/backend/src/main/java/com/srsystem/exception/ErrorCode.java b/backend/src/main/java/com/srsystem/exception/ErrorCode.java index d9cf3bb..0e86c05 100644 --- a/backend/src/main/java/com/srsystem/exception/ErrorCode.java +++ b/backend/src/main/java/com/srsystem/exception/ErrorCode.java @@ -27,7 +27,8 @@ public enum ErrorCode { DUPLICATE_GROUP_CODE(HttpStatus.CONFLICT, "COD_ERR_002", "이미 존재하는 그룹 코드입니다"), GROUP_HAS_CODES(HttpStatus.BAD_REQUEST, "COD_ERR_003", "그룹에 속한 코드가 있어 삭제할 수 없습니다"), PLAN_NOT_FOUND(HttpStatus.NOT_FOUND, "PLN_ERR_001", "주간 계획을 찾을 수 없습니다"), - INVALID_STATUS(HttpStatus.BAD_REQUEST, "TCK_ERR_004", "처리할 수 없는 상태입니다"); + INVALID_STATUS(HttpStatus.BAD_REQUEST, "TCK_ERR_004", "처리할 수 없는 상태입니다"), + INVALID_INPUT_VALUE(HttpStatus.BAD_REQUEST, "SYS_ERR_002", "필수 입력값이 누락되었거나 올바르지 않습니다"); private final HttpStatus httpStatus; private final String errorCode; diff --git a/backend/src/main/java/com/srsystem/service/EmployeeService.java b/backend/src/main/java/com/srsystem/service/EmployeeService.java index ab006d1..f514e58 100644 --- a/backend/src/main/java/com/srsystem/service/EmployeeService.java +++ b/backend/src/main/java/com/srsystem/service/EmployeeService.java @@ -83,14 +83,24 @@ public class EmployeeService { @Transactional public Employee create(Employee employee) { - if (employee.getEmail() != null && employeeRepository.findByEmail(employee.getEmail()).isPresent()) { + if (employee.getLoginId() == null || employee.getLoginId().isBlank()) { + throw new BusinessException(ErrorCode.INVALID_INPUT_VALUE); + } + if (employeeRepository.findByLoginId(employee.getLoginId()).isPresent()) { + throw new BusinessException(ErrorCode.DUPLICATE_LOGIN_ID); + } + if (employee.getEmail() != null && !employee.getEmail().isBlank() && employeeRepository.findByEmail(employee.getEmail()).isPresent()) { 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())); + String rawPassword = employee.getPassword(); + if (rawPassword == null || rawPassword.isBlank()) { + rawPassword = "admin123"; + } + employee.setPassword(passwordEncoder.encode(rawPassword)); try { return employeeRepository.save(employee); } catch (DataIntegrityViolationException e) { diff --git a/backend/src/main/java/com/srsystem/util/PhoneEncryptionConverter.java b/backend/src/main/java/com/srsystem/util/PhoneEncryptionConverter.java index a8fb59f..ce2011c 100644 --- a/backend/src/main/java/com/srsystem/util/PhoneEncryptionConverter.java +++ b/backend/src/main/java/com/srsystem/util/PhoneEncryptionConverter.java @@ -24,7 +24,20 @@ public class PhoneEncryptionConverter implements AttributeConverter