diff --git a/src/main/java/com/wooribound/domain/admin/AdminServiceImpl.java b/src/main/java/com/wooribound/domain/admin/AdminServiceImpl.java index 55280ad..ba26f82 100644 --- a/src/main/java/com/wooribound/domain/admin/AdminServiceImpl.java +++ b/src/main/java/com/wooribound/domain/admin/AdminServiceImpl.java @@ -4,6 +4,7 @@ import com.wooribound.domain.admin.dto.AdminDTO; import com.wooribound.domain.enterprise.EnterpriseRepository; import com.wooribound.global.constant.YN; +import com.wooribound.global.exception.NoApproveStatusException; import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; @@ -25,6 +26,9 @@ public void create(AdminDTO adminDTO) { @Override public String joinApprove(AdminApproveReqDTO adminApproveReqDTO) { + if (adminApproveReqDTO.getApprove() == null) + throw new NoApproveStatusException(); + // 기업 회원가입을 반려할 때 if (adminApproveReqDTO.getApprove() == YN.N) { if (enterpriseRepository.deleteByEntId(adminApproveReqDTO.getEntId()) == 1) @@ -43,6 +47,9 @@ public String joinApprove(AdminApproveReqDTO adminApproveReqDTO) { @Override public String deleteApprove(AdminApproveReqDTO adminApproveReqDTO) { + if (adminApproveReqDTO.getApprove() == null) + throw new NoApproveStatusException(); + // 기업 회원탈퇴를 승인할 때 if (adminApproveReqDTO.getApprove() == YN.Y) { if (enterpriseRepository.updateIsDeleted(adminApproveReqDTO.getEntId()) == 1) diff --git a/src/main/java/com/wooribound/global/exception/NoApproveStatusException.java b/src/main/java/com/wooribound/global/exception/NoApproveStatusException.java new file mode 100644 index 0000000..17646e4 --- /dev/null +++ b/src/main/java/com/wooribound/global/exception/NoApproveStatusException.java @@ -0,0 +1,10 @@ +package com.wooribound.global.exception; + +import lombok.experimental.StandardException; + +@StandardException +public class NoApproveStatusException extends RuntimeException{ + public NoApproveStatusException() { + super("잘못된 기업회원 가입 승인 요청입니다. 다시 시도해주세요"); + } +} diff --git a/src/main/java/com/wooribound/global/handler/GlobalExceptionHandler.java b/src/main/java/com/wooribound/global/handler/GlobalExceptionHandler.java index cd5b826..bde29f1 100644 --- a/src/main/java/com/wooribound/global/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/wooribound/global/handler/GlobalExceptionHandler.java @@ -89,12 +89,16 @@ public ResponseEntity handleDeletedUserException(DeletedUserException e, responseBody.put("message", "deleted_user"); return new ResponseEntity<>(responseBody, HttpStatus.GONE); // 410 Gone } + @ExceptionHandler(NotValidPasswordException.class) public ResponseEntity handleNotValidPasswordException(NotValidPasswordException e) { return ResponseEntity.status(400).body(e.getMessage()); } - + @ExceptionHandler(NoApproveStatusException.class) + public ResponseEntity handleNoApproveStatusException(NoApproveStatusException e) { + return ResponseEntity.status(400).body(e.getMessage()); + } }