-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat : 설정 따른 알림 전송 #140
Merged
feat : 설정 따른 알림 전송 #140
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0ea0492
feat : 알림 설정 엔티티 생성
rladmstn b0a2561
refactor : 알림 세팅 필드명 수정
rladmstn 29b0e2e
feat : 그룹 생성, 가입 시 NotificationSetting 추가
rladmstn a654ce1
feat : 알림 목록 조회 API 추가
rladmstn 6123b3f
test : StudyGroupServiceTest에 NotificationSettingRepository 모킹 추가
rladmstn 743d2f0
Merge branch 'develop' into feat/#122
rladmstn 3295984
feat : NotificationMessage 케이스 별 알림 writing 추가
rladmstn 3557b7d
Resolve conflict
rladmstn 12d1345
feat : 알림 정보 조회 실패 예외 클래스 추가
rladmstn 3c463ba
test : 문제 시작 할 때 알림 전송 시, 알림 설정 모킹 추가
rladmstn 713a706
feat : 문제 시작 할 때 알림 전송 시, 알림 설정 로직 추가
rladmstn 3f7c324
feat : 풀이 생성 시 설정에 따라 그룹 멤버들에게 알림 전송 로직 추가
rladmstn 461d0b1
test : 풀이 생성 테스트 작성
rladmstn d624232
feat : 댓글 작성 시 설정 따른 알림 전송 로직 추가
rladmstn da51350
test : 댓글 작성 성공 시 설정 따른 알림 전송 테스트 작성
rladmstn b4cdeed
fix : 댓글 작성 시 알림 전송 메소드 오류 수정
rladmstn 21bc04c
fix : 댓글 작성 시 알림 전송 메소드 오류 repository 수정
rladmstn 0a7b7b1
test : CommentRepository 모킹 추가
rladmstn ea1b712
feat : 새로운 멤버 가입 시, 설정 따른 알림 전송 로직 추가
rladmstn 8988326
test : 새로운 멤버 가입 시, 설정 따른 알림 전송 테스트 추가 작성
rladmstn 2f29387
feat : 마감 날짜가 오늘인 문제들에 대해 설정 따른 알림 전송 로직 추가
rladmstn 2b8646b
test : 마감 날짜가 오늘인 문제들에 대해 설정 따른 알림 전송 테스트 추가 작성
rladmstn 9e8babe
feat : 그룹 제거 및 회원 탈퇴 시 notificationSetting 제거
rladmstn 0e0dc5f
test : 그룹 삭제 시 테스트 일부 수정
rladmstn c539756
feat : 알림 설정 수정 API 추가
rladmstn b4461de
test : 알림 설정 관련 API 테스트 작성
rladmstn 5a5dda3
Resolve conflict
rladmstn 658cc2c
Resolve conflict
rladmstn a416c3b
refactor : 알림 전송 로직을 NotificationService에 위임
rladmstn 67153a1
feat : 알림 전송할 때 알림 설정 조회 실패 시, error log 추가
rladmstn 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 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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/gamzabat/algohub/feature/notification/domain/NotificationSetting.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,55 @@ | ||
package com.gamzabat.algohub.feature.notification.domain; | ||
|
||
import com.gamzabat.algohub.feature.group.studygroup.domain.GroupMember; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.OneToOne; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
public class NotificationSetting { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private GroupMember member; | ||
|
||
private boolean allNotifications; | ||
private boolean newProblem; | ||
private boolean newSolution; | ||
private boolean newComment; | ||
private boolean newMember; | ||
private boolean deadlineReached; | ||
|
||
@Builder | ||
public NotificationSetting(GroupMember member) { | ||
this.member = member; | ||
this.allNotifications = true; | ||
this.newProblem = true; | ||
this.newSolution = true; | ||
this.newComment = true; | ||
this.newMember = true; | ||
this.deadlineReached = true; | ||
} | ||
|
||
public void editSettings(boolean all, boolean newProblem, boolean newSolution, boolean newComment, | ||
boolean newMember, boolean deadlineReached) { | ||
this.allNotifications = all; | ||
this.newProblem = newProblem; | ||
this.newSolution = newSolution; | ||
this.newComment = newComment; | ||
this.newMember = newMember; | ||
this.deadlineReached = deadlineReached; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...in/java/com/gamzabat/algohub/feature/notification/dto/EditNotificationSettingRequest.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,12 @@ | ||
package com.gamzabat.algohub.feature.notification.dto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record EditNotificationSettingRequest(@NotNull(message = "그룹 아이디는 필수 입력입니다.") Long groupId, | ||
boolean all, | ||
boolean newProblem, | ||
boolean newSolution, | ||
boolean newComment, | ||
boolean newMember, | ||
boolean deadlineReached) { | ||
} |
29 changes: 29 additions & 0 deletions
29
...in/java/com/gamzabat/algohub/feature/notification/dto/GetNotificationSettingResponse.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,29 @@ | ||
package com.gamzabat.algohub.feature.notification.dto; | ||
|
||
import com.gamzabat.algohub.feature.notification.domain.NotificationSetting; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record GetNotificationSettingResponse(Long groupId, | ||
String groupName, | ||
boolean allNotifications, | ||
boolean newProblem, | ||
boolean newSolution, | ||
boolean newComment, | ||
boolean newMember, | ||
boolean deadlineReached) { | ||
|
||
public static GetNotificationSettingResponse toDTO(NotificationSetting setting) { | ||
return GetNotificationSettingResponse.builder() | ||
.groupId(setting.getMember().getStudyGroup().getId()) | ||
.groupName(setting.getMember().getStudyGroup().getName()) | ||
.allNotifications(setting.isAllNotifications()) | ||
.newProblem(setting.isNewProblem()) | ||
.newSolution(setting.isNewSolution()) | ||
.newComment(setting.isNewComment()) | ||
.newMember(setting.isNewMember()) | ||
.deadlineReached(setting.isDeadlineReached()) | ||
.build(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/gamzabat/algohub/feature/notification/enums/NotificationCategory.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,19 @@ | ||
package com.gamzabat.algohub.feature.notification.enums; | ||
|
||
public enum NotificationCategory { | ||
PROBLEM_STARTED("[%s] 문제가 시작되었습니다! 지금 도전해보세요!"), | ||
NEW_SOLUTION_POSTED("%s님이 새로운 풀이를 등록했습니다! 풀이를 확인하고 의견을 나눠보세요."), | ||
NEW_MEMBER_JOINED("%s님이 스터디에 합류했습니다!"), | ||
NEW_COMMENT_POSTED("%s님이 내 풀이에 코멘트를 남겼습니다! 어떤 리뷰인지 확인해보세요."), | ||
PROBLEM_DEADLINE_REACHED("[%s] 문제의 마감이 오늘입니다! 아직 해결하지 못했다면 지금 도전해보세요!"); | ||
|
||
private final String message; | ||
|
||
NotificationCategory(String message) { | ||
this.message = message; | ||
} | ||
|
||
public String getMessage(Object... args) { | ||
return String.format(message, args); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
src/main/java/com/gamzabat/algohub/feature/notification/enums/NotificationMessage.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...zabat/algohub/feature/notification/exception/CannotFoundNotificationSettingException.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,12 @@ | ||
package com.gamzabat.algohub.feature.notification.exception; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class CannotFoundNotificationSettingException extends RuntimeException { | ||
private final String error; | ||
|
||
public CannotFoundNotificationSettingException(String error) { | ||
this.error = error; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...a/com/gamzabat/algohub/feature/notification/repository/NotificationSettingRepository.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,17 @@ | ||
package com.gamzabat.algohub.feature.notification.repository; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.gamzabat.algohub.feature.group.studygroup.domain.GroupMember; | ||
import com.gamzabat.algohub.feature.notification.domain.NotificationSetting; | ||
import com.gamzabat.algohub.feature.notification.repository.querydsl.CustomNotificationSettingRepository; | ||
|
||
public interface NotificationSettingRepository extends JpaRepository<NotificationSetting, Long>, | ||
CustomNotificationSettingRepository { | ||
|
||
Optional<NotificationSetting> findByMember(GroupMember member); | ||
|
||
void deleteByMember(GroupMember member); | ||
} |
13 changes: 13 additions & 0 deletions
13
...algohub/feature/notification/repository/querydsl/CustomNotificationSettingRepository.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,13 @@ | ||
package com.gamzabat.algohub.feature.notification.repository.querydsl; | ||
|
||
import java.util.List; | ||
|
||
import com.gamzabat.algohub.feature.group.studygroup.domain.StudyGroup; | ||
import com.gamzabat.algohub.feature.notification.domain.NotificationSetting; | ||
import com.gamzabat.algohub.feature.user.domain.User; | ||
|
||
public interface CustomNotificationSettingRepository { | ||
List<NotificationSetting> findAllByUser(User user); | ||
|
||
List<NotificationSetting> findAllByStudyGroup(StudyGroup studyGroup); | ||
} |
34 changes: 34 additions & 0 deletions
34
...hub/feature/notification/repository/querydsl/CustomNotificationSettingRepositoryImpl.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,34 @@ | ||
package com.gamzabat.algohub.feature.notification.repository.querydsl; | ||
|
||
import static com.gamzabat.algohub.feature.notification.domain.QNotificationSetting.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import com.gamzabat.algohub.feature.group.studygroup.domain.StudyGroup; | ||
import com.gamzabat.algohub.feature.notification.domain.NotificationSetting; | ||
import com.gamzabat.algohub.feature.user.domain.User; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
@Repository | ||
@AllArgsConstructor | ||
public class CustomNotificationSettingRepositoryImpl implements CustomNotificationSettingRepository { | ||
private final JPAQueryFactory query; | ||
|
||
@Override | ||
public List<NotificationSetting> findAllByUser(User user) { | ||
return query.selectFrom(notificationSetting) | ||
.where(notificationSetting.member.user.eq(user)) | ||
.fetch(); | ||
} | ||
|
||
@Override | ||
public List<NotificationSetting> findAllByStudyGroup(StudyGroup studyGroup) { | ||
return query.selectFrom(notificationSetting) | ||
.where(notificationSetting.member.studyGroup.eq(studyGroup)) | ||
.fetch(); | ||
} | ||
} |
Oops, something went wrong.
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.
이런거 그냥 studygroup으로 질의해서 batch delete하면 쿼리 2->1번으로 줄일 수 있겠네용. 반영해달라는건 아니고 사족입니다