Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 잘못된 Schedule ID 장소인 경우, 에러 대신 무시하도록 수정 #206

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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