Skip to content

Commit

Permalink
[OING-375] feat: 음성 댓글 관련 API 목을 추가해요 (#275)
Browse files Browse the repository at this point in the history
* feat: add voice comment apis

* feat: implement voice comment apis mock

* feat: 버전 호환성에 대응하는 api로 변경해요
  • Loading branch information
CChuYong authored Dec 5, 2024
1 parent e097272 commit f3f441b
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 0 deletions.
56 changes: 56 additions & 0 deletions post/src/main/java/com/oing/controller/VoiceCommentController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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.PostCommentResponseV2;
import com.oing.restapi.VoiceCommentApi;
import org.springframework.stereotype.Controller;

import java.time.ZonedDateTime;
import java.util.List;

@Controller
public class VoiceCommentController implements VoiceCommentApi {
@Override
public PostCommentResponseV2 createPostVoiceComment(String postId,
CreatePostCommentRequest request, String loginMemberId) {
return new PostCommentResponseV2(
"01HGW2N7EHJVJ4CJ999RRS2E97",
CommentType.VOICE,
postId,
loginMemberId,
"앱 버전 업데이트 후에 확인할 수 있는 댓글이에요",
"https://..",
ZonedDateTime.now()
);
}

@Override
public DefaultResponse deletePostVoiceComment(String postId, String commentId, String loginMemberId) {
return DefaultResponse.ok();
}

@Override
public PaginationResponse<PostCommentResponseV2> getPostComments(String postId, Integer page, Integer size,
String sort, String loginMemberId) {
return new PaginationResponse<>(
1,
1,
size,
false,
List.of(
new PostCommentResponseV2(
"01HGW2N7EHJVJ4CJ999RRS2E97",
CommentType.VOICE,
postId,
loginMemberId,
"앱 버전 업데이트 후에 확인할 수 있는 댓글이에요",
"https://..",
ZonedDateTime.now()
)
)
);
}
}
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
@@ -0,0 +1,31 @@
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 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,

@Schema(description = "댓글 작성 시간", example = "2023-12-23T01:53:21.577347+09:00")
ZonedDateTime createdAt
) {

}
77 changes: 77 additions & 0 deletions post/src/main/java/com/oing/restapi/VoiceCommentApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.oing.restapi;

import com.oing.dto.request.CreatePostCommentRequest;
import com.oing.dto.response.DefaultResponse;
import com.oing.dto.response.PaginationResponse;
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;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import org.springframework.web.bind.annotation.*;

@Tag(name = "게시물 음성 댓글 API", description = "게시물 음성 댓글 관련 API")
@RestController
@Valid
@RequestMapping("/v1/posts/{postId}/voice-comments")
public interface VoiceCommentApi {
@Operation(summary = "게시물 음성 댓글 추가", description = "게시물에 음성 댓글을 추가합니다.")
@PostMapping
PostCommentResponseV2 createPostVoiceComment(
@Parameter(description = "게시물 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
@PathVariable
String postId,

@Valid
@RequestBody
CreatePostCommentRequest request,

@Parameter(hidden = true)
@LoginMemberId
String loginMemberId
);

@Operation(summary = "게시물 음성 댓글 삭제", description = "게시물에 음성 댓글을 삭제합니다.")
@DeleteMapping("/{commentId}")
DefaultResponse deletePostVoiceComment(
@Parameter(description = "게시물 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
@PathVariable
String postId,

@Parameter(description = "음성 댓글 ID", example = "01HGW2N7EHJVJ4CJ999RRS2E97")
@PathVariable
String commentId,

@Parameter(hidden = true)
@LoginMemberId
String loginMemberId
);

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

@RequestParam(required = false, defaultValue = "1")
@Parameter(description = "가져올 현재 페이지", example = "1")
@Min(value = 1)
Integer page,

@RequestParam(required = false, defaultValue = "10")
@Parameter(description = "가져올 페이지당 크기", example = "10")
@Min(value = 1)
Integer size,

@RequestParam(required = false)
@Parameter(description = "정렬 방식", example = "DESC | ASC")
String sort,

@Parameter(hidden = true)
@LoginMemberId
String loginMemberId
);
}

0 comments on commit f3f441b

Please sign in to comment.