From c52324b25643baece723f38c45312e2745bdec20 Mon Sep 17 00:00:00 2001 From: plum-king Date: Thu, 11 May 2023 12:52:10 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20ZatchController=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20#19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ZatchController.java | 27 ++++++++++++++++--- .../zatchserver/dto/GetMyZatchResDto.java | 13 +++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/zatch/zatchserver/dto/GetMyZatchResDto.java diff --git a/src/main/java/com/zatch/zatchserver/controller/ZatchController.java b/src/main/java/com/zatch/zatchserver/controller/ZatchController.java index 0c3cdd5..74236d6 100644 --- a/src/main/java/com/zatch/zatchserver/controller/ZatchController.java +++ b/src/main/java/com/zatch/zatchserver/controller/ZatchController.java @@ -5,13 +5,12 @@ import com.zatch.zatchserver.ResponseMessage; import com.zatch.zatchserver.StatusCode; import com.zatch.zatchserver.domain.Zatch; -import com.zatch.zatchserver.dto.GetPopularZatchItemRes; -import com.zatch.zatchserver.dto.PostZatchLikeRes; -import com.zatch.zatchserver.dto.PostZatchReq; +import com.zatch.zatchserver.dto.*; import com.zatch.zatchserver.service.ZatchService; -import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.*; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -53,6 +52,10 @@ public void makeNewZatch(@RequestBody PostZatchReq postZatchReq) { postService.register(newPost); } + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success", response = PostZatchLikeRes.class, + examples = @Example(@ExampleProperty(value = "{'property1': 'value1', 'property2': 'value2'}", mediaType = MediaType.APPLICATION_JSON_VALUE))) + }) @PostMapping("/{zatchId}/likes") @ApiOperation(value = "좋아요", notes = "좋아요") public PostZatchLikeRes postZatchlike(HttpServletRequest request, @PathVariable("zatchId") Long zatchId) { @@ -61,6 +64,10 @@ public PostZatchLikeRes postZatchlike(HttpServletRequest request, @PathVariable( return new PostZatchLikeRes(zatchId, likeCount); } + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success", response = PostZatchLikeRes.class, + examples = @Example(@ExampleProperty(value = "{'property1': 'value1', 'property2': 'value2'}", mediaType = MediaType.APPLICATION_JSON_VALUE))) + }) @DeleteMapping("/{zatchId}/dislikes") @ApiOperation(value = "좋아요 취소", notes = "좋아요 취소") public PostZatchLikeRes postZatchDislike(HttpServletRequest request, @PathVariable("zatchId") Long zatchId) { @@ -69,6 +76,10 @@ public PostZatchLikeRes postZatchDislike(HttpServletRequest request, @PathVariab return new PostZatchLikeRes(zatchId, likeCount); } + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success", response = GetPopularZatchItemRes.class, + examples = @Example(@ExampleProperty(value = "{'property1': 'value1', 'property2': 'value2'}", mediaType = MediaType.APPLICATION_JSON_VALUE))) + }) @GetMapping("/search/popularItem") @ApiOperation(value = "인기있는 재치 물품", notes = "좋아요 순 조회") public GetPopularZatchItemRes getPopularItem(HttpServletRequest request) { @@ -77,6 +88,10 @@ public GetPopularZatchItemRes getPopularItem(HttpServletRequest request) { } + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success", response = GetMyZatchResDto.class, + examples = @Example(@ExampleProperty(value = "{'property1': 'value1', 'property2': 'value2'}", mediaType = MediaType.APPLICATION_JSON_VALUE))) + }) //내 재치 검색어 띄우기 @GetMapping("/{userId}/search") @ApiOperation(value = "교환할 수 있는 재치", notes = "검색 시, 내 재치 조회 API") @@ -89,6 +104,10 @@ public ResponseEntity getMyZatch(@PathVariable("userId") Long userId) { } } + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success", response = GetExchangeSearchResDto.class, + examples = @Example(@ExampleProperty(value = "{'property1': 'value1', 'property2': 'value2'}", mediaType = MediaType.APPLICATION_JSON_VALUE))) + }) //교환할 재치 검색 결과 @GetMapping("/{userId}/search/{itemName1}&{itemName2}") @ApiOperation(value = "교환할 재치", notes = "교환 재치 검색 결과 조회 API") diff --git a/src/main/java/com/zatch/zatchserver/dto/GetMyZatchResDto.java b/src/main/java/com/zatch/zatchserver/dto/GetMyZatchResDto.java new file mode 100644 index 0000000..54abcd6 --- /dev/null +++ b/src/main/java/com/zatch/zatchserver/dto/GetMyZatchResDto.java @@ -0,0 +1,13 @@ +package com.zatch.zatchserver.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class GetMyZatchResDto { + String itemName1; // 교환할 수 있는 내 물건 +} +