-
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.
- Loading branch information
1 parent
6a27a54
commit 9ebd88e
Showing
6 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/fullcar/carpool/domain/form/FormMessage.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,18 @@ | ||
package com.fullcar.carpool.domain.form; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum FormMessage { | ||
REJECT_MESSAGE("카풀 매칭에 실패했어요. 다른 카풀을 찾아보세요!"), | ||
REQUEST_TITLE("탑승 요청이 들어왔어요!"), | ||
REQUEST_BODY("탑승자 정보를 확인하고 승인해 주세요🚘"), | ||
ACCEPT_TITLE("카풀 매칭에 성공했어요!"), | ||
ACCEPT_BODY("운전자 정보를 확인해 주세요🚘"), | ||
REJECT_TITLE("카풀 매칭에 실패했어요."), | ||
REJECT_BODY("다른 카풀을 찾아볼까요?💁🏻♀️"); | ||
|
||
private final String message; | ||
} |
3 changes: 2 additions & 1 deletion
3
src/main/java/com/fullcar/carpool/domain/service/NotificationService.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,8 +1,9 @@ | ||
package com.fullcar.carpool.domain.service; | ||
|
||
import com.fullcar.carpool.infra.dto.NotificationDto; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Transactional | ||
public interface NotificationService { | ||
void sendNotification(String nickname, String deviceToken, String title, String body); | ||
void sendNotification(NotificationDto notificationDto); | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/fullcar/carpool/infra/dto/NotificationDto.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.fullcar.carpool.infra.dto; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class NotificationDto { | ||
private String nickName; | ||
|
||
private String deviceToken; | ||
|
||
private String title; | ||
|
||
private String body; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/fullcar/carpool/infra/event/NotificationEvent.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 com.fullcar.carpool.infra.event; | ||
|
||
import com.fullcar.carpool.infra.dto.NotificationDto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class NotificationEvent { | ||
private NotificationDto notificationDto; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/fullcar/carpool/infra/event/NotificationEventListener.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,26 @@ | ||
package com.fullcar.carpool.infra.event; | ||
|
||
import com.fullcar.carpool.domain.form.event.FormStateChangedEvent; | ||
import com.fullcar.carpool.domain.service.NotificationService; | ||
import com.fullcar.carpool.infra.dto.NotificationDto; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
@EnableAsync | ||
public class NotificationEventListener { | ||
private final NotificationService notificationService; | ||
|
||
@Async | ||
@EventListener | ||
public void sendNotification(FormStateChangedEvent formStateChangedEvent) { | ||
notificationService.sendNotification(formStateChangedEvent.getNotificationDto()); | ||
log.info("Notification send"); | ||
} | ||
} |