diff --git a/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java b/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java index 5932d308..e91fd3ad 100644 --- a/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java +++ b/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java @@ -114,9 +114,9 @@ ResponseEntity> getMeetingRetrospectiv ); @Operation( - summary = "토픽별 코멘트 조회 (developer: 오주현)", + summary = "코멘트 조회 (developer: 오주현)", description = """ - 특정 토픽의 코멘트를 조회합니다. + 약속 회고의 코멘트를 조회합니다. - 커서 기반 무한스크롤을 지원합니다. - 첫 페이지: cursorCreatedAt, cursorCommentId 없이 호출 - 다음 페이지: 응답의 nextCursor 값을 파라미터로 전달 @@ -133,11 +133,11 @@ ResponseEntity> getMeetingRetrospectiv examples = @ExampleObject(value = """ { "code": "SUCCESS", - "message": "토픽 코멘트 조회 성공", + "message": "코멘트 조회 성공", "data": { "items": [ { - "meetingRetrospectiveId": 1, + "commentId": 1, "userId": 1, "nickname": "사용자1", "profileImageUrl": "https://example.com/profile.jpg", @@ -179,21 +179,14 @@ ResponseEntity> getMeetingRetrospectiv ), @io.swagger.v3.oas.annotations.responses.ApiResponse( responseCode = "404", - description = "약속 또는 토픽을 찾을 수 없음", + description = "약속을 찾을 수 없음", content = @Content( mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ExampleObject( - name = "약속 없음", value = """ {"code": "M001", "message": "약속을 찾을 수 없습니다.", "data": null} """ - ), - @ExampleObject( - name = "토픽 없음", - value = """ - {"code": "T001", "message": "토픽을 찾을 수 없습니다.", "data": null} - """ ) } ) @@ -214,9 +207,6 @@ ResponseEntity> getMeetingRetro @GetMapping("/comments") public ResponseEntity>> getTopicComments( @PathVariable Long meetingId, - @RequestParam Long topicId, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime cursorCreatedAt, @RequestParam(required = false) Long cursorCommentId ) { CursorResponse response = - meetingRetrospectiveService.getTopicComments( - meetingId, topicId, pageSize, cursorCreatedAt, cursorCommentId + meetingRetrospectiveService.getComments( + meetingId, pageSize, cursorCreatedAt, cursorCommentId ); - return ApiResponse.success(response, "토픽 코멘트 조회 성공"); + return ApiResponse.success(response, "코멘트 조회 성공"); } @Override diff --git a/src/main/java/com/dokdok/retrospective/dto/request/MeetingRetrospectiveRequest.java b/src/main/java/com/dokdok/retrospective/dto/request/MeetingRetrospectiveRequest.java index 9a83f2f8..1ec20d8f 100644 --- a/src/main/java/com/dokdok/retrospective/dto/request/MeetingRetrospectiveRequest.java +++ b/src/main/java/com/dokdok/retrospective/dto/request/MeetingRetrospectiveRequest.java @@ -9,11 +9,6 @@ @Schema(description = "모임 회고 작성 요청") @Builder public record MeetingRetrospectiveRequest( - - @Schema(description = "주제 ID", example = "1", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull - Long topicId, - @Schema(description = "회고 코멘트 (공백 포함 500자 이내)", example = "이번 모임에서 핵심 논의가 잘 정리되었습니다.", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank @Size(max = 500, message = "회고 코멘트는 500자 이내로 작성해주세요.") diff --git a/src/main/java/com/dokdok/retrospective/dto/response/MeetingRetrospectiveResponse.java b/src/main/java/com/dokdok/retrospective/dto/response/MeetingRetrospectiveResponse.java index 6865eabd..1f6c338a 100644 --- a/src/main/java/com/dokdok/retrospective/dto/response/MeetingRetrospectiveResponse.java +++ b/src/main/java/com/dokdok/retrospective/dto/response/MeetingRetrospectiveResponse.java @@ -96,8 +96,8 @@ public static KeyPointResponse from(TopicRetrospectiveSummary.KeyPoint keyPoint) @Schema(description = "모임 회고 코멘트") @Builder public record CommentResponse( - @Schema(description = "모임 회고 ID", example = "1") - Long meetingRetrospectiveId, + @Schema(description = "코멘트 ID", example = "1") + Long commentId, @Schema(description = "작성자 사용자 ID", example = "1") Long userId, @Schema(description = "닉네임", example = "독서왕") @@ -112,7 +112,7 @@ public record CommentResponse( public static CommentResponse from(MeetingRetrospective retrospective, String presignedProfileImageUrl) { return CommentResponse.builder() - .meetingRetrospectiveId(retrospective.getId()) + .commentId(retrospective.getId()) .userId(retrospective.getCreatedBy().getId()) .nickname(retrospective.getCreatedBy().getNickname()) .profileImageUrl(presignedProfileImageUrl) diff --git a/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java b/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java index 3502a48e..11a85929 100644 --- a/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java +++ b/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java @@ -35,19 +35,14 @@ public class MeetingRetrospective extends BaseTimeEntity { @JoinColumn(name = "created_by", nullable = false) private User createdBy; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "topic_id") - private Topic topic; - @Column(name = "comment", columnDefinition = "TEXT") private String comment; - public static MeetingRetrospective of(Meeting meeting, User user, Topic topic, String comment){ + public static MeetingRetrospective of(Meeting meeting, User user, String comment){ return MeetingRetrospective.builder() .meeting(meeting) .createdBy(user) - .topic(topic) - .comment(comment). - build(); + .comment(comment) + .build(); } } diff --git a/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java b/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java index 45ce38c8..e194279a 100644 --- a/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java +++ b/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java @@ -18,26 +18,26 @@ public interface RetrospectiveRepository extends JpaRepository findByTopicIdFirstPage( - @Param("topicId") Long topicId, + @Param("meetingId") Long meetingId, Pageable pageable ); @Query("SELECT mr FROM MeetingRetrospective mr " + "JOIN FETCH mr.createdBy " + - "WHERE mr.topic.id = :topicId " + + "WHERE mr.meeting.id = :meetingId " + "AND (mr.createdAt < :cursorCreatedAt " + " OR (mr.createdAt = :cursorCreatedAt AND mr.id < :cursorCommentId)) " + "ORDER BY mr.createdAt DESC, mr.id DESC") List findByTopicIdAfterCursor( - @Param("topicId") Long topicId, + @Param("meetingId") Long meetingId, @Param("cursorCreatedAt") LocalDateTime cursorCreatedAt, @Param("cursorCommentId") Long cursorCommentId, Pageable pageable ); - @Query("SELECT COUNT(mr) FROM MeetingRetrospective mr WHERE mr.topic.id = :topicId") - int countByTopicId(@Param("topicId") Long topicId); + @Query("SELECT COUNT(mr) FROM MeetingRetrospective mr WHERE mr.meeting.id = :meetingId") + int countByTopicId(@Param("meetingId") Long meetingId); } diff --git a/src/main/java/com/dokdok/retrospective/service/MeetingRetrospectiveService.java b/src/main/java/com/dokdok/retrospective/service/MeetingRetrospectiveService.java index 7979b0f3..e84c5c15 100644 --- a/src/main/java/com/dokdok/retrospective/service/MeetingRetrospectiveService.java +++ b/src/main/java/com/dokdok/retrospective/service/MeetingRetrospectiveService.java @@ -78,9 +78,8 @@ public MeetingRetrospectiveResponse getMeetingRetrospective(Long meetingId){ /** * 토픽별 코멘트 조회 (무한 스크롤) */ - public CursorResponse getTopicComments( + public CursorResponse getComments( Long meetingId, - Long topicId, int pageSize, LocalDateTime cursorCreatedAt, Long cursorCommentId @@ -90,9 +89,7 @@ public CursorResponse buildSummaryMap(List topics) } private CursorResponse fetchComments( - Long topicId, + Long meetingId, int pageSize, LocalDateTime cursorCreatedAt, Long cursorCommentId @@ -157,8 +151,8 @@ private CursorResponse comments = isFirstPage - ? retrospectiveRepository.findByTopicIdFirstPage(topicId, pageable) - : retrospectiveRepository.findByTopicIdAfterCursor(topicId, cursorCreatedAt, cursorCommentId, pageable); + ? retrospectiveRepository.findByTopicIdFirstPage(meetingId, pageable) + : retrospectiveRepository.findByTopicIdAfterCursor(meetingId, cursorCreatedAt, cursorCommentId, pageable); boolean hasNext = comments.size() > pageSize; List pageComments = hasNext @@ -170,7 +164,7 @@ private CursorResponse