-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...src/main/kotlin/team/comit/simtong/domain/schedule/dto/ChangeIndividualScheduleRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
53 changes: 53 additions & 0 deletions
53
...main/kotlin/team/comit/simtong/domain/schedule/usecase/ChangeIndividualScheduleUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
) | ||
} | ||
|
||
} |