From 0301a82c760fae8795b0b8cdf8d43e87b4ebcd12 Mon Sep 17 00:00:00 2001 From: Jo Kyung Hyeon Date: Thu, 22 Dec 2022 22:37:47 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20(#251)=20=ED=9C=B4=EB=AC=B4=ED=91=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=EA=B8=B0=EA=B0=84=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simtong/global/security/SecurityConfig.kt | 1 + .../domain/holiday/WebHolidayAdapter.kt | 20 +++++++++++-- .../request/AppointHolidayPeriodWebRequest.kt | 29 +++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/dto/request/AppointHolidayPeriodWebRequest.kt diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt index f4b803ef..bf504caf 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/global/security/SecurityConfig.kt @@ -101,6 +101,7 @@ class SecurityConfig( .antMatchers(HttpMethod.GET, "/holidays/annual/count").hasRole(ROLE_COMMON.role) .antMatchers(HttpMethod.GET, "/holidays/verification-period").hasRole(ROLE_COMMON.role) .antMatchers(HttpMethod.GET, "/holidays/employee").hasRole(ROLE_ADMIN.role) + .antMatchers(HttpMethod.PUT, "/holidays/period").hasRole(ROLE_ADMIN.role) // admins .antMatchers(HttpMethod.POST, "/admins/tokens").permitAll() diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/WebHolidayAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/WebHolidayAdapter.kt index 1df73682..076e3135 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/WebHolidayAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/WebHolidayAdapter.kt @@ -9,17 +9,20 @@ import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.RestController +import team.comit.simtong.domain.holiday.dto.AppointHolidayPeriodRequest import team.comit.simtong.domain.holiday.dto.QueryEmployeeHolidayResponse import team.comit.simtong.domain.holiday.dto.QueryIndividualHolidaysResponse import team.comit.simtong.domain.holiday.dto.QueryIndividualRequest import team.comit.simtong.domain.holiday.dto.request.AppointAnnualWebRequest +import team.comit.simtong.domain.holiday.dto.request.AppointHolidayPeriodWebRequest import team.comit.simtong.domain.holiday.dto.request.AppointHolidayWebRequest -import team.comit.simtong.domain.holiday.dto.request.CancelHolidayRequest +import team.comit.simtong.domain.holiday.dto.request.CancelHolidayWebRequest import team.comit.simtong.domain.holiday.dto.request.ShareHolidayWebRequest import team.comit.simtong.domain.holiday.dto.request.WebHolidayQueryType import team.comit.simtong.domain.holiday.dto.request.WebHolidayStatus import team.comit.simtong.domain.holiday.dto.response.QueryRemainAnnualWebResponse import team.comit.simtong.domain.holiday.usecase.AppointAnnualUseCase +import team.comit.simtong.domain.holiday.usecase.AppointHolidayPeriodUseCase import team.comit.simtong.domain.holiday.usecase.AppointHolidayUseCase import team.comit.simtong.domain.holiday.usecase.CancelHolidayUseCase import team.comit.simtong.domain.holiday.usecase.CheckHolidayPeriodUseCase @@ -42,6 +45,7 @@ import javax.validation.Valid @RestController @RequestMapping("/holidays") class WebHolidayAdapter( + private val appointHolidayPeriodUseCase: AppointHolidayPeriodUseCase, private val checkHolidayPeriodUseCase: CheckHolidayPeriodUseCase, private val queryRemainAnnualUseCase: QueryRemainAnnualUseCase, private val appointAnnualUseCase: AppointAnnualUseCase, @@ -72,7 +76,7 @@ class WebHolidayAdapter( } @PutMapping("/work") - fun cancelHoliday(@RequestBody request: CancelHolidayRequest) { + fun cancelHoliday(@RequestBody request: CancelHolidayWebRequest) { cancelHolidayUseCase.execute(request.date) } @@ -119,4 +123,16 @@ class WebHolidayAdapter( teamId = teamId ) } + + @PutMapping("/period") + fun appointHolidayPeriod(@Valid @RequestBody request: AppointHolidayPeriodWebRequest) { + appointHolidayPeriodUseCase.execute( + AppointHolidayPeriodRequest( + year = request.year, + month = request.month, + startAt = request.startAt, + endAt = request.endAt + ) + ) + } } \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/dto/request/AppointHolidayPeriodWebRequest.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/dto/request/AppointHolidayPeriodWebRequest.kt new file mode 100644 index 00000000..06bf0219 --- /dev/null +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/holiday/dto/request/AppointHolidayPeriodWebRequest.kt @@ -0,0 +1,29 @@ +package team.comit.simtong.domain.holiday.dto.request + +import org.hibernate.validator.constraints.Range +import java.time.LocalDate +import javax.validation.constraints.NotNull + +/** + * + * 휴무표 작성 기간 설정을 요청하는 AppointHolidayPeriodWebRequest + * + * @author Chokyunghyeon + * @date 2022/12/22 + * @version 1.0.0 + **/ +data class AppointHolidayPeriodWebRequest( + @field:NotNull + val year: Int, + + @field:NotNull + @field:Range( + min = 1, + max = 12 + ) + val month: Int, + + val startAt: LocalDate, + + val endAt: LocalDate +) \ No newline at end of file