From d9e1ed53f2c062e99fd6f58ed15b9fb62322a07e Mon Sep 17 00:00:00 2001 From: Jo Kyung Hyeon Date: Mon, 5 Dec 2022 21:38:23 +0900 Subject: [PATCH] =?UTF-8?q?add:=20(#176)=20=EA=B0=9C=EC=9D=B8=20=ED=9C=B4?= =?UTF-8?q?=EB=AC=B4=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20UseCase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/QueryIndividualHolidaysResponse.kt | 28 +++++++++++++ .../usecase/QueryIndividualHolidayUseCase.kt | 39 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/dto/QueryIndividualHolidaysResponse.kt create mode 100644 simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/QueryIndividualHolidayUseCase.kt diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/dto/QueryIndividualHolidaysResponse.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/dto/QueryIndividualHolidaysResponse.kt new file mode 100644 index 00000000..e910c200 --- /dev/null +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/dto/QueryIndividualHolidaysResponse.kt @@ -0,0 +1,28 @@ +package team.comit.simtong.domain.holiday.dto + +import java.time.LocalDate + +/** + * + * 개인 휴무일 정보를 전송하는 QueryIndividualHolidayResponse + * + * @author Chokyunghyeon + * @date 2022/12/05 + * @version 1.0.0 + **/ +data class QueryIndividualHolidaysResponse( + val holidays: List +) + +/** + * + * 개인 휴무일 정보를 전송하는 IndividualHolidayResponse + * + * @author Chokyunghyeon + * @date 2022/12/05 + * @version 1.0.0 + **/ +data class IndividualHolidayResponse( + val date: LocalDate, + val type: String +) \ No newline at end of file diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/QueryIndividualHolidayUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/QueryIndividualHolidayUseCase.kt new file mode 100644 index 00000000..ab64fdc3 --- /dev/null +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/holiday/usecase/QueryIndividualHolidayUseCase.kt @@ -0,0 +1,39 @@ +package team.comit.simtong.domain.holiday.usecase + +import team.comit.simtong.domain.holiday.dto.IndividualHolidayResponse +import team.comit.simtong.domain.holiday.dto.QueryIndividualHolidaysResponse +import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort +import team.comit.simtong.domain.holiday.spi.QueryHolidayPort +import team.comit.simtong.global.annotation.ReadOnlyUseCase +import java.time.LocalDate + +/** + * + * 개인 휴무일 조회 요청을 담당하는 QueryIndividualHolidayUseCase + * + * @author Chokyunghyeon + * @date 2022/12/05 + * @version 1.0.0 + **/ +@ReadOnlyUseCase +class QueryIndividualHolidayUseCase( + private val queryHolidayPort: QueryHolidayPort, + private val securityPort: HolidaySecurityPort +) { + + fun execute(date: LocalDate) : QueryIndividualHolidaysResponse { + val currentUserId = securityPort.getCurrentUserId() + + val holidays = queryHolidayPort.queryHolidaysByMonthAndUserId(date, currentUserId) + + val response = holidays.map { + IndividualHolidayResponse( + date = it.date, + type = it.type.name + ) + } + + return QueryIndividualHolidaysResponse(response) + } + +} \ No newline at end of file