Skip to content

Commit

Permalink
add: (#249) 휴무표 작성 기간 확인 UseCase
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Dec 22, 2022
1 parent e6a600f commit a3dfb62
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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("휴무표 작성 기간이 아닙니다.")
}
}

}

0 comments on commit a3dfb62

Please sign in to comment.