Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
[Feat] 여행지 등록 시 Policy 조건 추가
Browse files Browse the repository at this point in the history
`+` SpaceService
  • Loading branch information
NoJaeHyuk committed Jan 24, 2024
1 parent 8207a2a commit f9b38c9
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ public JourneysResponse getJourneyForSpace(Long spaceId, Long memberId) {

validateJoinedMember(space, requestMember);

List<Journey> journeys = journeyRepository.findAllBySpaceOrderByDateAsc(
space);
List<Journey> journeys = journeyRepository.findAllBySpaceOrderByDateAsc(space);

return JourneysResponse.from(journeys);
}
Expand All @@ -186,6 +185,7 @@ public JourneyResponse selectedPlacesForSpace(Long spaceId, Long memberId, Selec
.orElseThrow(() -> new SpaceException(JOURNEY_NOT_FOUND));

List<SelectedPlace> selectedPlaces = insertSelectedPlace(request, journey);

journey.addSelectedPlace(selectedPlaces);

return JourneyResponse.from(journey);
Expand Down Expand Up @@ -253,6 +253,10 @@ private void deleteJourneys(DateUpdateRequest updateRequest, Space space, int da
private List<SelectedPlace> insertSelectedPlace(SelectedPlaceRequest selectedPlaceRequest, Journey journey) {
int lastOrder = journey.getPlace().size();

if (lastOrder + selectedPlaceRequest.selectedPlaces().size() > 30) {
throw new SpaceException(SELECTED_PLACES_COUNT_OVER);
}

List<SelectedPlace> selectedPlaces = new ArrayList<>();

for (Integer id : selectedPlaceRequest.selectedPlaces()) {
Expand Down

0 comments on commit f9b38c9

Please sign in to comment.