diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java b/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java index 6f7f6ec8..96a48b5f 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryController.java @@ -1,9 +1,9 @@ package coffeemeet.server.chatting.history.presentation; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP; +import coffeemeet.server.chatting.history.presentation.dto.ChattingHistoryCustomSlice; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; import coffeemeet.server.chatting.history.service.ChattingRoomHistoryService; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.common.annotation.Login; import coffeemeet.server.common.domain.AuthInfo; @@ -33,14 +33,14 @@ public ResponseEntity viewChattingRoomHistor } @GetMapping("/{roomHistoryId}") - public ResponseEntity viewChattingRoomMessageHistories( + public ResponseEntity viewChattingRoomMessageHistories( @PathVariable Long roomHistoryId, @RequestParam(defaultValue = "0") Long firstMessageId, @RequestParam(defaultValue = "50") int pageSize) { - ChattingMessageHistoryListDto chattingMessageHistoryListDto = chattingRoomHistoryService.searchChattingMessageHistories( + ChattingHistoryListDto chattingHistoryListDto = chattingRoomHistoryService.searchChattingMessageHistories( roomHistoryId, firstMessageId, pageSize); return ResponseEntity.ok( - ChattingMessageHistoriesHTTP.Response.from(chattingMessageHistoryListDto)); + ChattingHistoryCustomSlice.Response.from(chattingHistoryListDto)); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingHistoryCustomSlice.java similarity index 52% rename from src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java rename to src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingHistoryCustomSlice.java index a94fc10e..2907588d 100644 --- a/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingMessageHistoriesHTTP.java +++ b/src/main/java/coffeemeet/server/chatting/history/presentation/dto/ChattingHistoryCustomSlice.java @@ -3,20 +3,20 @@ import static lombok.AccessLevel.PRIVATE; import coffeemeet.server.chatting.history.service.dto.ChattingHistory; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import java.util.List; import lombok.NoArgsConstructor; @NoArgsConstructor(access = PRIVATE) -public final class ChattingMessageHistoriesHTTP { +public final class ChattingHistoryCustomSlice { public record Response( List chatHistories, boolean hasNext) { - public static Response from(ChattingMessageHistoryListDto chattingMessageHistoryListDto) { - return new Response(chattingMessageHistoryListDto.contents(), - chattingMessageHistoryListDto.hasNext()); + public static Response from(ChattingHistoryListDto chattingHistoryListDto) { + return new Response(chattingHistoryListDto.contents(), + chattingHistoryListDto.hasNext()); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java index 9e52eccf..70793a48 100644 --- a/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java +++ b/src/main/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryService.java @@ -7,7 +7,7 @@ import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; import coffeemeet.server.chatting.history.service.dto.ChattingHistory; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; import coffeemeet.server.user.implement.UserQuery; @@ -45,7 +45,7 @@ public List searchChattingRoomHistories(Long userId) { } // TODO: 11/20/23 캐쉬 로직 적용 - public ChattingMessageHistoryListDto searchChattingMessageHistories(Long roomHistoryId, + public ChattingHistoryListDto searchChattingMessageHistories(Long roomHistoryId, Long firstMessageId, int pageSize) { ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryQuery.getChattingRoomHistoryBy( roomHistoryId); @@ -58,7 +58,7 @@ public ChattingMessageHistoryListDto searchChattingMessageHistories(Long roomHis .map(chattingMessageHistory -> ChattingHistory.of( chattingMessageHistory.getUser(), chattingMessageHistory)) .toList(); - return ChattingMessageHistoryListDto.of(historyDtoList, hasNext); + return ChattingHistoryListDto.of(historyDtoList, hasNext); } } diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistoryListDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistoryListDto.java new file mode 100644 index 00000000..c4ae6751 --- /dev/null +++ b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingHistoryListDto.java @@ -0,0 +1,15 @@ +package coffeemeet.server.chatting.history.service.dto; + +import java.util.List; + +public record ChattingHistoryListDto( + List contents, + boolean hasNext +) { + + public static ChattingHistoryListDto of(List contents, + boolean hasNext) { + return new ChattingHistoryListDto(contents, hasNext); + } + +} diff --git a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java b/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java deleted file mode 100644 index 2270a8da..00000000 --- a/src/main/java/coffeemeet/server/chatting/history/service/dto/ChattingMessageHistoryListDto.java +++ /dev/null @@ -1,15 +0,0 @@ -package coffeemeet.server.chatting.history.service.dto; - -import java.util.List; - -public record ChattingMessageHistoryListDto( - List contents, - boolean hasNext -) { - - public static ChattingMessageHistoryListDto of(List contents, - boolean hasNext) { - return new ChattingMessageHistoryListDto(contents, hasNext); - } - -} diff --git a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java index 9aa0278a..ad455961 100644 --- a/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/presentation/ChattingRoomHistoryControllerTest.java @@ -17,10 +17,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import coffeemeet.server.auth.domain.RefreshToken; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP.Response; +import coffeemeet.server.chatting.history.presentation.dto.ChattingHistoryCustomSlice.Response; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; import coffeemeet.server.chatting.history.service.ChattingRoomHistoryService; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.common.config.ControllerTestConfig; import coffeemeet.server.common.fixture.AuthFixture; @@ -95,14 +95,14 @@ void viewChattingRoomMessageHistoriesTest() throws Exception { Long firstMessageId = 51L; int pageSize = 50; - ChattingMessageHistoryListDto chattingMessageHistoryListDto = ChattingFixture.chattingMessageHistoryListDto(); + ChattingHistoryListDto chattingHistoryListDto = ChattingFixture.chattingMessageHistoryListDto(); Response response = ChattingFixture.chattingMessageHistoriesHTTPResponse( - chattingMessageHistoryListDto); + chattingHistoryListDto); given(jwtTokenProvider.extractUserId(TOKEN)).willReturn(userId); given(chattingRoomHistoryService.searchChattingMessageHistories(roomHistoryId, firstMessageId, pageSize)).willReturn( - chattingMessageHistoryListDto); + chattingHistoryListDto); // when, then mockMvc.perform(get("/api/v1/chatting/room/histories/{roomHistoryId}", roomHistoryId) diff --git a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java index a3a376d8..268d7219 100644 --- a/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java +++ b/src/test/java/coffeemeet/server/chatting/history/service/ChattingRoomHistoryServiceTest.java @@ -8,7 +8,7 @@ import coffeemeet.server.chatting.history.implement.ChattingMessageHistoryQuery; import coffeemeet.server.chatting.history.implement.ChattingRoomHistoryQuery; import coffeemeet.server.chatting.history.implement.UserChattingHistoryQuery; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.common.fixture.ChattingFixture; import coffeemeet.server.user.implement.UserQuery; import java.util.List; @@ -67,7 +67,7 @@ void searchChattingMessageHistoriesTest(Long firstMessageId, int pageSize) { chattingMessageHistories); // when - ChattingMessageHistoryListDto responses = chattingRoomHistoryService.searchChattingMessageHistories( + ChattingHistoryListDto responses = chattingRoomHistoryService.searchChattingMessageHistories( roomHistoryId, firstMessageId, pageSize); diff --git a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java index e75ffb09..0fbf980e 100644 --- a/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java +++ b/src/test/java/coffeemeet/server/common/fixture/ChattingFixture.java @@ -12,9 +12,9 @@ import coffeemeet.server.chatting.history.domain.ChattingMessageHistory; import coffeemeet.server.chatting.history.domain.ChattingRoomHistory; import coffeemeet.server.chatting.history.domain.UserChattingHistory; -import coffeemeet.server.chatting.history.presentation.dto.ChattingMessageHistoriesHTTP; +import coffeemeet.server.chatting.history.presentation.dto.ChattingHistoryCustomSlice; import coffeemeet.server.chatting.history.presentation.dto.ChattingRoomHistoriesHTTP; -import coffeemeet.server.chatting.history.service.dto.ChattingMessageHistoryListDto; +import coffeemeet.server.chatting.history.service.dto.ChattingHistoryListDto; import coffeemeet.server.chatting.history.service.dto.ChattingRoomHistoryDto; import coffeemeet.server.user.domain.User; import java.util.List; @@ -125,18 +125,18 @@ public static ChattingRoomStatusHTTP.Response chatRoomStatusHTTPResponse( return ChattingRoomStatusHTTP.Response.from(chattingRoomStatusDto); } - public static ChattingMessageHistoryListDto chattingMessageHistoryListDto() { - return Instancio.of(ChattingMessageHistoryListDto.class) + public static ChattingHistoryListDto chattingMessageHistoryListDto() { + return Instancio.of(ChattingHistoryListDto.class) .create(); } - public static ChattingMessageHistoriesHTTP.Response chattingMessageHistoriesHTTPResponse( - ChattingMessageHistoryListDto chattingMessageHistoryListDto) { - return Instancio.of(ChattingMessageHistoriesHTTP.Response.class) - .set(field(ChattingMessageHistoriesHTTP.Response::chatHistories), - chattingMessageHistoryListDto.contents()) - .set(field(ChattingMessageHistoriesHTTP.Response::hasNext), - chattingMessageHistoryListDto.hasNext()) + public static ChattingHistoryCustomSlice.Response chattingMessageHistoriesHTTPResponse( + ChattingHistoryListDto chattingHistoryListDto) { + return Instancio.of(ChattingHistoryCustomSlice.Response.class) + .set(field(ChattingHistoryCustomSlice.Response::chatHistories), + chattingHistoryListDto.contents()) + .set(field(ChattingHistoryCustomSlice.Response::hasNext), + chattingHistoryListDto.hasNext()) .create(); }