Skip to content

Commit

Permalink
hotfix : 호스트 정보 조회 api 에러상황 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
bo-ram-bo-ram committed Sep 17, 2024
1 parent fe83c28 commit 3b396d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.pickple.server.api.host.service;

import com.pickple.server.api.guest.domain.Guest;
import com.pickple.server.api.guest.repository.GuestRepository;
import com.pickple.server.api.host.domain.Host;
import com.pickple.server.api.host.dto.response.HostByMoimResponse;
import com.pickple.server.api.host.dto.response.HostGetResponse;
Expand All @@ -8,7 +10,6 @@
import com.pickple.server.api.moim.domain.Moim;
import com.pickple.server.api.moim.repository.MoimRepository;
import com.pickple.server.api.moimsubmission.repository.MoimSubmissionRepository;
import com.pickple.server.api.submitter.domain.Submitter;
import com.pickple.server.api.submitter.repository.SubmitterRepository;
import com.pickple.server.global.exception.BadRequestException;
import com.pickple.server.global.response.enums.ErrorCode;
Expand All @@ -27,10 +28,12 @@ public class HostQueryService {
private final MoimRepository moimRepository;
private final MoimSubmissionRepository moimSubmissionRepository;
private final SubmitterRepository submitterRepository;
private final GuestRepository guestRepository;

public HostGetResponse getHost(Long hostId, Long guestId) {
Submitter submitter = submitterRepository.findSubmitterByGuestIdOrThrow(guestId);
isDuplicatedSubmission(submitter);
Guest guest = guestRepository.findGuestByIdOrThrow(guestId);

isDuplicatedSubmission(guest);

Host host = hostRepository.findHostByIdOrThrow(hostId);

Expand Down Expand Up @@ -84,8 +87,8 @@ private int moimCounter(Long hostId) {
return moimRepository.CompletedMoimNumber(hostId);
}

private void isDuplicatedSubmission(Submitter submitter) {
if (submitterRepository.existsByGuestAndSubmitterState(submitter.getGuest(), submitter.getSubmitterState())) {
private void isDuplicatedSubmission(Guest guest) {
if (submitterRepository.existsByGuestAndSubmitterState(guest, "pending")) {
throw new BadRequestException(ErrorCode.DUPLICATION_SUBMITTER);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,4 @@ default Submitter findSubmitterByIdOrThrow(Long id) {

boolean existsByNickname(String nickname);

Optional<Submitter> findSubmitterByGuestId(Long guestId);

default Submitter findSubmitterByGuestIdOrThrow(Long guestId) {
return findSubmitterByGuestId(guestId)
.orElseThrow(() -> new CustomException(ErrorCode.SUBMITTER_NOT_FOUND));
}

}

0 comments on commit 3b396d2

Please sign in to comment.