Skip to content

Commit

Permalink
Refactor: Swagger ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
sansan20535 committed Jan 21, 2025
1 parent 70ac65b commit 5d1ee4f
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public ResponseEntity<BaseResponse<CommentsAndSubCommentsResponse>> getPostComme
return SuccessResponse.success(SuccessMessage.OK, postComments);
}

@GetMapping("/my")
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMyComments(
@GetMapping("/members")
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMemberComments(
@RequestParam(name = "nickname", required = false) final String nickname
) {
return SuccessResponse.success(SuccessMessage.OK, commentService.getMyComments(nickname, PrincipalHandler.getMemberIdFromPrincipal()));
return SuccessResponse.success(SuccessMessage.OK, commentService.getMemberComments(nickname, PrincipalHandler.getMemberIdFromPrincipal()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public ResponseEntity<BaseResponse<Void>> deletePostSubComment(
@Parameter(name = "postId", description = "๊ฒŒ์‹œ๊ธ€ ์•„์ด๋””", in = ParameterIn.PATH, required = true, schema = @Schema(type = "Long"))
public ResponseEntity<BaseResponse<CommentsAndSubCommentsResponse>> getPostComments(final Long postId);

@Operation(summary = "๋‚˜์˜ ๋Œ“๊ธ€&๋Œ€๋Œ“๊ธ€ ์กฐํšŒ API", description = "๋‚ด๊ฐ€ ๋‹จ ๋Œ“๊ธ€๊ณผ ๋Œ€๋Œ“๊ธ€์„ ์กฐํšŒํ•˜๋Š” API์ž…๋‹ˆ๋‹ค. ")
@Operation(summary = "์‚ฌ์šฉ์ž ๋Œ“๊ธ€ & ๋Œ€๋Œ“๊ธ€ ์กฐํšŒ API", description = "์‚ฌ์šฉ์ž์˜ ๋Œ“๊ธ€๊ณผ ๋Œ€๋Œ“๊ธ€์„ ์กฐํšŒํ•˜๋Š” API์ž…๋‹ˆ๋‹ค. ")
@ApiResponse(
responseCode = "200",
description = "์š”์ฒญ์— ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.")
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMyComments (
public ResponseEntity<BaseResponse<MyAllCommentsResponse>> getMemberComments(
@RequestParam final String nickname
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public CommentsAndSubCommentsResponse getPostComments(final Long postId, final L
return CommentsAndSubCommentsResponse.of(commentDtos);
}

public MyAllCommentsResponse getMyComments(final String nickname, final Long memberId) {
public MyAllCommentsResponse getMemberComments(final String nickname, final Long memberId) {
final Long selectedMemberId = (nickname != null ) ? findMemberByNickname(nickname): memberId;
final List<Comment> comments = commentRepository.findByMemberIdOrderByCreatedAtAsc(selectedMemberId);
final List<Long> commentIds = comments.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.swagger.v3.oas.annotations.media.Schema;

public record LoginRequest(
@Schema(description = "์†Œ์…œ ํ”Œ๋žซํผ", example = "KAKAO")
@Schema(description = "์†Œ์…œ ํ”Œ๋žซํผ", example = "KAKAO or GOOGLE or APPLE")
Platform platform,
@Schema(description = "์ฝ”๋“œ", example = "egagasdgasdgdagdasgasgasdgdasgasdglkj")
String code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public record PetResponse(
String petName,
@Schema(description = "์• ์™„๋™๋ฌผ ์„ฑ๋ณ„",example = "12")
int petAge,
@Schema(description = "์• ์™„๋™๋ฌผ ๋‚˜์ด", example = "์• ์™„๋™๋ฌผ ์„ฑ๋ณ„")
@Schema(description = "์• ์™„๋™๋ฌผ ๋‚˜์ด", example = "M or F")
Gender petGender,
@Schema(description = "์ข… ์•„์ด๋””", example = "1")
Long breedId,
Expand All @@ -32,4 +32,4 @@ public record PetResponse(
public static PetResponse of(final Long petId, final String petImage, final String petName,final int petAge, final Gender petGender, final Long breedId, final String breed, final Long animalId, final String animal, final List<PetDiseaseResponse> diseases, final List<PetSymptomResponse> symptoms) {
return new PetResponse(petId, petImage, petName, petAge, petGender, breedId, breed, animalId, animal, diseases, symptoms);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public record PetCreateRequest(
@Schema(description = "๋ฐ˜๋ ค๋™๋ฌผ ์ด๋ฆ„", example = "ํฌ๋ฆฌ")
String name,

@Schema(description = "์„ฑ๋ณ„", example = "F")
@Schema(description = "์„ฑ๋ณ„", example = "F or M")
Gender gender,

@Schema(description = "๋‚˜์ด", example = "12")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public record PetUpdateRequest(
@Schema(description = "๋ฐ˜๋ ค๋™๋ฌผ ์ด๋ฆ„", example = "ํฌ๋ฆฌ")
String name,

@Schema(description = "์„ฑ๋ณ„", example = "F")
@Schema(description = "์„ฑ๋ณ„", example = "F or M")
Gender gender,

@Schema(description = "๋‚˜์ด", example = "12")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public ResponseEntity<BaseResponse<PostListResponse>> getPosts(
return SuccessResponse.success(SuccessMessage.OK, postService.getPosts(PrincipalHandler.getMemberIdFromPrincipal(), postListRequest.keyword(),
postListRequest.animalIds(), postListRequest.symptomIds(), postListRequest.diseaseIds(),
postListRequest.sortBy(), postListRequest.cursorId(), postListRequest.categoryId(),
postListRequest.likeCount(), postListRequest.createAt()));
postListRequest.likeCount(), postListRequest.createdAt()));
}

@GetMapping("/my")
@GetMapping("/members")
public ResponseEntity<BaseResponse<MemberPostsResponse>> getMemberPosts(
@RequestParam(name = "nickname", required = false) final String nickname
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cocos.cocos.api.post.controller;

import com.cocos.cocos.api.post.dto.request.PostListRequest;
import com.cocos.cocos.api.post.dto.request.PostRequest;
import com.cocos.cocos.api.post.dto.response.*;
import com.cocos.cocos.common.response.BaseResponse;
Expand All @@ -10,6 +11,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;

@Tag(name = "Post Controller", description = "๊ฒŒ์‹œ๊ธ€ ๊ด€๋ จ API")
public interface PostControllerSwagger {
Expand Down Expand Up @@ -52,4 +54,13 @@ public interface PostControllerSwagger {
description = "์‚ฌ์šฉ์ž ๊ฒŒ์‹œ๊ธ€ ์กฐํšŒ ์„ฑ๊ณต")
@Parameter(name = "nickname", description = "๋ชจ๋ชจ", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "String"))
public ResponseEntity<BaseResponse<MemberPostsResponse>> getMemberPosts(final String nickname);


@Operation(summary = "๊ฒŒ์‹œ๊ธ€ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ API", description = "์‚ฌ์šฉ์ž ๊ฒŒ์‹œ๊ธ€์„ ์กฐํšŒํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.")
@ApiResponse(
responseCode = "200",
description = "๊ฒŒ์‹œ๊ธ€ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ ์„ฑ๊ณต")
public ResponseEntity<BaseResponse<PostListResponse>> getPosts(
@RequestBody final PostListRequest postListRequest
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public record PostListRequest(
@Schema(description = "๋งˆ์ง€๋ง‰ ๊ฒŒ์‹œ๊ธ€ ์ข‹์•„์š” ์ˆ˜ ์•„์ด๋””", example = "1 or null")
Long likeCount,
@Schema(description = "๋งˆ์ง€๋ง‰ ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ์ผ", example = "YYYY-MM-DD~ or null")
LocalDateTime createAt
LocalDateTime createdAt
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.List;

public record SearchResponse(
@Schema(description = "๊ฒ€์ƒ‰ ๋‚ด์—ญ", example = "1")
@Schema(description = "๊ฒ€์ƒ‰ ๋‚ด์—ญ")
List<KeywordResponse> keywords
) {
public static SearchResponse of(final List<KeywordResponse> keywords) {
Expand Down

0 comments on commit 5d1ee4f

Please sign in to comment.