-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from Team-Shaka/feature/84
✨ Feat: 알림 조회 문구의 구체화 및 읽음 처리 기능
- Loading branch information
Showing
13 changed files
with
231 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/treehouse/server/api/notification/business/NotificationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package treehouse.server.api.notification.business; | ||
|
||
import org.apache.commons.lang3.function.TriFunction; | ||
import treehouse.server.global.entity.member.Member; | ||
import treehouse.server.global.entity.notification.NotificationType; | ||
|
||
import java.util.EnumMap; | ||
import java.util.Map; | ||
|
||
public class NotificationUtil { | ||
|
||
private static final Map<NotificationType, String> titleMap = new EnumMap<>(NotificationType.class); | ||
private static final Map<NotificationType, TriFunction<Member, Long, String, String>> bodyMap = new EnumMap<>(NotificationType.class); | ||
|
||
static { | ||
titleMap.put(NotificationType.COMMENT, "댓글 알림"); | ||
titleMap.put(NotificationType.REPLY, "대댓글 알림"); | ||
titleMap.put(NotificationType.INVITATION, "초대 알림"); | ||
titleMap.put(NotificationType.POST_REACTION, "게시글 반응 알림"); | ||
titleMap.put(NotificationType.COMMENT_REACTION, "댓글 반응 알림"); | ||
|
||
bodyMap.put(NotificationType.COMMENT, (sender, targetId, reactionName) -> sender.getName() + " 님이 댓글을 남겼습니다."); | ||
bodyMap.put(NotificationType.REPLY, (sender, targetId, reactionName) -> sender.getName() + " 님이 답글을 남겼습니다."); | ||
bodyMap.put(NotificationType.INVITATION, (sender, targetId, reactionName) -> sender.getName() + " 님이 트리하우스에 초대했습니다."); | ||
bodyMap.put(NotificationType.POST_REACTION, (sender, targetId, reactionName) -> sender.getName() + " 님이 게시글에 " + reactionName + "을(를) 눌렀습니다."); | ||
bodyMap.put(NotificationType.COMMENT_REACTION, (sender, targetId, reactionName) -> sender.getName() + " 님이 댓글에 " + reactionName + "을(를) 눌렀습니다."); | ||
} | ||
|
||
public static String getTitle(NotificationType type) { | ||
return titleMap.getOrDefault(type, "Notification"); | ||
} | ||
|
||
public static String getBody(NotificationType type, Member sender, Long targetId, String reactionName) { | ||
return bodyMap.getOrDefault(type, (s, t, r) -> "알림이 있습니다.").apply(sender, targetId, reactionName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/treehouse/server/api/notification/implement/NotificationQueryAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
package treehouse.server.api.notification.implement; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import treehouse.server.api.notification.persistence.NotificationRepository; | ||
import treehouse.server.global.annotations.Adapter; | ||
import treehouse.server.global.entity.notification.Notification; | ||
import treehouse.server.global.exception.GlobalErrorCode; | ||
import treehouse.server.global.exception.ThrowClass.NotificationException; | ||
|
||
@Adapter | ||
@RequiredArgsConstructor | ||
public class NotificationQueryAdapter { | ||
|
||
private final NotificationRepository notificationRepository; | ||
public Notification findById(Long notificationId) { | ||
return notificationRepository.findById(notificationId) | ||
.orElseThrow(() -> new NotificationException(GlobalErrorCode.NOTIFICATION_NOT_FOUND)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/treehouse/server/api/notification/presentation/dto/NotificationRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package treehouse.server.api.notification.presentation.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import treehouse.server.api.notification.business.NotificationService; | ||
import treehouse.server.global.entity.notification.NotificationType; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class NotificationRequestDTO { | ||
|
||
@Getter | ||
@Setter | ||
public static class createNotification { | ||
|
||
private String title; | ||
private String body; | ||
private NotificationType type; | ||
private Long targetId; | ||
private Long receiverId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.