Skip to content

Commit

Permalink
Merge pull request #206 from mash-up-kr/feature/wrong-schedule-ignore
Browse files Browse the repository at this point in the history
feat: 잘못된 Schedule ID 장소인 경우, 에러 대신 무시하도록 수정
  • Loading branch information
KimDoubleB authored Oct 3, 2024
2 parents d90e8b9 + e4dbccf commit 4ce2bef
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import com.piikii.application.port.output.persistence.PlaceCommandPort
import com.piikii.application.port.output.persistence.PlaceQueryPort
import com.piikii.application.port.output.persistence.RoomQueryPort
import com.piikii.application.port.output.persistence.ScheduleQueryPort
import com.piikii.common.exception.ExceptionCode
import com.piikii.common.exception.PiikiiException
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import org.springframework.web.multipart.MultipartFile
Expand Down Expand Up @@ -54,14 +52,15 @@ class PlaceService(
override fun findAllByRoomUidGroupByPlaceType(roomUid: UuidTypeId): List<ScheduleTypeGroupResponse> {
val scheduleById = scheduleQueryPort.findAllByRoomUid(roomUid).associateBy { it.id }
return placeQueryPort.findAllByRoomUid(roomUid).groupBy { it.scheduleId }
.map { (scheduleId, places) ->
val schedule = scheduleById[scheduleId] ?: throw PiikiiException(ExceptionCode.NOT_FOUNDED)
ScheduleTypeGroupResponse(
scheduleId = scheduleId.getValue(),
scheduleName = schedule.name,
type = schedule.type,
places = places.map { place -> PlaceResponse(place = place) },
)
.mapNotNull { (scheduleId, places) ->
scheduleById[scheduleId]?.let { schedule ->
ScheduleTypeGroupResponse(
scheduleId = scheduleId.getValue(),
scheduleName = schedule.name,
type = schedule.type,
places = places.map { place -> PlaceResponse(place = place) },
)
}
}
}

Expand Down

0 comments on commit 4ce2bef

Please sign in to comment.