Skip to content

Commit

Permalink
feat: 이동봉사 신청 취소, 승인, 반려, 봉사 완료 API 응답 추가 (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Nov 22, 2023
1 parent d8ee939 commit 8055f3a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ public ResponseEntity<ApplicationVolunteerGetOneResponse> getVolunteerOneApplica
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@DeleteMapping( "/volunteers/applications/{applicationId}")
public ResponseEntity<Void> deleteApplication(@AuthenticationPrincipal UserDetails loginUser,
@PathVariable Long applicationId) {
applicationService.deleteApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.noContent().build();
public ResponseEntity<ApplicationSuccessResponse> deleteApplication(@AuthenticationPrincipal UserDetails loginUser,
@PathVariable Long applicationId) {
ApplicationSuccessResponse response = applicationService.deleteApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.ok(response);
}

@Operation(summary = "봉사 관리 - 승인 대기중 - 이동봉사자 확인 - 봉사 신청 확정", description = "이동봉사자의 봉사 신청을 확정합니다.",
Expand All @@ -103,10 +103,10 @@ public ResponseEntity<Void> deleteApplication(@AuthenticationPrincipal UserDetai
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PatchMapping( "/intermediaries/applications/{applicationId}")
public ResponseEntity<Void> confirmApplication(@AuthenticationPrincipal UserDetails loginUser,
public ResponseEntity<ApplicationSuccessResponse> confirmApplication(@AuthenticationPrincipal UserDetails loginUser,
@PathVariable Long applicationId) {
applicationService.confirmApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.noContent().build();
ApplicationSuccessResponse response = applicationService.confirmApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.ok(response);
}

@Operation(summary = "봉사 관리 - 승인 대기중 - 이동봉사자 확인 - 봉사 신청 반려", description = "이동봉사자의 봉사 신청을 반려합니다.",
Expand All @@ -116,10 +116,10 @@ public ResponseEntity<Void> confirmApplication(@AuthenticationPrincipal UserDeta
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@DeleteMapping( "/intermediaries/applications/{applicationId}")
public ResponseEntity<Void> cancelApplication(@AuthenticationPrincipal UserDetails loginUser,
public ResponseEntity<ApplicationSuccessResponse> cancelApplication(@AuthenticationPrincipal UserDetails loginUser,
@PathVariable Long applicationId) {
applicationService.cancelApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.noContent().build();
ApplicationSuccessResponse response = applicationService.cancelApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.ok(response);
}

@Operation(summary = "봉사 관리 - 승인 대기중 목록 조회", description = "이동봉사 승인 대기중 목록을 조회합니다.",
Expand Down Expand Up @@ -206,9 +206,9 @@ public ResponseEntity<ApplicationVolunteerInfoResponse> getMyInfo(@Authenticatio
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PatchMapping( "/intermediaries/applications/{applicationId}/completed")
public ResponseEntity<Void> completeApplication(@AuthenticationPrincipal UserDetails loginUser,
public ResponseEntity<ApplicationSuccessResponse> completeApplication(@AuthenticationPrincipal UserDetails loginUser,
@PathVariable Long applicationId) {
applicationService.completeApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.noContent().build();
ApplicationSuccessResponse response = applicationService.completeApplication(loginUser.getUsername(), applicationId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pawwithu.connectdog.domain.application.dto.response;

public record ApplicationSuccessResponse(Boolean isSuccess) {
public static ApplicationSuccessResponse of(Boolean isSuccess) {
return new ApplicationSuccessResponse(isSuccess);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class ApplicationService {
private final ApplicationRepository applicationRepository;
private final CustomApplicationRepository customApplicationRepository;
private final IntermediaryRepository intermediaryRepository;
private final ReviewRepository reviewRepository;
private final DogStatusRepository dogStatusRepository;

public void volunteerApply(String email, Long postId, VolunteerApplyRequest request) {
// 이동봉사자
Expand Down Expand Up @@ -87,7 +85,7 @@ public ApplicationVolunteerGetOneResponse getVolunteerOneApplication(String emai
return oneApplication;
}

public void deleteApplication(String email, Long applicationId) {
public ApplicationSuccessResponse deleteApplication(String email, Long applicationId) {
// 이동봉사자
Volunteer volunteer = volunteerRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(VOLUNTEER_NOT_FOUND));
// 신청 내역 + post
Expand All @@ -96,9 +94,11 @@ public void deleteApplication(String email, Long applicationId) {
// 상태 업데이트 (승인 대기중 -> 모집중)
Post post = application.getPost();
post.updateStatus(PostStatus.RECRUITING);
ApplicationSuccessResponse isSuccess = ApplicationSuccessResponse.of(true);
return isSuccess;
}

public void confirmApplication(String email, Long applicationId) {
public ApplicationSuccessResponse confirmApplication(String email, Long applicationId) {
// 이동봉사 중개
Intermediary intermediary = intermediaryRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
// 신청 내역 + post
Expand All @@ -107,9 +107,11 @@ public void confirmApplication(String email, Long applicationId) {
// 상태 업데이트 (승인 대기중 -> 진행중)
application.updateStatus(ApplicationStatus.PROGRESSING);
post.updateStatus(PostStatus.PROGRESSING);
ApplicationSuccessResponse isSuccess = ApplicationSuccessResponse.of(true);
return isSuccess;
}

public void cancelApplication(String email, Long applicationId) {
public ApplicationSuccessResponse cancelApplication(String email, Long applicationId) {
// 이동봉사 중개
Intermediary intermediary = intermediaryRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
// 신청 내역 + post
Expand All @@ -118,6 +120,8 @@ public void cancelApplication(String email, Long applicationId) {
// 상태 업데이트 (승인 대기중 -> 모집중)
Post post = application.getPost();
post.updateStatus(PostStatus.RECRUITING);
ApplicationSuccessResponse isSuccess = ApplicationSuccessResponse.of(true);
return isSuccess;
}

@Transactional(readOnly = true)
Expand Down Expand Up @@ -170,7 +174,7 @@ public ApplicationVolunteerInfoResponse getMyInfo(String email) {
return volunteerInfo;
}

public void completeApplication(String email, Long applicationId) {
public ApplicationSuccessResponse completeApplication(String email, Long applicationId) {
// 이동봉사 중개
Intermediary intermediary = intermediaryRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
// 신청 내역 + post
Expand All @@ -179,5 +183,7 @@ public void completeApplication(String email, Long applicationId) {
// 상태 업데이트 (진행중 -> 봉사 완료)
application.updateStatus(ApplicationStatus.COMPLETED);
post.updateStatus(PostStatus.COMPLETED);
ApplicationSuccessResponse isSuccess = ApplicationSuccessResponse.of(true);
return isSuccess;
}
}

0 comments on commit 8055f3a

Please sign in to comment.