Skip to content

Commit

Permalink
feat: ZatchController 응답 코드 수정 #19
Browse files Browse the repository at this point in the history
  • Loading branch information
plum-king committed May 11, 2023
1 parent c1355a0 commit c52324b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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")
Expand All @@ -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")
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/zatch/zatchserver/dto/GetMyZatchResDto.java
Original file line number Diff line number Diff line change
@@ -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; // 교환할 수 있는 내 물건
}

0 comments on commit c52324b

Please sign in to comment.