-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] 게스트에 해당하는 신청한 모임 조회 API 구현
- Loading branch information
Showing
10 changed files
with
97 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/pickple/server/api/moim/dto/response/SubmittedMoimByGuestResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.pickple.server.api.moim.dto.response; | ||
|
||
import com.pickple.server.api.moim.domain.DateInfo; | ||
import com.pickple.server.api.moimsubmission.domain.MoimSubmissionState; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record SubmittedMoimByGuestResponse( | ||
Long moimId, | ||
MoimSubmissionState moimSubmissionState, | ||
String title, | ||
String hostNickname, | ||
DateInfo dateList, | ||
int fee, | ||
String imageUrl | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
4 changes: 2 additions & 2 deletions
4
...m/dto/response/SubmittedMoimResponse.java → ...esponse/SubmittedMoimByGuestResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/pickple/server/api/moimsubmission/service/MoimSubmissionQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.pickple.server.api.moimsubmission.service; | ||
|
||
import com.pickple.server.api.guest.domain.Guest; | ||
import com.pickple.server.api.guest.repository.GuestRepository; | ||
import com.pickple.server.api.moim.dto.response.SubmittedMoimByGuestResponse; | ||
import com.pickple.server.api.moimsubmission.domain.MoimSubmission; | ||
import com.pickple.server.api.moimsubmission.domain.MoimSubmissionState; | ||
import com.pickple.server.api.moimsubmission.repository.MoimSubmissionRepository; | ||
import com.pickple.server.global.exception.CustomException; | ||
import com.pickple.server.global.response.enums.ErrorCode; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class MoimSubmissionQueryService { | ||
|
||
private final GuestRepository guestRepository; | ||
private final MoimSubmissionRepository moimSubmissionRepository; | ||
|
||
public List<SubmittedMoimByGuestResponse> getSubmittedMoimListByGuest(final Long guestId, | ||
final MoimSubmissionState moimSubmissionState) { | ||
Guest guest = guestRepository.findGuestByIdOrThrow(guestId); | ||
List<MoimSubmission> moimSubmissionList; | ||
|
||
if (moimSubmissionState.equals(MoimSubmissionState.ALL)) { | ||
moimSubmissionList = moimSubmissionRepository.findAllByGuestId(guest.getId()); | ||
} else { | ||
moimSubmissionList = moimSubmissionRepository.findAllByMoimSubmissionState(moimSubmissionState); | ||
} | ||
|
||
if (moimSubmissionList.isEmpty()) { | ||
throw new CustomException(ErrorCode.MOIM_BY_STATE_NOT_FOUND); | ||
} | ||
|
||
return moimSubmissionList.stream() | ||
.map(oneMoimSubmission -> SubmittedMoimByGuestResponse.builder() | ||
.moimId(oneMoimSubmission.getMoim().getId()) | ||
.moimSubmissionState(oneMoimSubmission.getMoimSubmissionState()) | ||
.title(oneMoimSubmission.getMoim().getTitle()) | ||
.hostNickname(oneMoimSubmission.getMoim().getHost().getNickname()) | ||
.dateList(oneMoimSubmission.getMoim().getDateList()) | ||
.fee(oneMoimSubmission.getMoim().getFee()) | ||
.imageUrl(oneMoimSubmission.getMoim().getImageList().getImageUrl1()) | ||
.build()) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters