diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCase.kt new file mode 100644 index 00000000..e1960a6b --- /dev/null +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCase.kt @@ -0,0 +1,35 @@ +package team.comit.simtong.domain.holiday.usecase + +import team.comit.simtong.domain.holiday.exception.HolidayExceptions +import team.comit.simtong.domain.holiday.spi.HolidayQueryUserPort +import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort +import team.comit.simtong.domain.holiday.spi.QueryHolidayPeriodPort +import team.comit.simtong.domain.user.exception.UserExceptions +import team.comit.simtong.global.annotation.ReadOnlyUseCase +import java.time.LocalDate + +/** + * + * 휴무일 작성 기간인지 확인을 담당하는 CheckHolidayPeriodUseCase + * + * @author Chokyunghyeon + * @date 2022/12/22 + * @version 1.0.0 + **/ +@ReadOnlyUseCase +class CheckHolidayPeriodUseCase( + private val queryHolidayPeriodPort: QueryHolidayPeriodPort, + private val queryUserPort: HolidayQueryUserPort, + private val securityPort: HolidaySecurityPort +) { + + fun execute() { + val user = queryUserPort.queryUserById(securityPort.getCurrentUserId()) + ?: throw UserExceptions.NotFound() + + if (!queryHolidayPeriodPort.existsHolidayPeriodByDateAndSpotId(LocalDate.now(), user.spotId)) { + throw HolidayExceptions.NotFound("휴무표 작성 기간이 아닙니다.") + } + } + +} \ No newline at end of file