From e3b37d06e65627d36ce0445ebb68ba1846b92d5c Mon Sep 17 00:00:00 2001 From: java-saeng Date: Thu, 5 Oct 2023 13:44:32 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=EC=95=8C=EB=A6=BC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20DTO=20=EB=84=A4=EC=9D=B4?= =?UTF-8?q?=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #663 --- .../java/com/emmsale/NotificationApiTest.java | 8 ++++---- .../com/emmsale/notification/api/NotificationApi.java | 4 ++-- .../application/NotificationQueryService.java | 6 +++--- ...llResponse.java => NotificationDetailResponse.java} | 6 +++--- .../application/NotificationQueryServiceTest.java | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) rename backend/emm-sale/src/main/java/com/emmsale/notification/application/dto/{NotificationAllResponse.java => NotificationDetailResponse.java} (87%) diff --git a/backend/emm-sale/src/documentTest/java/com/emmsale/NotificationApiTest.java b/backend/emm-sale/src/documentTest/java/com/emmsale/NotificationApiTest.java index f80b1c7ad..a1ec79211 100644 --- a/backend/emm-sale/src/documentTest/java/com/emmsale/NotificationApiTest.java +++ b/backend/emm-sale/src/documentTest/java/com/emmsale/NotificationApiTest.java @@ -17,7 +17,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.emmsale.notification.api.NotificationApi; -import com.emmsale.notification.application.dto.NotificationAllResponse; +import com.emmsale.notification.application.dto.NotificationDetailResponse; import com.emmsale.notification.application.dto.NotificationDeleteRequest; import com.emmsale.notification.domain.NotificationType; import java.time.LocalDateTime; @@ -75,8 +75,8 @@ void test_find() throws Exception { fieldWithPath("[].createdAt").description("알림 생성 시간") ); - final List responses = List.of( - new NotificationAllResponse( + final List responses = List.of( + new NotificationDetailResponse( 1L, NotificationType.COMMENT, commentJsonData1, @@ -85,7 +85,7 @@ void test_find() throws Exception { 225L, LocalDateTime.now() ), - new NotificationAllResponse( + new NotificationDetailResponse( 1L, NotificationType.EVENT, eventJsonData1, diff --git a/backend/emm-sale/src/main/java/com/emmsale/notification/api/NotificationApi.java b/backend/emm-sale/src/main/java/com/emmsale/notification/api/NotificationApi.java index 6fccc72c9..a4c12678b 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/notification/api/NotificationApi.java +++ b/backend/emm-sale/src/main/java/com/emmsale/notification/api/NotificationApi.java @@ -3,7 +3,7 @@ import com.emmsale.member.domain.Member; import com.emmsale.notification.application.NotificationCommandService; import com.emmsale.notification.application.NotificationQueryService; -import com.emmsale.notification.application.dto.NotificationAllResponse; +import com.emmsale.notification.application.dto.NotificationDetailResponse; import com.emmsale.notification.application.dto.NotificationDeleteRequest; import java.util.List; import lombok.RequiredArgsConstructor; @@ -25,7 +25,7 @@ public class NotificationApi { private final NotificationCommandService notificationCommandService; @GetMapping("/notifications") - public List find( + public List find( final Member authMember, @RequestParam("member-id") final Long loginMemberId ) { diff --git a/backend/emm-sale/src/main/java/com/emmsale/notification/application/NotificationQueryService.java b/backend/emm-sale/src/main/java/com/emmsale/notification/application/NotificationQueryService.java index 5d3868b33..ad5eb85d1 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/notification/application/NotificationQueryService.java +++ b/backend/emm-sale/src/main/java/com/emmsale/notification/application/NotificationQueryService.java @@ -4,7 +4,7 @@ import com.emmsale.member.domain.Member; import com.emmsale.member.exception.MemberException; -import com.emmsale.notification.application.dto.NotificationAllResponse; +import com.emmsale.notification.application.dto.NotificationDetailResponse; import com.emmsale.notification.domain.NotificationRepository; import java.util.List; import java.util.stream.Collectors; @@ -17,12 +17,12 @@ public class NotificationQueryService { private final NotificationRepository notificationRepository; - public List findAllByMemberId(final Member authMember, final Long loginMemberId) { + public List findAllByMemberId(final Member authMember, final Long loginMemberId) { validateSameMember(authMember, loginMemberId); return notificationRepository.findAllByReceiverId(loginMemberId) .stream() - .map(NotificationAllResponse::from) + .map(NotificationDetailResponse::from) .collect(Collectors.toList()); } diff --git a/backend/emm-sale/src/main/java/com/emmsale/notification/application/dto/NotificationAllResponse.java b/backend/emm-sale/src/main/java/com/emmsale/notification/application/dto/NotificationDetailResponse.java similarity index 87% rename from backend/emm-sale/src/main/java/com/emmsale/notification/application/dto/NotificationAllResponse.java rename to backend/emm-sale/src/main/java/com/emmsale/notification/application/dto/NotificationDetailResponse.java index 33658d3f0..be958286d 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/notification/application/dto/NotificationAllResponse.java +++ b/backend/emm-sale/src/main/java/com/emmsale/notification/application/dto/NotificationDetailResponse.java @@ -10,7 +10,7 @@ @RequiredArgsConstructor @Getter -public class NotificationAllResponse { +public class NotificationDetailResponse { private final Long notificationId; private final NotificationType type; @@ -22,8 +22,8 @@ public class NotificationAllResponse { @JsonFormat(pattern = "yyyy:MM:dd:HH:mm:ss") private final LocalDateTime createdAt; - public static NotificationAllResponse from(final Notification notification) { - return new NotificationAllResponse( + public static NotificationDetailResponse from(final Notification notification) { + return new NotificationDetailResponse( notification.getId(), notification.getType(), notification.getJsonData(), diff --git a/backend/emm-sale/src/test/java/com/emmsale/notification/application/NotificationQueryServiceTest.java b/backend/emm-sale/src/test/java/com/emmsale/notification/application/NotificationQueryServiceTest.java index 2e4b63cf2..dc41c2765 100644 --- a/backend/emm-sale/src/test/java/com/emmsale/notification/application/NotificationQueryServiceTest.java +++ b/backend/emm-sale/src/test/java/com/emmsale/notification/application/NotificationQueryServiceTest.java @@ -5,7 +5,7 @@ import com.emmsale.helper.ServiceIntegrationTestHelper; import com.emmsale.member.domain.Member; import com.emmsale.member.domain.MemberRepository; -import com.emmsale.notification.application.dto.NotificationAllResponse; +import com.emmsale.notification.application.dto.NotificationDetailResponse; import com.emmsale.notification.domain.Notification; import com.emmsale.notification.domain.NotificationRepository; import com.emmsale.notification.domain.NotificationType; @@ -76,13 +76,13 @@ void test_findAllByMemberId() throws Exception { ) ); - final List expect = List.of( - NotificationAllResponse.from(notification1), - NotificationAllResponse.from(notification2) + final List expect = List.of( + NotificationDetailResponse.from(notification1), + NotificationDetailResponse.from(notification2) ); //when - final List actual = notificationQueryService.findAllByMemberId( + final List actual = notificationQueryService.findAllByMemberId( loginMember, loginMember.getId() );