-
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
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...on/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/CheckHolidayPeriodUseCase.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,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("휴무표 작성 기간이 아닙니다.") | ||
} | ||
} | ||
|
||
} |