Skip to content

Commit

Permalink
feat: ignore when wrong schedule id
Browse files Browse the repository at this point in the history
  • Loading branch information
KimDoubleB committed Oct 3, 2024
1 parent d90e8b9 commit 3de26a4
Showing 1 changed file with 16 additions and 18 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 All @@ -85,14 +84,13 @@ class PlaceService(
return PlaceResponse(
placeCommandPort.update(
targetPlaceId = targetPlaceId,
place =
modifyPlaceRequest.toDomain(
targetPlaceId,
targetRoomUid,
place.origin,
LongTypeId(modifyPlaceRequest.scheduleId),
filterDuplicateUrls(updatedUrls, modifyPlaceRequest.deleteTargetUrls, place),
),
place = modifyPlaceRequest.toDomain(
targetPlaceId,
targetRoomUid,
place.origin,
LongTypeId(modifyPlaceRequest.scheduleId),
filterDuplicateUrls(updatedUrls, modifyPlaceRequest.deleteTargetUrls, place),
),
),
)
}
Expand Down

0 comments on commit 3de26a4

Please sign in to comment.