-
Notifications
You must be signed in to change notification settings - Fork 0
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
[REFACTOR] FCM 외부 API 호출 인터페이스 분리 및 기타 리팩토링 #239
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
acc284d
[FIX] FCM 파일 이동
thguss dbe028d
[REFACTOR] FCM API 인터페이스 분리, FirebaseMessage 리팩토링
thguss 918bc51
[REFACTOR] 리팩토링 반영
thguss 9a315bd
[REFACTOR] 리팩토링 반영, 레포지토리 쿼리 수정
thguss 8c807c8
[REFACTOR] 레포지토리 쿼리 수정
thguss 5c29b14
[ADD] api 모듈 의존 모듈 batch 추가 (스케줄러 미작동 이슈 해결)
thguss 0f44285
[FIX] 이름 변경
thguss 5eaf931
[FIX] 이름 변경
thguss c8d940d
[FIX] 이름 변경
thguss 3198207
[FIX] 메서드명 수정 (과도한 책임 분리)
thguss fafbd02
[FIX] 설정파일 값 경로 수정
thguss 956d21c
[FIX] 설정파일 값 경로 수, 변경된 클래스 이름 반영
thguss 230add4
[FIX] 설정파일 값 경로 수정
thguss 5495f5d
[FIX] 클래스 이름 변경
thguss c872cff
[FIX] 직관적인 메서드명으로 수정
thguss 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
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
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
40 changes: 0 additions & 40 deletions
40
smeem-batch/src/main/java/com/smeem/batch/scheduler/MessageScheduler.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
smeem-batch/src/main/java/com/smeem/batch/scheduler/NotificationScheduler.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,41 @@ | ||
package com.smeem.batch.scheduler; | ||
|
||
import com.smeem.common.config.ValueConfig; | ||
import com.smeem.domain.member.model.Member; | ||
import com.smeem.domain.member.repository.MemberRepository; | ||
import com.smeem.external.firebase.NotificationService; | ||
import com.smeem.external.firebase.dto.request.NotificationMulticastRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.val; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Component | ||
@EnableScheduling | ||
@RequiredArgsConstructor | ||
public class NotificationScheduler { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
private final NotificationService notificationService; | ||
private final ValueConfig valueConfig; | ||
|
||
@Scheduled(cron = "${smeem.notification.cron_expression}") | ||
@Transactional(readOnly = true) | ||
public void sendMessagesForTrainingTime() throws InterruptedException { | ||
Thread.sleep(1000); | ||
|
||
val members = memberRepository.findAllByTrainingTime(LocalDateTime.now()); | ||
|
||
if (!members.isEmpty()) { | ||
val tokens = members.stream().map(Member::getFcmToken).toList(); | ||
val title = valueConfig.getNOTIFICATION_TITLE(); | ||
val body = valueConfig.getNOTIFICATION_BODY(); | ||
notificationService.sendMessages(NotificationMulticastRequest.of(tokens, title, body)); | ||
} | ||
} | ||
} |
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
smeem-domain/src/main/java/com/smeem/domain/member/repository/MemberCustomRepository.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,10 @@ | ||
package com.smeem.domain.member.repository; | ||
|
||
import com.smeem.domain.member.model.Member; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public interface MemberCustomRepository { | ||
List<Member> findAllByTrainingTime(LocalDateTime now); | ||
} |
6 changes: 1 addition & 5 deletions
6
smeem-domain/src/main/java/com/smeem/domain/member/repository/MemberRepository.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,20 +1,16 @@ | ||
package com.smeem.domain.member.repository; | ||
|
||
|
||
|
||
|
||
import com.smeem.domain.member.model.Member; | ||
import com.smeem.domain.member.model.SocialType; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
public interface MemberRepository extends JpaRepository<Member, Long>, MemberCustomRepository { | ||
|
||
boolean existsBySocialAndSocialId(SocialType socialType, String socialId); | ||
|
||
Optional<Member> findBySocialAndSocialId(SocialType social, String socialId); | ||
|
||
boolean existsByUsername(String username); | ||
|
||
} |
31 changes: 14 additions & 17 deletions
31
...epository/TrainingTimeRepositoryImpl.java → ...mber/repository/MemberRepositoryImpl.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
11 changes: 0 additions & 11 deletions
11
...main/src/main/java/com/smeem/domain/training/repository/TrainingTimeCustomRepository.java
This file was deleted.
Oops, something went wrong.
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.
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.
갑자기 궁금해졌는데, code 상에 별도로 Timezone을 명시 안했는데, 알람이 한국 시간 기준인 것은 서버 시간이 한국 시간으로 설정되어 있어서 그런거겠죠 ?
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.
넵! TimezoneConfig를 통해서 디폴트 시각을 KST로 설정해두어서 그렇습니다!
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.
아아 TimezonConfig 클래스를 만들어줬었죠 ㅋㅋㅋㅋ 굳이빈당