Skip to content

Commit

Permalink
add: (#176) 개인 휴무일 조회 UseCase
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Dec 5, 2022
1 parent 65a5a37 commit d9e1ed5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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>
)

/**
*
* 개인 휴무일 정보를 전송하는 IndividualHolidayResponse
*
* @author Chokyunghyeon
* @date 2022/12/05
* @version 1.0.0
**/
data class IndividualHolidayResponse(
val date: LocalDate,
val type: String
)
Original file line number Diff line number Diff line change
@@ -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)
}

}

0 comments on commit d9e1ed5

Please sign in to comment.