Skip to content

Commit 13526b0

Browse files
committed
refactor: 알림 DTO에 카테고리, 썸네일, 알림 메시지 필드 추가
1 parent af15937 commit 13526b0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main/java/com/back/domain/notification/dto/NotificationItemDto.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.back.domain.notification.entity.Notification;
44
import com.back.domain.notification.enums.NotificationType;
5+
import com.back.domain.post.post.entity.PostImage;
56
import java.time.LocalDateTime;
67
import lombok.Builder;
78
import lombok.Getter;
@@ -13,18 +14,29 @@ public class NotificationItemDto {
1314
private NotificationType type;
1415
private Long postId;
1516
private String postTitle;
17+
private String postCategoryName;
18+
private String postThumbnailUrl;
19+
private String message;
1620
private boolean read;
1721
private LocalDateTime createdAt;
1822

1923
public static NotificationItemDto from(Notification n) {
24+
String categoryName = n.getPost().getCategory() != null ? n.getPost().getCategory().getName() : null;
25+
String thumbnailUrl = n.getPost().getImages().stream()
26+
.map(PostImage::getUrl)
27+
.findFirst()
28+
.orElse(null);
29+
2030
return NotificationItemDto.builder()
2131
.id(n.getId())
2232
.type(n.getType())
2333
.postId(n.getPost().getId())
2434
.postTitle(n.getPost().getTitle())
35+
.postCategoryName(categoryName)
36+
.postThumbnailUrl(thumbnailUrl)
37+
.message(n.getMessage())
2538
.read(n.isRead())
2639
.createdAt(n.getCreatedAt())
2740
.build();
2841
}
2942
}
30-

0 commit comments

Comments
 (0)