Skip to content

Commit

Permalink
feat: ReviewApi 작성 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
daeyoung0726 committed Aug 2, 2024
1 parent 724a245 commit a1005fe
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions src/main/java/gible/domain/review/api/ReviewApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import gible.domain.review.dto.ReviewReq;
import gible.domain.security.common.SecurityUserDetails;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.data.domain.Pageable;
Expand All @@ -17,16 +22,104 @@
@Tag(name = "[리뷰 API]", description = "리뷰 관련 API")
public interface ReviewApi {

@Operation(summary = "리뷰 목록 조회", description = "리뷰 목록 조회하기 위한 API")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "리뷰 목록 가져오기 성공",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(value = """
{
"totalPages": 1,
"totalElements": 2,
"first": true,
"last": true,
"size": 10,
"content": [
{
"id": "a12b34cd-56ef-78gh-90ij-1234567890kl",
"title": "리뷰 제목 1",
"content": "리뷰 내용 1",
"nickname": "리뷰자1"
},
{
"id": "a12b34cd-56ef-78gh-90ij-1234567890kl",
"title": "리뷰 제목 2",
"content": "리뷰 내용 2",
"nickname": "리뷰자2"
}
],
"number": 0,
"sort": {
"empty": false,
"sorted": true,
"unsorted": false
},
"numberOfElements": 2,
"pageable": {
"pageNumber": 0,
"pageSize": 10,
"sort": {
"empty": false,
"sorted": true,
"unsorted": false
},
"offset": 0,
"paged": true,
"unpaged": false
},
"empty": false
}
""")
})
)
})
ResponseEntity<?> getReviews(
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC) Pageable pageable
);

@Operation(summary = "특정 리뷰 조회", description = "특정 리뷰에 대한 조회하기 위한 API")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "특정 리뷰 조회하기 성공",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(value = """
{
"title": "리뷰 제목 1",
"content": "리뷰 내용 1",
"nickname": "리뷰자1",
"imageUrl": "http://example.com/image.jpg",
"writerId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}
""")
})
)
})
ResponseEntity<?> getReview(@PathVariable UUID reviewId);

@Operation(summary = "리뷰 업로드", description = "리뷰 업로드하기 위한 API")
@ApiResponses({
@ApiResponse(responseCode = "201", description = "리뷰 업로드 성공",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(value = """
{
"response": "리뷰 업로드 성공"
}
""")
})),
})
ResponseEntity<?> uploadReview(
@AuthenticationPrincipal SecurityUserDetails userDetails,
@Valid @RequestBody ReviewReq reviewReq
);

@Operation(summary = "리뷰 삭제", description = "리뷰 삭제하기 위한 API")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "리뷰 삭제 성공",
content = @Content(mediaType = "application/json", examples = {
@ExampleObject(value = """
{
"response": "리뷰 삭제 성공"
}
""")
})),
})
ResponseEntity<?> deleteReview(@PathVariable UUID reviewId);
}

0 comments on commit a1005fe

Please sign in to comment.