Skip to content

Commit

Permalink
Merge pull request #151 from mash-up-kr/hotfix/#150-place-delete-by-s…
Browse files Browse the repository at this point in the history
…chedule

hotfix: 스케줄에 해당하는 장소 삭제 로직 추가
  • Loading branch information
thguss authored Aug 15, 2024
2 parents e091e56 + 617ac0d commit cfd0ad3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.piikii.application.port.output.persistence.ScheduleQueryPort
import com.piikii.common.exception.ExceptionCode
import com.piikii.common.exception.PiikiiException
import com.piikii.output.persistence.postgresql.persistence.entity.ScheduleEntity
import com.piikii.output.persistence.postgresql.persistence.repository.PlaceRepository
import com.piikii.output.persistence.postgresql.persistence.repository.ScheduleRepository
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Repository
Expand All @@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional
@Transactional(readOnly = true)
class ScheduleAdapter(
private val scheduleRepository: ScheduleRepository,
private val placeRepository: PlaceRepository,
) : ScheduleCommandPort, ScheduleQueryPort {
@Transactional
override fun saveSchedules(schedules: List<Schedule>) {
Expand All @@ -27,6 +29,7 @@ class ScheduleAdapter(

@Transactional
override fun deleteSchedules(scheduleIds: List<LongTypeId>) {
placeRepository.deleteByScheduleIdIn(scheduleIds.map { it.getValue() })
scheduleRepository.deleteAll(
scheduleIds.map { findScheduleEntityById(it) },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ interface PlaceRepository : JpaRepository<PlaceEntity, Long> {
scheduleId: Long,
confirmed: Boolean,
): List<PlaceEntity>

fun deleteByScheduleIdIn(scheduleIds: List<Long>)
}

0 comments on commit cfd0ad3

Please sign in to comment.