Skip to content

Commit

Permalink
Merge pull request #88 from WooRibound/fix/#77-admin-enterprise
Browse files Browse the repository at this point in the history
Fix/#77 admin enterprise
  • Loading branch information
cshharry authored Nov 13, 2024
2 parents 6b07ffa + 5421f01 commit 09990e6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.wooribound.global.exception;

import lombok.experimental.StandardException;

@StandardException
public class NoApproveStatusException extends RuntimeException{
public NoApproveStatusException() {
super("잘못된 기업회원 가입 승인 요청입니다. 다시 시도해주세요");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ public ResponseEntity<Object> handleDeletedUserException(DeletedUserException e,
responseBody.put("message", "deleted_user");
return new ResponseEntity<>(responseBody, HttpStatus.GONE); // 410 Gone
}

@ExceptionHandler(NotValidPasswordException.class)
public ResponseEntity<String> handleNotValidPasswordException(NotValidPasswordException e) {
return ResponseEntity.status(400).body(e.getMessage());
}


@ExceptionHandler(NoApproveStatusException.class)
public ResponseEntity<String> handleNoApproveStatusException(NoApproveStatusException e) {
return ResponseEntity.status(400).body(e.getMessage());
}
}


Expand Down

0 comments on commit 09990e6

Please sign in to comment.