diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/common/WebCommonAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/common/WebCommonAdapter.kt index ad3f7c3f..2d2be490 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/common/WebCommonAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/common/WebCommonAdapter.kt @@ -7,7 +7,6 @@ import org.springframework.web.bind.annotation.* import team.comit.simtong.domain.auth.dto.response.TokenResponse import team.comit.simtong.domain.auth.usecase.ReissueTokenUseCase import team.comit.simtong.domain.common.dto.ChangePasswordRequest -import team.comit.simtong.domain.common.dto.FindEmployeeNumberRequest import team.comit.simtong.domain.common.dto.ResetPasswordRequest import team.comit.simtong.domain.spot.dto.SpotResponse import team.comit.simtong.domain.spot.usecase.ShowSpotListUseCase @@ -25,6 +24,8 @@ import java.util.UUID import javax.validation.Valid import javax.validation.constraints.Email import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotEmpty +import javax.validation.constraints.NotNull /** * @@ -50,13 +51,21 @@ class WebCommonAdapter( ) { @GetMapping("/employee-number") - fun findEmployeeNumber(@Valid @ModelAttribute request: FindEmployeeNumberRequest): FindEmployeeNumberResponse { - return findEmployeeNumberUseCase.execute(request.toData()) + fun findEmployeeNumber( + @NotBlank @RequestParam name: String?, + @NotNull @RequestParam("spot_id") spotId: UUID?, + @NotEmpty @Email @RequestParam email: String? + ): FindEmployeeNumberResponse { + return findEmployeeNumberUseCase.execute( + name = name!!, + spotId = spotId!!, + email = email!! + ) } @PutMapping("/token/reissue") - fun reissueJsonWebToken(@RequestHeader("Refresh-Token") request: String): TokenResponse { - return reissueTokenUseCase.execute(request) + fun reissueJsonWebToken(@NotNull @RequestHeader("Refresh-Token") token: String?): TokenResponse { + return reissueTokenUseCase.execute(token!!) } @PutMapping("/password/initialization") @@ -66,8 +75,8 @@ class WebCommonAdapter( } @GetMapping("/email/duplication") - fun checkEmailDuplication(@Email @NotBlank @RequestParam email: String) { - checkEmailDuplicationUseCase.execute(email) + fun checkEmailDuplication(@NotEmpty @Email @RequestParam email: String?) { + checkEmailDuplicationUseCase.execute(email!!) } @PutMapping("/password") @@ -78,12 +87,14 @@ class WebCommonAdapter( @GetMapping("/account/existence") fun checkMatchedAccount( - @Range(min = EmployeeNumber.MIN_VALUE, max = EmployeeNumber.MAX_VALUE) - @RequestParam employeeNumber: Int, - @NotBlank @Email - @RequestParam email: String + @NotNull @Range(min = EmployeeNumber.MIN_VALUE, max = EmployeeNumber.MAX_VALUE) + @RequestParam employeeNumber: Int?, + @NotEmpty @Email @RequestParam email: String? ) { - checkMatchedAccountUseCase.execute(employeeNumber, email) + checkMatchedAccountUseCase.execute( + employeeNumber = employeeNumber!!, + email = email!! + ) } @GetMapping("/spot") @@ -92,8 +103,8 @@ class WebCommonAdapter( } @GetMapping("/password/compare") - fun comparePassword(@NotBlank @RequestParam password: String) { - comparePasswordUseCase.execute(password) + fun comparePassword(@NotBlank @RequestParam password: String?) { + comparePasswordUseCase.execute(password!!) } @GetMapping("/team/{spot-id}") diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/email/WebEmailAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/email/WebEmailAdapter.kt index a41a0230..a87f19f4 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/email/WebEmailAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/email/WebEmailAdapter.kt @@ -1,15 +1,20 @@ package team.comit.simtong.domain.email +import org.hibernate.validator.constraints.Length +import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController import team.comit.simtong.domain.auth.usecase.CheckAuthCodeUseCase import team.comit.simtong.domain.auth.usecase.SendAuthCodeUseCase -import team.comit.simtong.domain.email.dto.CheckAuthCodeRequest import team.comit.simtong.domain.email.dto.SendAuthCodeRequest import javax.validation.Valid +import javax.validation.constraints.Email +import javax.validation.constraints.NotEmpty +import javax.validation.constraints.NotNull /** * @@ -19,6 +24,7 @@ import javax.validation.Valid * @date 2022/09/24 * @version 1.0.0 **/ +@Validated @RestController @RequestMapping("/emails") class WebEmailAdapter( @@ -32,8 +38,14 @@ class WebEmailAdapter( } @GetMapping - fun checkAuthCode(@Valid request: CheckAuthCodeRequest) { - checkAuthCodeUseCase.execute(request.toData()) + fun checkAuthCode( + @NotEmpty @Email @RequestParam email: String?, + @NotNull @Length(min = 6, max = 6) @RequestParam code: String? + ) { + checkAuthCodeUseCase.execute( + email = email!!, + code = code!! + ) } } \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/WebFileAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/WebFileAdapter.kt index 69708db5..b5981159 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/WebFileAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/file/WebFileAdapter.kt @@ -1,8 +1,10 @@ package team.comit.simtong.domain.file import org.springframework.http.HttpStatus +import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestPart import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.RestController import org.springframework.web.multipart.MultipartFile @@ -12,6 +14,7 @@ import team.comit.simtong.domain.file.dto.response.UploadImageListResponse import team.comit.simtong.domain.file.dto.response.UploadImageResponse import team.comit.simtong.domain.file.usecase.RegisterEmployeeCertificateUseCase import team.comit.simtong.domain.file.usecase.UploadImageUseCase +import javax.validation.constraints.NotNull /** * @@ -21,6 +24,7 @@ import team.comit.simtong.domain.file.usecase.UploadImageUseCase * @date 2022/09/21 * @version 1.2.5 **/ +@Validated @RestController @RequestMapping("/files") class WebFileAdapter( @@ -30,25 +34,25 @@ class WebFileAdapter( @PostMapping @ResponseStatus(HttpStatus.CREATED) - fun uploadSingleImage(file: MultipartFile): UploadImageResponse { + fun uploadSingleImage(@NotNull @RequestPart file: MultipartFile?): UploadImageResponse { return uploadImageUseCase.execute( - file.let(ImageFileConverter::transferTo) + file!!.let(ImageFileConverter::transferTo) ) } @PostMapping("/list") @ResponseStatus(HttpStatus.CREATED) - fun uploadMultipleImage(files: List): UploadImageListResponse { + fun uploadMultipleImage(@NotNull @RequestPart files: List?): UploadImageListResponse { return uploadImageUseCase.execute( - files.let(ImageFileConverter::transferToList) + files!!.let(ImageFileConverter::transferToList) ) } @PostMapping("/employee") @ResponseStatus(HttpStatus.CREATED) - fun importEmployeeCertificate(file: MultipartFile) { + fun importEmployeeCertificate(@NotNull @RequestPart file: MultipartFile?) { registerEmployeeCertificateUseCase.execute( - file.let(ExcelFileConverter::transferTo) + file!!.let(ExcelFileConverter::transferTo) ) } 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 922ecf41..f1081aa2 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 @@ -1,6 +1,7 @@ package team.comit.simtong.domain.holiday import org.springframework.http.HttpStatus +import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.PutMapping @@ -35,6 +36,7 @@ import team.comit.simtong.domain.holiday.usecase.ShareHolidayUseCase import java.time.LocalDate import java.util.UUID import javax.validation.Valid +import javax.validation.constraints.NotNull /** * @@ -45,6 +47,7 @@ import javax.validation.Valid * @date 2022/12/03 * @version 1.2.3 **/ +@Validated @RestController @RequestMapping("/holidays") class WebHolidayAdapter( @@ -62,37 +65,37 @@ class WebHolidayAdapter( ) { @GetMapping("/annual/count") - fun queryRemainAnnual(@RequestParam year: Int): QueryRemainAnnualResponse { - return queryRemainAnnualUseCase.execute(year) + fun queryRemainAnnual(@NotNull @RequestParam year: Int?): QueryRemainAnnualResponse { + return queryRemainAnnualUseCase.execute(year!!) } @PostMapping("/annual") @ResponseStatus(HttpStatus.CREATED) - fun appointAnnual(@RequestBody request: AppointAnnualRequest) { + fun appointAnnual(@Valid @RequestBody request: AppointAnnualRequest) { appointAnnualUseCase.execute(request.toData()) } @PostMapping("/dayoff") @ResponseStatus(HttpStatus.CREATED) - fun appointHoliday(@RequestBody request: AppointHolidayRequest) { + fun appointHoliday(@Valid @RequestBody request: AppointHolidayRequest) { appointHolidayUseCase.execute(request.toData()) } @PutMapping("/work") - fun cancelHoliday(@RequestBody request: CancelHolidayRequest) { + fun cancelHoliday(@Valid @RequestBody request: CancelHolidayRequest) { cancelHolidayUseCase.execute(request.toData()) } @GetMapping("/individual") fun queryIndividualHolidays( - @RequestParam("start_at") startAt: LocalDate, - @RequestParam("end_at") endAt: LocalDate, - @RequestParam status: HolidayStatus + @NotNull @RequestParam("start_at") startAt: LocalDate?, + @NotNull @RequestParam("end_at") endAt: LocalDate?, + @NotNull @RequestParam status: HolidayStatus? ): QueryIndividualHolidaysResponse { return queryIndividualHolidayUseCase.execute( - startAt = startAt, - endAt = endAt, - status = status + startAt = startAt!!, + endAt = endAt!!, + status = status!! ) } @@ -109,15 +112,15 @@ class WebHolidayAdapter( @GetMapping("/employee") fun queryEmployeeHolidays( - @RequestParam year: Int, - @RequestParam month: Int, - @RequestParam type: HolidayQueryType, + @NotNull @RequestParam year: Int?, + @NotNull @RequestParam month: Int?, + @NotNull @RequestParam type: HolidayQueryType?, @RequestParam("team_id", required = false) teamId: UUID? ): QueryEmployeeHolidayResponse { return queryEmployeeHolidayUseCase.execute( - year = year, - month = month, - type = type, + year = year!!, + month = month!!, + type = type!!, teamId = teamId ) } @@ -135,9 +138,12 @@ class WebHolidayAdapter( @GetMapping("/period") fun queryMonthHolidayPeriod( - @RequestParam year: Int, - @RequestParam month: Int + @NotNull @RequestParam year: Int?, + @NotNull @RequestParam month: Int? ): QueryMonthHolidayPeriodResponse { - return queryMonthHolidayPeriodUseCase.execute(year, month) + return queryMonthHolidayPeriodUseCase.execute( + year = year!!, + month = month!! + ) } } \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/menu/WebMenuAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/menu/WebMenuAdapter.kt index 3bfaa56d..9b0769a9 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/menu/WebMenuAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/menu/WebMenuAdapter.kt @@ -1,20 +1,22 @@ package team.comit.simtong.domain.menu +import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.ModelAttribute import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RequestPart import org.springframework.web.bind.annotation.RestController -import team.comit.simtong.domain.menu.dto.SaveMenuRequest +import org.springframework.web.multipart.MultipartFile +import team.comit.simtong.domain.file.converter.ExcelFileConverter import team.comit.simtong.domain.menu.dto.response.MenuResponse import team.comit.simtong.domain.menu.usecase.QueryMenuByMonthUseCase import team.comit.simtong.domain.menu.usecase.QueryPublicMenuUseCase import team.comit.simtong.domain.menu.usecase.SaveMenuUseCase import java.time.LocalDate import java.util.UUID -import javax.validation.Valid +import javax.validation.constraints.NotNull /** * @@ -25,6 +27,7 @@ import javax.validation.Valid * @date 2022/09/25 * @version 1.0.0 **/ +@Validated @RestController @RequestMapping("/menu") class WebMenuAdapter( @@ -35,25 +38,38 @@ class WebMenuAdapter( @GetMapping fun getMenu( - @RequestParam("start_at") startAt: LocalDate, - @RequestParam("end_at") endAt: LocalDate + @NotNull @RequestParam("start_at") startAt: LocalDate?, + @NotNull @RequestParam("end_at") endAt: LocalDate? ): MenuResponse { - return queryMenuByMonthUseCase.execute(startAt, endAt) + return queryMenuByMonthUseCase.execute( + startAt = startAt!!, + endAt = endAt!! + ) } @GetMapping("/public") fun getPublicMenu( - @RequestParam("start_at") startAt: LocalDate, - @RequestParam("end_at") endAt: LocalDate + @NotNull @RequestParam("start_at") startAt: LocalDate?, + @NotNull @RequestParam("end_at") endAt: LocalDate? ): MenuResponse { - return queryPublicMenuUseCase.execute(startAt, endAt) + return queryPublicMenuUseCase.execute( + startAt = startAt!!, + endAt = endAt!! + ) } @PostMapping("/{spot-id}") fun saveMenu( @PathVariable("spot-id") spotId: UUID, - @Valid @ModelAttribute request: SaveMenuRequest + @NotNull @RequestPart file: MultipartFile?, + @NotNull @RequestParam year: Int?, + @NotNull @RequestParam month: Int? ) { - saveMenuUseCase.execute(request.toData(), spotId) + saveMenuUseCase.execute( + spotId = spotId, + file = file!!.let(ExcelFileConverter::transferTo), + year = year!!, + month = month!! + ) } } \ No newline at end of file diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/schedule/WebScheduleAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/schedule/WebScheduleAdapter.kt index c3375294..a732751a 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/schedule/WebScheduleAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/schedule/WebScheduleAdapter.kt @@ -1,6 +1,7 @@ package team.comit.simtong.domain.schedule import org.springframework.http.HttpStatus +import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable @@ -28,6 +29,7 @@ import team.comit.simtong.domain.schedule.usecase.RemoveSpotScheduleUseCase import java.time.LocalDate import java.util.UUID import javax.validation.Valid +import javax.validation.constraints.NotNull /** * @@ -37,6 +39,7 @@ import javax.validation.Valid * @date 2022/11/21 * @version 1.2.5 **/ +@Validated @RestController @RequestMapping("/schedules") class WebScheduleAdapter( @@ -62,23 +65,32 @@ class WebScheduleAdapter( @PathVariable("schedule-id") scheduleId: UUID, @Valid @RequestBody request: ChangeIndividualScheduleRequest ) { - changeIndividualScheduleUseCase.execute(request.toData(), scheduleId) + changeIndividualScheduleUseCase.execute( + request = request.toData(), + scheduleId = scheduleId + ) } @GetMapping fun queryIndividualSpotSchedule( - @RequestParam("start_at") startAt: LocalDate, - @RequestParam("end_at") endAt: LocalDate + @NotNull @RequestParam("start_at") startAt: LocalDate?, + @NotNull @RequestParam("end_at") endAt: LocalDate? ): QueryIndividualSpotScheduleResponse { - return queryIndividualSpotScheduleUseCase.execute(startAt, endAt) + return queryIndividualSpotScheduleUseCase.execute( + startAt = startAt!!, + endAt = endAt!! + ) } @GetMapping("/spots") fun queryEntireSpotSchedule( - @RequestParam("start_at") startAt: LocalDate, - @RequestParam("end_at") endAt: LocalDate + @NotNull @RequestParam("start_at") startAt: LocalDate?, + @NotNull @RequestParam("end_at") endAt: LocalDate? ): QueryEntireSpotScheduleResponse { - return queryEntireSpotScheduleUseCase.execute(startAt, endAt) + return queryEntireSpotScheduleUseCase.execute( + startAt = startAt!!, + endAt = endAt!! + ) } @PostMapping("/spots/{spot-id}") @@ -87,7 +99,10 @@ class WebScheduleAdapter( @PathVariable("spot-id") spotId: UUID, @Valid @RequestBody request: AddSpotScheduleRequest ) { - addSpotScheduleUseCase.execute(request.toData(), spotId) + addSpotScheduleUseCase.execute( + request = request.toData(), + spotId = spotId + ) } @PutMapping("/spots/{schedule-id}") @@ -96,7 +111,10 @@ class WebScheduleAdapter( @PathVariable("schedule-id") scheduleId: UUID, @Valid @RequestBody request: ChangeSpotScheduleRequest ) { - changeSpotScheduleUseCase.execute(request.toData(), scheduleId) + changeSpotScheduleUseCase.execute( + request = request.toData(), + scheduleId = scheduleId + ) } @DeleteMapping("/{schedule-id}") diff --git a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt index da63ea23..c54002d2 100644 --- a/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt +++ b/simtong-presentation/src/main/kotlin/team/comit/simtong/domain/user/WebUserAdapter.kt @@ -31,6 +31,8 @@ import team.comit.simtong.domain.user.usecase.QueryUserInfoUseCase import team.comit.simtong.domain.user.usecase.SignInUseCase import team.comit.simtong.domain.user.usecase.SignUpUseCase import javax.validation.Valid +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern /** @@ -99,19 +101,22 @@ class WebUserAdapter( @GetMapping("/nickname/duplication") fun checkNicknameDuplication( - @Pattern(regexp = NickName.PATTERN) - @RequestParam nickname: String + @NotNull @Pattern(regexp = NickName.PATTERN) + @RequestParam nickname: String? ) { - checkNicknameDuplicationUseCase.execute(nickname) + checkNicknameDuplicationUseCase.execute(nickname!!) } @GetMapping("/verification-employee") fun checkEmployee( - @RequestParam name: String, - @Range(min = EmployeeNumber.MIN_VALUE, max = EmployeeNumber.MAX_VALUE) - @RequestParam("employee_number") employeeNumber: Int + @NotBlank @RequestParam name: String?, + @NotNull @Range(min = EmployeeNumber.MIN_VALUE, max = EmployeeNumber.MAX_VALUE) + @RequestParam("employee_number") employeeNumber: Int? ) { - checkEmployeeUseCase.execute(name, employeeNumber) + checkEmployeeUseCase.execute( + name = name!!, + employeeNumber = employeeNumber!! + ) } } \ No newline at end of file