From 02a38bfe0146b6b085b96c79b6ab58ffe64779aa Mon Sep 17 00:00:00 2001 From: juhyun Date: Fri, 20 Feb 2026 23:23:35 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor=20:=20comment=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../retrospective/api/MeetingRetrospectiveApi.java | 9 +++++---- .../controller/MeetingRetrospectiveController.java | 6 +++--- .../dto/response/MeetingRetrospectiveResponse.java | 3 +++ .../retrospective/entity/MeetingRetrospective.java | 1 - .../repository/RetrospectiveRepository.java | 6 +++--- .../service/MeetingRetrospectiveService.java | 12 +++++------- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java b/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java index e91fd3a..29b8dc7 100644 --- a/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java +++ b/src/main/java/com/dokdok/retrospective/api/MeetingRetrospectiveApi.java @@ -52,6 +52,7 @@ public interface MeetingRetrospectiveApi { "meetingName": "데미안을 읽어보아요", "meetingDate": "2026-01-15", "meetingTime": "19:00-20:00", + "meetingLeaderId": 123, "gathering": { "gatheringId": 1, "gatheringName": "독서 모임" @@ -285,11 +286,11 @@ ResponseEntity> create summary = "공동 회고 코멘트 삭제 (developer: 오주현)", description = """ 약속에 대한 공동 회고 코멘트를 삭제합니다. - - 권한: 작성자 또는 모임장 + - 권한: 작성자 또는 약속장 """, parameters = { @Parameter(name = "meetingId", description = "약속 식별자", in = ParameterIn.PATH, required = true), - @Parameter(name = "meetingRetrospectiveId", description = "공동 회고 식별자", in = ParameterIn.PATH, required = true) + @Parameter(name = "commentId", description = "코멘트 식별자", in = ParameterIn.PATH, required = true) } ) @ApiResponses({ @@ -315,10 +316,10 @@ ResponseEntity> create {"code": "E000", "message": "서버 에러가 발생했습니다. 담당자에게 문의 바랍니다.", "data": null} """))) }) - @DeleteMapping(path = "/{meetingRetrospectiveId}", produces = MediaType.APPLICATION_JSON_VALUE) + @DeleteMapping(path = "/{commentId}", produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity> deleteMeetingRetrospective( @PathVariable Long meetingId, - @PathVariable Long meetingRetrospectiveId + @PathVariable Long commentId ); @Operation( diff --git a/src/main/java/com/dokdok/retrospective/controller/MeetingRetrospectiveController.java b/src/main/java/com/dokdok/retrospective/controller/MeetingRetrospectiveController.java index 8af9f33..33df3f3 100644 --- a/src/main/java/com/dokdok/retrospective/controller/MeetingRetrospectiveController.java +++ b/src/main/java/com/dokdok/retrospective/controller/MeetingRetrospectiveController.java @@ -59,12 +59,12 @@ public ResponseEntity> } @Override - @DeleteMapping("/{meetingRetrospectiveId}") + @DeleteMapping("/{commentId}") public ResponseEntity> deleteMeetingRetrospective( @PathVariable Long meetingId, - @PathVariable Long meetingRetrospectiveId + @PathVariable Long commentId ) { - meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, meetingRetrospectiveId); + meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, commentId); return ApiResponse.deleted("공동 회고 코멘트 삭제 완료"); } 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 1f6c338..7a14295 100644 --- a/src/main/java/com/dokdok/retrospective/dto/response/MeetingRetrospectiveResponse.java +++ b/src/main/java/com/dokdok/retrospective/dto/response/MeetingRetrospectiveResponse.java @@ -23,6 +23,8 @@ public record MeetingRetrospectiveResponse( LocalDate meetingDate, @Schema(description = "약속 시간", example = "14:00") String meetingTime, + @Schema(description = "약속장 ID", example = "123") + Long meetingLeaderId, @Schema(description = "모임 정보") MeetingResponse.GatheringInfo gathering, @Schema(description = "주제 목록") @@ -37,6 +39,7 @@ public static MeetingRetrospectiveResponse from ( .meetingName(meeting.getMeetingName()) .meetingDate(meeting.getMeetingStartDate().toLocalDate()) .meetingTime(meeting.getFormattedTime()) + .meetingLeaderId(meeting.getMeetingLeader().getId()) .gathering(MeetingResponse.GatheringInfo.from(meeting.getGathering())) .topics(topics) .build(); diff --git a/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java b/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java index 11a8592..4ab7ce9 100644 --- a/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java +++ b/src/main/java/com/dokdok/retrospective/entity/MeetingRetrospective.java @@ -2,7 +2,6 @@ import com.dokdok.global.BaseTimeEntity; import com.dokdok.meeting.entity.Meeting; -import com.dokdok.topic.entity.Topic; import com.dokdok.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java b/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java index e194279..095d112 100644 --- a/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java +++ b/src/main/java/com/dokdok/retrospective/repository/RetrospectiveRepository.java @@ -20,7 +20,7 @@ public interface RetrospectiveRepository extends JpaRepository findByTopicIdFirstPage( + List findByMeetingIdFirstPage( @Param("meetingId") Long meetingId, Pageable pageable ); @@ -31,7 +31,7 @@ List findByTopicIdFirstPage( "AND (mr.createdAt < :cursorCreatedAt " + " OR (mr.createdAt = :cursorCreatedAt AND mr.id < :cursorCommentId)) " + "ORDER BY mr.createdAt DESC, mr.id DESC") - List findByTopicIdAfterCursor( + List findByMeetingIdAfterCursor( @Param("meetingId") Long meetingId, @Param("cursorCreatedAt") LocalDateTime cursorCreatedAt, @Param("cursorCommentId") Long cursorCommentId, @@ -39,5 +39,5 @@ List findByTopicIdAfterCursor( ); @Query("SELECT COUNT(mr) FROM MeetingRetrospective mr WHERE mr.meeting.id = :meetingId") - int countByTopicId(@Param("meetingId") Long meetingId); + int countByMeetingId(@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 e84c5c1..e0ad51c 100644 --- a/src/main/java/com/dokdok/retrospective/service/MeetingRetrospectiveService.java +++ b/src/main/java/com/dokdok/retrospective/service/MeetingRetrospectiveService.java @@ -18,7 +18,6 @@ import com.dokdok.topic.entity.TopicStatus; import com.dokdok.topic.repository.TopicAnswerRepository; import com.dokdok.topic.repository.TopicRepository; -import com.dokdok.topic.service.TopicValidator; import com.dokdok.user.entity.User; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; @@ -41,7 +40,6 @@ public class MeetingRetrospectiveService { private final TopicRetrospectiveSummaryRepository topicRetrospectiveSummaryRepository; private final RetrospectiveRepository retrospectiveRepository; private final MeetingValidator meetingValidator; - private final TopicValidator topicValidator; private final StorageService storageService; private final TopicAnswerRepository topicAnswerRepository; @@ -115,11 +113,11 @@ public MeetingRetrospectiveResponse.CommentResponse createMeetingRetrospective( } @Transactional - public void deleteMeetingRetrospective(Long meetingId, Long meetingRetrospectiveId) { + public void deleteMeetingRetrospective(Long meetingId, Long commentId) { Long userId = SecurityUtil.getCurrentUserId(); MeetingRetrospective retrospective = retrospectiveRepository - .findByIdAndMeetingId(meetingRetrospectiveId, meetingId) + .findByIdAndMeetingId(commentId, meetingId) .orElseThrow(() -> new RetrospectiveException(RetrospectiveErrorCode.MEETING_RETROSPECTIVE_NOT_FOUND)); retrospectiveValidator.validateMeetingRetrospectiveDeletePermission(retrospective, userId); @@ -151,8 +149,8 @@ private CursorResponse comments = isFirstPage - ? retrospectiveRepository.findByTopicIdFirstPage(meetingId, pageable) - : retrospectiveRepository.findByTopicIdAfterCursor(meetingId, cursorCreatedAt, cursorCommentId, pageable); + ? retrospectiveRepository.findByMeetingIdFirstPage(meetingId, pageable) + : retrospectiveRepository.findByMeetingIdAfterCursor(meetingId, cursorCreatedAt, cursorCommentId, pageable); boolean hasNext = comments.size() > pageSize; List pageComments = hasNext @@ -164,7 +162,7 @@ private CursorResponse Date: Fri, 20 Feb 2026 23:29:45 +0900 Subject: [PATCH 2/2] =?UTF-8?q?refactor=20:=20testcode=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MeetingRetrospectiveServiceTest.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/test/java/com/dokdok/retrospective/service/MeetingRetrospectiveServiceTest.java b/src/test/java/com/dokdok/retrospective/service/MeetingRetrospectiveServiceTest.java index 7f9a125..c1331ff 100644 --- a/src/test/java/com/dokdok/retrospective/service/MeetingRetrospectiveServiceTest.java +++ b/src/test/java/com/dokdok/retrospective/service/MeetingRetrospectiveServiceTest.java @@ -142,10 +142,12 @@ void getMeetingRetrospective_withNoComments_success() { Long userId = 1L; Long gatheringId = 1L; + User leader = User.builder().id(userId).nickname("리더").build(); Gathering gathering = Gathering.builder().id(gatheringId).build(); Meeting meeting = Meeting.builder() .id(meetingId) .gathering(gathering) + .meetingLeader(leader) .meetingName("모임") .meetingStartDate(LocalDateTime.of(2026, 1, 15, 19, 0)) .meetingEndDate(LocalDateTime.of(2026, 1, 15, 21, 0)) @@ -289,14 +291,14 @@ void createMeetingRetrospective_throwsWhenNoAccess() { @DisplayName("공동 회고 삭제를 정상적으로 수행한다") void deleteMeetingRetrospective_success() { Long meetingId = 1L; - Long retrospectiveId = 10L; + Long commentId = 10L; Long userId = 1L; Gathering gathering = Gathering.builder().id(1L).build(); Meeting meeting = Meeting.builder().id(meetingId).gathering(gathering).build(); User user = User.builder().id(userId).build(); MeetingRetrospective retrospective = MeetingRetrospective.builder() - .id(retrospectiveId) + .id(commentId) .meeting(meeting) .createdBy(user) .build(); @@ -304,12 +306,12 @@ void deleteMeetingRetrospective_success() { try (MockedStatic securityUtilMock = mockStatic(SecurityUtil.class)) { securityUtilMock.when(SecurityUtil::getCurrentUserId).thenReturn(userId); - when(retrospectiveRepository.findByIdAndMeetingId(retrospectiveId, meetingId)) + when(retrospectiveRepository.findByIdAndMeetingId(commentId, meetingId)) .thenReturn(Optional.of(retrospective)); doNothing().when(retrospectiveValidator) .validateMeetingRetrospectiveDeletePermission(retrospective, userId); - meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, retrospectiveId); + meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, commentId); verify(retrospectiveRepository).delete(retrospective); } @@ -319,16 +321,16 @@ void deleteMeetingRetrospective_success() { @DisplayName("공동 회고가 없으면 삭제 시 예외가 발생한다") void deleteMeetingRetrospective_throwsWhenNotFound() { Long meetingId = 1L; - Long retrospectiveId = 10L; + Long commentId = 10L; Long userId = 1L; try (MockedStatic securityUtilMock = mockStatic(SecurityUtil.class)) { securityUtilMock.when(SecurityUtil::getCurrentUserId).thenReturn(userId); - when(retrospectiveRepository.findByIdAndMeetingId(retrospectiveId, meetingId)) + when(retrospectiveRepository.findByIdAndMeetingId(commentId, meetingId)) .thenReturn(Optional.empty()); - assertThatThrownBy(() -> meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, retrospectiveId)) + assertThatThrownBy(() -> meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, commentId)) .isInstanceOf(RetrospectiveException.class) .hasFieldOrPropertyWithValue("errorCode", RetrospectiveErrorCode.MEETING_RETROSPECTIVE_NOT_FOUND); @@ -340,14 +342,14 @@ void deleteMeetingRetrospective_throwsWhenNotFound() { @DisplayName("공동 회고 삭제 권한이 없으면 예외가 발생한다") void deleteMeetingRetrospective_throwsWhenForbidden() { Long meetingId = 1L; - Long retrospectiveId = 10L; + Long commentId = 10L; Long userId = 2L; Gathering gathering = Gathering.builder().id(1L).build(); Meeting meeting = Meeting.builder().id(meetingId).gathering(gathering).build(); User user = User.builder().id(1L).build(); MeetingRetrospective retrospective = MeetingRetrospective.builder() - .id(retrospectiveId) + .id(commentId) .meeting(meeting) .createdBy(user) .build(); @@ -355,12 +357,12 @@ void deleteMeetingRetrospective_throwsWhenForbidden() { try (MockedStatic securityUtilMock = mockStatic(SecurityUtil.class)) { securityUtilMock.when(SecurityUtil::getCurrentUserId).thenReturn(userId); - when(retrospectiveRepository.findByIdAndMeetingId(retrospectiveId, meetingId)) + when(retrospectiveRepository.findByIdAndMeetingId(commentId, meetingId)) .thenReturn(Optional.of(retrospective)); doThrow(new GatheringException(GatheringErrorCode.NOT_GATHERING_LEADER)) .when(retrospectiveValidator).validateMeetingRetrospectiveDeletePermission(retrospective, userId); - assertThatThrownBy(() -> meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, retrospectiveId)) + assertThatThrownBy(() -> meetingRetrospectiveService.deleteMeetingRetrospective(meetingId, commentId)) .isInstanceOf(GatheringException.class) .hasFieldOrPropertyWithValue("errorCode", GatheringErrorCode.NOT_GATHERING_LEADER);