Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public interface ApplicationRepository extends JpaRepository<Application, Long>
Optional<Application> findByPostIdAndStatusNot(Long postId, ApplicationStatus status);
void deleteAllByPostId(Long postId);
List<Application> findByIntermediary(Intermediary intermediary);

Boolean existsByVolunteerAndStatusIn(Volunteer volunteer, List<ApplicationStatus> statuses);
Boolean existsByIntermediaryAndStatusIn(Intermediary intermediary, List<ApplicationStatus> statuses);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@Tag(name = "Auth", description = "Auth API")
@RestController
Expand Down Expand Up @@ -155,4 +152,27 @@ public ResponseEntity<IntermediaryEmailWithAuthResponse> sendEmailToIntermediary
return ResponseEntity.ok(response);
}

@Operation(summary = "이동봉사자 - 탈퇴 - 승인 대기중, 진행중 공고 존재 여부 확인", description = "승인 대기중, 진행중 공고 존재 여부를 확인합니다.",
responses = {@ApiResponse(responseCode = "200", description = "승인 대기중, 진행중 공고 존재 여부 확인 성공")
, @ApiResponse(responseCode = "400"
, description = "M1, 해당 이동봉사자를 찾을 수 없습니다."
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping( "/volunteers/my/check")
public ResponseEntity<Boolean> checkVolunteerWithdraw(@AuthenticationPrincipal UserDetails loginUser) {
Boolean response = authService.checkVolunteerWithdraw(loginUser.getUsername());
return ResponseEntity.ok(response);
}

@Operation(summary = "중개자 - 탈퇴 - 승인 대기중, 진행중 공고 존재 여부 확인", description = "승인 대기중, 진행중 공고 존재 여부를 확인합니다.",
responses = {@ApiResponse(responseCode = "200", description = "승인 대기중, 진행중 공고 존재 여부 확인 성공")
, @ApiResponse(responseCode = "400"
, description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다."
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping( "/intermediaries/my/check")
public ResponseEntity<Boolean> checkIntermediaryWithdraw(@AuthenticationPrincipal UserDetails loginUser) {
Boolean response = authService.checkIntermediaryWithdraw(loginUser.getUsername());
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.pawwithu.connectdog.common.s3.FileService;
import com.pawwithu.connectdog.domain.application.entity.Application;
import com.pawwithu.connectdog.domain.application.entity.ApplicationStatus;
import com.pawwithu.connectdog.domain.application.repository.ApplicationRepository;
import com.pawwithu.connectdog.domain.auth.dto.request.*;
import com.pawwithu.connectdog.domain.auth.dto.response.*;
Expand Down Expand Up @@ -258,4 +259,18 @@ public IntermediaryEmailResponse findIntermediaryEmail(IntermediaryPhoneRequest
IntermediaryEmailResponse response = IntermediaryEmailResponse.of(intermediary.getEmail());
return response;
}

@Transactional(readOnly = true)
public Boolean checkVolunteerWithdraw(String email) {
Volunteer volunteer = volunteerRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(VOLUNTEER_NOT_FOUND));
Boolean response = applicationRepository.existsByVolunteerAndStatusIn(volunteer, List.of(ApplicationStatus.WAITING, ApplicationStatus.PROGRESSING));
return !response;
}

@Transactional(readOnly = true)
public Boolean checkIntermediaryWithdraw(String email) {
Intermediary intermediary = intermediaryRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
Boolean response = applicationRepository.existsByIntermediaryAndStatusIn(intermediary, List.of(ApplicationStatus.WAITING, ApplicationStatus.PROGRESSING));
return !response;
}
}
Loading