Skip to content

Commit

Permalink
feat: 버전 호환성에 대응하는 api로 변경해요
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Dec 5, 2024
1 parent 50bd26e commit 36d88fe
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
19 changes: 12 additions & 7 deletions post/src/main/java/com/oing/controller/VoiceCommentController.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.oing.controller;

import com.oing.domain.CommentType;
import com.oing.dto.request.CreatePostCommentRequest;
import com.oing.dto.response.DefaultResponse;
import com.oing.dto.response.PaginationResponse;
import com.oing.dto.response.PostVoiceCommentResponse;
import com.oing.dto.response.PostCommentResponseV2;
import com.oing.restapi.VoiceCommentApi;
import org.springframework.stereotype.Controller;

Expand All @@ -13,12 +14,14 @@
@Controller
public class VoiceCommentController implements VoiceCommentApi {
@Override
public PostVoiceCommentResponse createPostVoiceComment(String postId,
CreatePostCommentRequest request, String loginMemberId) {
return new PostVoiceCommentResponse(
public PostCommentResponseV2 createPostVoiceComment(String postId,
CreatePostCommentRequest request, String loginMemberId) {
return new PostCommentResponseV2(
"01HGW2N7EHJVJ4CJ999RRS2E97",
CommentType.VOICE,
postId,
loginMemberId,
"앱 버전 업데이트 후에 확인할 수 있는 댓글이에요",
"https://..",
ZonedDateTime.now()
);
Expand All @@ -30,18 +33,20 @@ public DefaultResponse deletePostVoiceComment(String postId, String commentId, S
}

@Override
public PaginationResponse<PostVoiceCommentResponse> getPostComments(String postId, Integer page, Integer size,
String sort, String loginMemberId) {
public PaginationResponse<PostCommentResponseV2> getPostComments(String postId, Integer page, Integer size,
String sort, String loginMemberId) {
return new PaginationResponse<>(
1,
1,
size,
false,
List.of(
new PostVoiceCommentResponse(
new PostCommentResponseV2(
"01HGW2N7EHJVJ4CJ999RRS2E97",
CommentType.VOICE,
postId,
loginMemberId,
"앱 버전 업데이트 후에 확인할 수 있는 댓글이에요",
"https://..",
ZonedDateTime.now()
)
Expand Down
5 changes: 5 additions & 0 deletions post/src/main/java/com/oing/domain/CommentType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.oing.domain;

public enum CommentType {
VOICE, TEXT
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
package com.oing.dto.response;

import com.oing.domain.CommentType;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime;

@Schema(description = "피드 게시물 음성 댓글 응답")
public record PostVoiceCommentResponse(
@Schema(description = "피드 게시물 음성 댓글 + 일반 댓글 응답")
public record PostCommentResponseV2(
@Schema(description = "피드 게시물 댓글 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
String commentId,

@Schema(description = "타입", example = "VOICE")
CommentType type,

@Schema(description = "피드 게시물 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
String postId,

@Schema(description = "음성 댓글 작성 사용자 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
String memberId,

@Schema(description = "피드 게시물 내용", example = "정말 환상적인 하루였네요!")
String comment,

@Schema(description = "음성 댓글 오디오 URL", example = "https://..")
String audioUrl,

Expand Down
6 changes: 3 additions & 3 deletions post/src/main/java/com/oing/restapi/VoiceCommentApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.oing.dto.request.CreatePostCommentRequest;
import com.oing.dto.response.DefaultResponse;
import com.oing.dto.response.PaginationResponse;
import com.oing.dto.response.PostVoiceCommentResponse;
import com.oing.dto.response.PostCommentResponseV2;
import com.oing.util.security.LoginMemberId;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -19,7 +19,7 @@
public interface VoiceCommentApi {
@Operation(summary = "게시물 음성 댓글 추가", description = "게시물에 음성 댓글을 추가합니다.")
@PostMapping
PostVoiceCommentResponse createPostVoiceComment(
PostCommentResponseV2 createPostVoiceComment(
@Parameter(description = "게시물 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
@PathVariable
String postId,
Expand Down Expand Up @@ -51,7 +51,7 @@ DefaultResponse deletePostVoiceComment(

@Operation(summary = "게시물 음성 댓글 조회", description = "게시물에 달린 음성 댓글을 조회합니다.")
@GetMapping
PaginationResponse<PostVoiceCommentResponse> getPostComments(
PaginationResponse<PostCommentResponseV2> getPostComments(
@Parameter(description = "게시물 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
@PathVariable
String postId,
Expand Down

0 comments on commit 36d88fe

Please sign in to comment.