Skip to content

Commit

Permalink
refactor : 알림 목록 조회 DTO 네이밍 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
java-saeng committed Oct 5, 2023
1 parent 882fd09 commit e3b37d0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,8 +75,8 @@ void test_find() throws Exception {
fieldWithPath("[].createdAt").description("알림 생성 시간")
);

final List<NotificationAllResponse> responses = List.of(
new NotificationAllResponse(
final List<NotificationDetailResponse> responses = List.of(
new NotificationDetailResponse(
1L,
NotificationType.COMMENT,
commentJsonData1,
Expand All @@ -85,7 +85,7 @@ void test_find() throws Exception {
225L,
LocalDateTime.now()
),
new NotificationAllResponse(
new NotificationDetailResponse(
1L,
NotificationType.EVENT,
eventJsonData1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +25,7 @@ public class NotificationApi {
private final NotificationCommandService notificationCommandService;

@GetMapping("/notifications")
public List<NotificationAllResponse> find(
public List<NotificationDetailResponse> find(
final Member authMember,
@RequestParam("member-id") final Long loginMemberId
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,12 +17,12 @@ public class NotificationQueryService {

private final NotificationRepository notificationRepository;

public List<NotificationAllResponse> findAllByMemberId(final Member authMember, final Long loginMemberId) {
public List<NotificationDetailResponse> findAllByMemberId(final Member authMember, final Long loginMemberId) {
validateSameMember(authMember, loginMemberId);

return notificationRepository.findAllByReceiverId(loginMemberId)
.stream()
.map(NotificationAllResponse::from)
.map(NotificationDetailResponse::from)
.collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@RequiredArgsConstructor
@Getter
public class NotificationAllResponse {
public class NotificationDetailResponse {

private final Long notificationId;
private final NotificationType type;
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,13 +76,13 @@ void test_findAllByMemberId() throws Exception {
)
);

final List<NotificationAllResponse> expect = List.of(
NotificationAllResponse.from(notification1),
NotificationAllResponse.from(notification2)
final List<NotificationDetailResponse> expect = List.of(
NotificationDetailResponse.from(notification1),
NotificationDetailResponse.from(notification2)
);

//when
final List<NotificationAllResponse> actual = notificationQueryService.findAllByMemberId(
final List<NotificationDetailResponse> actual = notificationQueryService.findAllByMemberId(
loginMember, loginMember.getId()
);

Expand Down

0 comments on commit e3b37d0

Please sign in to comment.