From a769641860265bb61e8f2df114c8ad6b66d24f03 Mon Sep 17 00:00:00 2001 From: KimDoubleB Date: Thu, 19 Sep 2024 23:53:20 +0900 Subject: [PATCH] feat: apply PreventDuplicateRequest --- .../com/piikii/input/http/controller/PlaceApi.kt | 3 +++ .../kotlin/com/piikii/input/http/controller/RoomApi.kt | 10 ++++++---- .../kotlin/com/piikii/input/http/controller/VoteApi.kt | 2 ++ .../piikii/input/http/controller/docs/RoomApiDocs.kt | 8 ++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt index a0c2b2d1..b45959f6 100644 --- a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt +++ b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/PlaceApi.kt @@ -9,6 +9,7 @@ import com.piikii.application.port.input.dto.request.AddPlaceRequest import com.piikii.application.port.input.dto.request.ModifyPlaceRequest import com.piikii.application.port.input.dto.response.PlaceResponse import com.piikii.application.port.input.dto.response.ScheduleTypeGroupResponse +import com.piikii.input.http.aspect.PreventDuplicateRequest import com.piikii.input.http.controller.docs.PlaceDocs import com.piikii.input.http.controller.dto.ResponseForm import jakarta.validation.Valid @@ -35,6 +36,7 @@ class PlaceApi( private val placeUseCase: PlaceUseCase, private val imageUploadUseCase: ImageUploadUseCase, ) : PlaceDocs { + @PreventDuplicateRequest("#roomUid + #addPlaceRequest.name") @ResponseStatus(HttpStatus.CREATED) @PostMapping(consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) override fun addPlace( @@ -54,6 +56,7 @@ class PlaceApi( return ResponseForm(placeUseCase.findAllByRoomUidGroupByPlaceType(UuidTypeId(roomUid))) } + @PreventDuplicateRequest("#roomUid + #placeId") @ResponseStatus(HttpStatus.OK) @PatchMapping("/{placeId}", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) override fun modifyPlace( diff --git a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/RoomApi.kt b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/RoomApi.kt index c0cd0449..1647e65e 100644 --- a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/RoomApi.kt +++ b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/RoomApi.kt @@ -7,6 +7,7 @@ import com.piikii.application.port.input.dto.request.RoomSaveRequestForm import com.piikii.application.port.input.dto.request.RoomUpdateRequestForm import com.piikii.application.port.input.dto.response.RoomResponse import com.piikii.application.port.input.dto.response.SaveRoomResponse +import com.piikii.input.http.aspect.PreventDuplicateRequest import com.piikii.input.http.controller.docs.RoomApiDocs import com.piikii.input.http.controller.dto.ResponseForm import jakarta.validation.Valid @@ -34,7 +35,7 @@ class RoomApi( ) : RoomApiDocs { @ResponseStatus(HttpStatus.CREATED) @PostMapping - override fun create( + override fun createRoom( @Valid @NotNull @RequestBody request: RoomSaveRequestForm, ): ResponseForm { return ResponseForm( @@ -42,9 +43,10 @@ class RoomApi( ) } + @PreventDuplicateRequest("#request.roomUid") @ResponseStatus(HttpStatus.OK) @PutMapping - override fun modifyInformation( + override fun modifyRoom( @Valid @NotNull @RequestBody request: RoomUpdateRequestForm, ): ResponseForm { roomUseCase.modify(request) @@ -53,7 +55,7 @@ class RoomApi( @ResponseStatus(HttpStatus.OK) @DeleteMapping("/{roomUid}") - override fun remove( + override fun deleteRoom( @NotNull @PathVariable roomUid: UUID, ): ResponseForm { roomUseCase.remove(UuidTypeId(roomUid)) @@ -62,7 +64,7 @@ class RoomApi( @ResponseStatus(HttpStatus.OK) @GetMapping("/{roomUid}") - override fun search( + override fun retrieveRoom( @NotNull @PathVariable roomUid: UUID, ): ResponseForm { return ResponseForm( diff --git a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/VoteApi.kt b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/VoteApi.kt index cd00b402..70ed17e2 100644 --- a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/VoteApi.kt +++ b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/VoteApi.kt @@ -8,6 +8,7 @@ import com.piikii.application.port.input.dto.request.VoteSaveRequest import com.piikii.application.port.input.dto.response.VoteResultResponse import com.piikii.application.port.input.dto.response.VoteStatusResponse import com.piikii.application.port.input.dto.response.VotedPlacesResponse +import com.piikii.input.http.aspect.PreventDuplicateRequest import com.piikii.input.http.controller.docs.VoteApiDocs import com.piikii.input.http.controller.dto.ResponseForm import jakarta.validation.Valid @@ -31,6 +32,7 @@ class VoteApi( private val voteUseCase: VoteUseCase, private val roomUseCase: RoomUseCase, ) : VoteApiDocs { + @PreventDuplicateRequest("#roomUid") @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/deadline") override fun changeVoteDeadline( diff --git a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/docs/RoomApiDocs.kt b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/docs/RoomApiDocs.kt index 4b323433..06892f69 100644 --- a/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/docs/RoomApiDocs.kt +++ b/piikii-input-http/src/main/kotlin/com/piikii/input/http/controller/docs/RoomApiDocs.kt @@ -36,7 +36,7 @@ interface RoomApiDocs { ), ], ) - fun create( + fun createRoom( @Parameter( description = "방 생성 요청 정보", required = true, @@ -58,7 +58,7 @@ interface RoomApiDocs { ), ], ) - fun modifyInformation( + fun modifyRoom( @Parameter( description = "방 수정 요청 정보", required = true, @@ -80,7 +80,7 @@ interface RoomApiDocs { ), ], ) - fun remove( + fun deleteRoom( @Parameter( name = "roomUid", description = "삭제하고자 하는 방 id", @@ -99,7 +99,7 @@ interface RoomApiDocs { ), ], ) - fun search( + fun retrieveRoom( @Parameter( name = "roomUid", description = "조회하고자 하는 방 id",