-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature] 알림 기능 구현 #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[Feature] 알림 기능 구현 #265
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
31 changes: 31 additions & 0 deletions
31
src/main/java/hanium/modic/backend/common/property/property/NotificationProperties.java
This file contains hidden or 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,31 @@ | ||
| package hanium.modic.backend.common.property.property; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @ConfigurationProperties(prefix = "notification") | ||
| public class NotificationProperties { | ||
|
|
||
| /** | ||
| * 읽은 알림을 얼마 동안 유지할지(분 단위) | ||
| */ | ||
| private long readRetentionMinutes = Duration.ofDays(30).toMinutes(); // 기본값: 30일 | ||
|
|
||
| public long getReadRetentionMinutes() { | ||
| return readRetentionMinutes; | ||
| } | ||
|
|
||
| public void setReadRetentionMinutes(long readRetentionMinutes) { | ||
| this.readRetentionMinutes = readRetentionMinutes; | ||
| } | ||
|
|
||
| public Duration getReadRetentionDuration() { | ||
| return Duration.ofMinutes(readRetentionMinutes); | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
src/main/java/hanium/modic/backend/common/scheduler/DailyScheduler.java
This file contains hidden or 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,20 @@ | ||
| package hanium.modic.backend.common.scheduler; | ||
|
|
||
| import org.springframework.scheduling.annotation.Scheduled; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import hanium.modic.backend.domain.notification.service.NotificationService; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class DailyScheduler { | ||
|
|
||
| private final NotificationService notificationService; | ||
|
|
||
| // 매일 자정(00:00:00)에 실행 | ||
| @Scheduled(cron = "0 0 0 * * *") | ||
| public void runEveryMidnight() { | ||
| notificationService.cleanupExpiredNotifications(); | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/hanium/modic/backend/common/scheduler/config/SchedulingConfig.java
This file contains hidden or 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,9 @@ | ||
| package hanium.modic.backend.common.scheduler.config; | ||
|
|
||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
|
||
| @Configuration | ||
| @EnableScheduling | ||
| public class SchedulingConfig { | ||
| } |
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...main/java/hanium/modic/backend/domain/ai/aiServer/listener/AiImageCreatedDlqListener.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
src/main/java/hanium/modic/backend/domain/ai/aiServer/listener/AiImageCreatedListener.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
src/main/java/hanium/modic/backend/domain/ai/aiServer/listener/DlqListener.java
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
30 changes: 30 additions & 0 deletions
30
src/main/java/hanium/modic/backend/domain/notification/dto/GetNotificationsResponse.java
This file contains hidden or 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,30 @@ | ||
| package hanium.modic.backend.domain.notification.dto; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import hanium.modic.backend.domain.notification.entity.NotificationEntity; | ||
| import hanium.modic.backend.domain.notification.enums.NotificationStatus; | ||
| import hanium.modic.backend.domain.notification.enums.NotificationType; | ||
|
|
||
| public record GetNotificationsResponse( | ||
| Long notificationId, | ||
| NotificationType type, | ||
| NotificationStatus status, | ||
| String title, | ||
| String body, | ||
| Long postId, | ||
| LocalDateTime createdAt | ||
| ) { | ||
|
|
||
| public static GetNotificationsResponse of(NotificationEntity entity, NotificationPayload payload) { | ||
| return new GetNotificationsResponse( | ||
| entity.getId(), | ||
| entity.getType(), | ||
| entity.getStatus(), | ||
| entity.getTitle(), | ||
| entity.getBody(), | ||
| payload.postId(), | ||
| entity.getCreateAt() | ||
| ); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/main/java/hanium/modic/backend/domain/notification/dto/GetUnreadCountResponse.java
This file contains hidden or 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,6 @@ | ||
| package hanium.modic.backend.domain.notification.dto; | ||
|
|
||
| public record GetUnreadCountResponse( | ||
| long unreadCount | ||
| ) { | ||
| } |
71 changes: 71 additions & 0 deletions
71
src/main/java/hanium/modic/backend/domain/notification/dto/NotificationPayload.java
This file contains hidden or 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,71 @@ | ||
| package hanium.modic.backend.domain.notification.dto; | ||
|
|
||
| public record NotificationPayload( | ||
| Long senderId, | ||
| String senderNickname, | ||
| String senderEmail, // 추가됨 | ||
| Long postId, | ||
| String postTitle, | ||
| Long amount, | ||
| String reviewContent | ||
| ) { | ||
|
|
||
| public static NotificationPayload empty() { | ||
| return new NotificationPayload( | ||
| null, null, null, null, null, null, null | ||
| ); | ||
| } | ||
|
|
||
| public static Builder builder(Long senderId, String senderNickname, String senderEmail) { | ||
| return new Builder(senderId, senderNickname, senderEmail); | ||
| } | ||
|
|
||
| public static class Builder { | ||
| private final Long senderId; | ||
| private final String senderNickname; | ||
| private final String senderEmail; | ||
|
|
||
| private Long postId; | ||
| private String postTitle; | ||
| private Long amount; | ||
| private String reviewContent; | ||
|
|
||
| public Builder(Long senderId, String senderNickname, String senderEmail) { | ||
| this.senderId = senderId; | ||
| this.senderNickname = senderNickname; | ||
| this.senderEmail = senderEmail; | ||
| } | ||
|
|
||
| public Builder postId(Long postId) { | ||
| this.postId = postId; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder postTitle(String postTitle) { | ||
| this.postTitle = postTitle; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder amount(Long amount) { | ||
| this.amount = amount; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder reviewContent(String reviewContent) { | ||
| this.reviewContent = reviewContent; | ||
| return this; | ||
| } | ||
|
|
||
| public NotificationPayload build() { | ||
| return new NotificationPayload( | ||
| senderId, | ||
| senderNickname, | ||
| senderEmail, | ||
| postId, | ||
| postTitle, | ||
| amount, | ||
| reviewContent | ||
| ); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
중복된 getter/setter를 제거하세요.
Lombok의
@Getter와@Setter어노테이션을 사용하면서 Line 20-26에서 명시적으로 getter/setter를 다시 정의하고 있어 중복입니다.다음 중 하나를 선택하세요:
권장 방안: Lombok 어노테이션 유지
@Getter @Setter @ConfigurationProperties(prefix = "notification") public class NotificationProperties { /** * 읽은 알림을 얼마 동안 유지할지(분 단위) */ private long readRetentionMinutes = Duration.ofDays(30).toMinutes(); // 기본값: 30일 - public long getReadRetentionMinutes() { - return readRetentionMinutes; - } - - public void setReadRetentionMinutes(long readRetentionMinutes) { - this.readRetentionMinutes = readRetentionMinutes; - } - public Duration getReadRetentionDuration() { return Duration.ofMinutes(readRetentionMinutes); } }📝 Committable suggestion
🤖 Prompt for AI Agents