Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge: (#313) 나머지 영문 명칭 수정 #314

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package team.comit.simtong.domain.holiday.dto.response

/**
*
* 남은 연차 개수를 전송하는 QueryRemainAnnualWebResponse
* 남은 연차 개수를 전송하는 QueryRestOfAnnualWebResponse
*
* @author Chokyunghyeon
* @date 2022/12/20
* @version 1.0.0
**/
data class QueryRemainAnnualResponse(
data class QueryRestOfAnnualResponse(
val result: Long
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package team.comit.simtong.domain.holiday.usecase

import team.comit.simtong.domain.holiday.dto.response.QueryRemainAnnualResponse
import team.comit.simtong.domain.holiday.dto.response.QueryRestOfAnnualResponse
import team.comit.simtong.domain.holiday.model.Holiday
import team.comit.simtong.domain.holiday.model.HolidayType
import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort
Expand All @@ -9,26 +9,26 @@ import team.comit.simtong.global.annotation.ReadOnlyUseCase

/**
*
* 남은 연차 개수 확인을 담당하는 QueryRemainAnnualUseCase
* 남은 연차 개수 확인을 담당하는 QueryRestOfAnnualUseCase
*
* @author Chokyunghyeon
* @author kimbeomjin
* @date 2022/12/20
* @version 1.2.5
**/
@ReadOnlyUseCase
class QueryRemainAnnualUseCase(
class QueryRestOfAnnualUseCase(
private val queryHolidayPort: QueryHolidayPort,
private val securityPort: HolidaySecurityPort
) {

fun execute(year: Int): QueryRemainAnnualResponse {
fun execute(year: Int): QueryRestOfAnnualResponse {
val currentUserId = securityPort.getCurrentUserId()

val annualCount = queryHolidayPort.countHolidayByYearAndUserIdAndType(year, currentUserId, HolidayType.ANNUAL)

return Holiday
.calculateRemainedAnnualCount(annualCount)
.let(::QueryRemainAnnualResponse)
.calculateRestOfAnnualCount(annualCount)
.let(::QueryRestOfAnnualResponse)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ import team.comit.simtong.global.annotation.SimtongTest
import java.util.UUID

@SimtongTest
class QueryRemainAnnualUseCaseTests {
class QueryRestOfAnnualUseCaseTests {

@MockBean
private lateinit var queryHolidayPort: QueryHolidayPort

@MockBean
private lateinit var securityPort: HolidaySecurityPort

private lateinit var queryRemainAnnualUseCase: QueryRemainAnnualUseCase
private lateinit var queryRestOfAnnualUseCase: QueryRestOfAnnualUseCase

private val id: UUID = UUID.randomUUID()

private val year: Int = 2023

@BeforeEach
fun setUp() {
queryRemainAnnualUseCase = QueryRemainAnnualUseCase(queryHolidayPort, securityPort)
queryRestOfAnnualUseCase = QueryRestOfAnnualUseCase(queryHolidayPort, securityPort)
}

@Test
Expand All @@ -44,7 +44,7 @@ class QueryRemainAnnualUseCaseTests {
.willReturn(count)

// when
val result = queryRemainAnnualUseCase.execute(year)
val result = queryRestOfAnnualUseCase.execute(year)

// then
assertEquals(result.result, Holiday.ANNUAL_LEAVE_LIMIT - count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ data class Holiday(
status: HolidayStatus = HolidayStatus.COMPLETED
) = Holiday(date, userId, type, spotId, status)

fun calculateRemainedAnnualCount(annualCount: Long) = ANNUAL_LEAVE_LIMIT - annualCount
fun calculateRestOfAnnualCount(annualCount: Long) = ANNUAL_LEAVE_LIMIT - annualCount

fun checkNotExceededHolidayLimit(holidayCount: Long) {
if (holidayCount >= WEEK_HOLIDAY_LIMIT) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import team.comit.simtong.domain.holiday.dto.ShareHolidayRequest
import team.comit.simtong.domain.holiday.dto.response.QueryEmployeeHolidayResponse
import team.comit.simtong.domain.holiday.dto.response.QueryIndividualHolidaysResponse
import team.comit.simtong.domain.holiday.dto.response.QueryMonthHolidayPeriodResponse
import team.comit.simtong.domain.holiday.dto.response.QueryRemainAnnualResponse
import team.comit.simtong.domain.holiday.dto.response.QueryRestOfAnnualResponse
import team.comit.simtong.domain.holiday.model.HolidayQueryType
import team.comit.simtong.domain.holiday.model.HolidayStatus
import team.comit.simtong.domain.holiday.usecase.AppointAnnualUseCase
Expand All @@ -31,7 +31,7 @@ import team.comit.simtong.domain.holiday.usecase.CheckHolidayPeriodUseCase
import team.comit.simtong.domain.holiday.usecase.QueryEmployeeHolidayUseCase
import team.comit.simtong.domain.holiday.usecase.QueryIndividualHolidayUseCase
import team.comit.simtong.domain.holiday.usecase.QueryMonthHolidayPeriodUseCase
import team.comit.simtong.domain.holiday.usecase.QueryRemainAnnualUseCase
import team.comit.simtong.domain.holiday.usecase.QueryRestOfAnnualUseCase
import team.comit.simtong.domain.holiday.usecase.ShareHolidayUseCase
import java.time.LocalDate
import java.util.UUID
Expand All @@ -54,7 +54,7 @@ class WebHolidayAdapter(
private val queryMonthHolidayPeriodUseCase: QueryMonthHolidayPeriodUseCase,
private val appointHolidayPeriodUseCase: AppointHolidayPeriodUseCase,
private val checkHolidayPeriodUseCase: CheckHolidayPeriodUseCase,
private val queryRemainAnnualUseCase: QueryRemainAnnualUseCase,
private val queryRestOfAnnualUseCase: QueryRestOfAnnualUseCase,
private val appointAnnualUseCase: AppointAnnualUseCase,
private val appointHolidayUseCase: AppointHolidayUseCase,
private val cancelHolidayUseCase: CancelHolidayUseCase,
Expand All @@ -65,8 +65,8 @@ class WebHolidayAdapter(
) {

@GetMapping("/annual/count")
fun queryRemainAnnual(@NotNull @RequestParam year: Int?): QueryRemainAnnualResponse {
return queryRemainAnnualUseCase.execute(year!!)
fun queryRestOfAnnual(@NotNull @RequestParam year: Int?): QueryRestOfAnnualResponse {
return queryRestOfAnnualUseCase.execute(year!!)
}

@PostMapping("/annual")
Expand Down