-
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.
feat: #11 notification 종류 별로 event&request 분리
- Loading branch information
1 parent
242d651
commit e408684
Showing
23 changed files
with
554 additions
and
167 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...rnal-api/src/main/java/kr/co/fitapet/api/common/event/notification/AnnouncementEvent.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,22 @@ | ||
package kr.co.fitapet.api.common.event.notification; | ||
|
||
import kr.co.fitapet.domain.domains.notification.domain.Notification; | ||
import kr.co.fitapet.domain.domains.notification.type.NotificationType; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record AnnouncementEvent( | ||
String title, | ||
String content, | ||
String imageUrl | ||
) { | ||
public Notification toEntity(Long toId) { | ||
return Notification.builder() | ||
.title(title) | ||
.content(content) | ||
.imageUrl(imageUrl) | ||
.ctype(NotificationType.ANNOUNCEMENT) | ||
.toId(toId) | ||
.build(); | ||
} | ||
} |
30 changes: 29 additions & 1 deletion
30
...p-external-api/src/main/java/kr/co/fitapet/api/common/event/notification/NoticeEvent.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,13 +1,41 @@ | ||
package kr.co.fitapet.api.common.event.notification; | ||
|
||
import kr.co.fitapet.domain.domains.notification.domain.Notification; | ||
import kr.co.fitapet.domain.domains.notification.type.NotificationType; | ||
import kr.co.fitapet.infra.client.fcm.NotificationDataKey; | ||
import lombok.Builder; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
@Builder | ||
public record NoticeEvent( | ||
NoticeType noticeType, | ||
Map<NotificationDataKey, ?> data | ||
NotificationType notificationType, | ||
String title, | ||
String content, | ||
String imageUrl, | ||
Map<NotificationDataKey, String> data | ||
) { | ||
public Notification toEntity() { | ||
String fromId = data.getOrDefault(NotificationDataKey.FROM_ID, null); | ||
String toId = data.getOrDefault(NotificationDataKey.TO_ID, null); | ||
String domainId = data.getOrDefault(NotificationDataKey.DOMAIN_ID, null); | ||
String subjectId = data.getOrDefault(NotificationDataKey.SUBJECT_ID, null); | ||
|
||
return Notification.builder() | ||
.title(title) | ||
.content(content) | ||
.imageUrl(imageUrl) | ||
.ctype(notificationType) | ||
.fromId(Objects.isNull(fromId) ? null : Long.parseLong(fromId)) | ||
.toId(Objects.isNull(toId) ? null : Long.parseLong(toId)) | ||
.domainId(Objects.isNull(domainId) ? null : Long.parseLong(domainId)) | ||
.subjectId(Objects.isNull(subjectId) ? null : Long.parseLong(subjectId)) | ||
.build(); | ||
} | ||
|
||
public String getValueFromNotificationDataKey(NotificationDataKey key) { | ||
return data.getOrDefault(key, null); | ||
} | ||
} |
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: 11 additions & 0 deletions
11
...n/src/main/java/kr/co/fitapet/domain/domains/device/repository/DeviceTokenRepository.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,11 @@ | ||
package kr.co.fitapet.domain.domains.device.repository; | ||
|
||
import kr.co.fitapet.domain.domains.device.domain.DeviceToken; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface DeviceTokenRepository extends JpaRepository<DeviceToken, Long> { | ||
List<DeviceToken> findAllByMember_Id(Long userId); | ||
boolean existsByDeviceToken(String deviceToken); | ||
} |
30 changes: 30 additions & 0 deletions
30
...n/src/main/java/kr/co/fitapet/domain/domains/device/service/DeviceTokenSearchService.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,30 @@ | ||
package kr.co.fitapet.domain.domains.device.service; | ||
|
||
import kr.co.fitapet.common.annotation.DomainService; | ||
import kr.co.fitapet.domain.domains.device.domain.DeviceToken; | ||
import kr.co.fitapet.domain.domains.device.repository.DeviceTokenRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class DeviceTokenSearchService { | ||
private final DeviceTokenRepository deviceTokenRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public List<DeviceToken> findDeviceTokensByMemberId(Long userId) { | ||
return deviceTokenRepository.findAllByMember_Id(userId); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<DeviceToken> findAll() { | ||
return deviceTokenRepository.findAll(); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public boolean isExistDeviceToken(String deviceToken) { | ||
return deviceTokenRepository.existsByDeviceToken(deviceToken); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
...ain/java/kr/co/fitapet/domain/domains/notification/repository/NotificationRepository.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,7 @@ | ||
package kr.co.fitapet.domain.domains.notification.repository; | ||
|
||
import kr.co.fitapet.domain.domains.notification.domain.Notification; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface NotificationRepository extends JpaRepository<Notification, Long> { | ||
} |
20 changes: 20 additions & 0 deletions
20
.../main/java/kr/co/fitapet/domain/domains/notification/service/NotificationSaveService.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,20 @@ | ||
package kr.co.fitapet.domain.domains.notification.service; | ||
|
||
import kr.co.fitapet.common.annotation.DomainService; | ||
import kr.co.fitapet.domain.domains.notification.domain.Notification; | ||
import kr.co.fitapet.domain.domains.notification.repository.NotificationRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@DomainService | ||
@RequiredArgsConstructor | ||
public class NotificationSaveService { | ||
private final NotificationRepository notificationRepository; | ||
|
||
public void save(Notification notification) { | ||
notificationRepository.save(notification); | ||
} | ||
|
||
public void saveAll(Iterable<Notification> notifications) { | ||
notificationRepository.saveAll(notifications); | ||
} | ||
} |
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
39 changes: 0 additions & 39 deletions
39
fitapet-infra/src/main/java/kr/co/fitapet/infra/client/fcm/NotificationEvent.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.