Skip to content

Commit 8743f59

Browse files
authored
Merge pull request #253 from PawWithU/feat/252-waiting-progressing-exist-api
[Feature] 봉사자, 중개자 승인대기중, 진행중 공고 존재 확인 API 구현
2 parents 2a49e65 + 26d2ed5 commit 8743f59

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

src/main/java/com/pawwithu/connectdog/domain/application/repository/ApplicationRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ public interface ApplicationRepository extends JpaRepository<Application, Long>
2020
Optional<Application> findByPostIdAndStatusNot(Long postId, ApplicationStatus status);
2121
void deleteAllByPostId(Long postId);
2222
List<Application> findByIntermediary(Intermediary intermediary);
23-
23+
Boolean existsByVolunteerAndStatusIn(Volunteer volunteer, List<ApplicationStatus> statuses);
24+
Boolean existsByIntermediaryAndStatusIn(Intermediary intermediary, List<ApplicationStatus> statuses);
2425
}

src/main/java/com/pawwithu/connectdog/domain/auth/controller/AuthController.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
import org.springframework.http.ResponseEntity;
2626
import org.springframework.security.core.annotation.AuthenticationPrincipal;
2727
import org.springframework.security.core.userdetails.UserDetails;
28-
import org.springframework.web.bind.annotation.DeleteMapping;
29-
import org.springframework.web.bind.annotation.PostMapping;
30-
import org.springframework.web.bind.annotation.RequestBody;
31-
import org.springframework.web.bind.annotation.RestController;
28+
import org.springframework.web.bind.annotation.*;
3229

3330
@Tag(name = "Auth", description = "Auth API")
3431
@RestController
@@ -155,4 +152,27 @@ public ResponseEntity<IntermediaryEmailWithAuthResponse> sendEmailToIntermediary
155152
return ResponseEntity.ok(response);
156153
}
157154

155+
@Operation(summary = "이동봉사자 - 탈퇴 - 승인 대기중, 진행중 공고 존재 여부 확인", description = "승인 대기중, 진행중 공고 존재 여부를 확인합니다.",
156+
responses = {@ApiResponse(responseCode = "200", description = "승인 대기중, 진행중 공고 존재 여부 확인 성공")
157+
, @ApiResponse(responseCode = "400"
158+
, description = "M1, 해당 이동봉사자를 찾을 수 없습니다."
159+
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
160+
})
161+
@GetMapping( "/volunteers/my/check")
162+
public ResponseEntity<Boolean> checkVolunteerWithdraw(@AuthenticationPrincipal UserDetails loginUser) {
163+
Boolean response = authService.checkVolunteerWithdraw(loginUser.getUsername());
164+
return ResponseEntity.ok(response);
165+
}
166+
167+
@Operation(summary = "중개자 - 탈퇴 - 승인 대기중, 진행중 공고 존재 여부 확인", description = "승인 대기중, 진행중 공고 존재 여부를 확인합니다.",
168+
responses = {@ApiResponse(responseCode = "200", description = "승인 대기중, 진행중 공고 존재 여부 확인 성공")
169+
, @ApiResponse(responseCode = "400"
170+
, description = "M2, 해당 이동봉사 중개를 찾을 수 없습니다."
171+
, content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
172+
})
173+
@GetMapping( "/intermediaries/my/check")
174+
public ResponseEntity<Boolean> checkIntermediaryWithdraw(@AuthenticationPrincipal UserDetails loginUser) {
175+
Boolean response = authService.checkIntermediaryWithdraw(loginUser.getUsername());
176+
return ResponseEntity.ok(response);
177+
}
158178
}

src/main/java/com/pawwithu/connectdog/domain/auth/service/AuthService.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.pawwithu.connectdog.common.s3.FileService;
44
import com.pawwithu.connectdog.domain.application.entity.Application;
5+
import com.pawwithu.connectdog.domain.application.entity.ApplicationStatus;
56
import com.pawwithu.connectdog.domain.application.repository.ApplicationRepository;
67
import com.pawwithu.connectdog.domain.auth.dto.request.*;
78
import com.pawwithu.connectdog.domain.auth.dto.response.*;
@@ -258,4 +259,18 @@ public IntermediaryEmailResponse findIntermediaryEmail(IntermediaryPhoneRequest
258259
IntermediaryEmailResponse response = IntermediaryEmailResponse.of(intermediary.getEmail());
259260
return response;
260261
}
262+
263+
@Transactional(readOnly = true)
264+
public Boolean checkVolunteerWithdraw(String email) {
265+
Volunteer volunteer = volunteerRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(VOLUNTEER_NOT_FOUND));
266+
Boolean response = applicationRepository.existsByVolunteerAndStatusIn(volunteer, List.of(ApplicationStatus.WAITING, ApplicationStatus.PROGRESSING));
267+
return !response;
268+
}
269+
270+
@Transactional(readOnly = true)
271+
public Boolean checkIntermediaryWithdraw(String email) {
272+
Intermediary intermediary = intermediaryRepository.findByEmail(email).orElseThrow(() -> new BadRequestException(INTERMEDIARY_NOT_FOUND));
273+
Boolean response = applicationRepository.existsByIntermediaryAndStatusIn(intermediary, List.of(ApplicationStatus.WAITING, ApplicationStatus.PROGRESSING));
274+
return !response;
275+
}
261276
}

0 commit comments

Comments
 (0)