Skip to content

Commit

Permalink
add: (#156) 개인 일정 변경 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Nov 27, 2022
1 parent e593713 commit e2bab71
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package team.comit.simtong.domain.schedule.dto

import java.time.LocalDate
import java.time.LocalTime
import java.util.UUID

/**
*
* 개인 일정 변경 요청 정보를 전달하는 ChangeIndividualScheduleRequest
*
* @author Chokyunghyeon
* @date 2022/11/27
* @version 1.0.0
**/
data class ChangeIndividualScheduleRequest(

val scheduleId: UUID,

val title: String,

val startAt: LocalDate,

val endAt: LocalDate,

val alarm: LocalTime
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package team.comit.simtong.domain.schedule.usecase

import team.comit.simtong.domain.schedule.dto.ChangeIndividualScheduleRequest
import team.comit.simtong.domain.schedule.exception.ScheduleNotFoundException
import team.comit.simtong.domain.schedule.spi.CommandSchedulePort
import team.comit.simtong.domain.schedule.spi.QuerySchedulePort
import team.comit.simtong.domain.schedule.spi.ScheduleQueryUserPort
import team.comit.simtong.domain.schedule.spi.ScheduleSecurityPort
import team.comit.simtong.domain.spot.exception.DifferentSpotException
import team.comit.simtong.domain.user.exception.UserNotFoundException
import team.comit.simtong.global.annotation.UseCase

/**
*
* 개인 일정 정보 변경 요청을 담당하는 ChangeIndividualScheduleUseCase
*
* @author Chokyunghyeon
* @date 2022/11/27
* @version 1.0.0
**/
@UseCase
class ChangeIndividualScheduleUseCase(
private val queryUserPort: ScheduleQueryUserPort,
private val querySchedulePort: QuerySchedulePort,
private val commandSchedulePort: CommandSchedulePort,
private val securityPort: ScheduleSecurityPort
) {

fun execute(request: ChangeIndividualScheduleRequest) {
val currentUserId = securityPort.getCurrentUserId()
val (scheduleId, title, startAt, endAt, alarm) = request

val schedule = querySchedulePort.queryScheduleById(scheduleId)
?: throw ScheduleNotFoundException.EXCEPTION

val user = queryUserPort.queryUserById(currentUserId)
?: throw UserNotFoundException.EXCEPTION

if (user.spotId != schedule.spotId) {
throw DifferentSpotException.EXCEPTION
}

commandSchedulePort.save(
schedule.copy(
title = title,
startAt = startAt,
endAt = endAt,
alarmTime = alarm
)
)
}

}

0 comments on commit e2bab71

Please sign in to comment.