generated from habinkim/SPRING_BOOT_3_JDK_21_DEMO
-
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.
refactor: VoteRegisterEvent Produce, Consume 로직 동작되도록 수정 refactor: Spring AWS SQS Listening 이슈로 인해 Spring Devtools 비활성화 처리 chore: RegisterVotePaper FCM 전송 로직 추가
- Loading branch information
Showing
21 changed files
with
143 additions
and
52 deletions.
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
22 changes: 15 additions & 7 deletions
22
src/main/java/com/tune_fun/v1/account/domain/value/NotificationApprovedDevice.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,10 +1,18 @@ | ||
package com.tune_fun.v1.account.domain.value; | ||
|
||
public record NotificationApprovedDevice( | ||
String id, | ||
String username, | ||
String nickname, | ||
String fcmToken, | ||
String deviceToken | ||
) { | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@EqualsAndHashCode | ||
public final class NotificationApprovedDevice { | ||
private Long id; | ||
private String username; | ||
private String nickname; | ||
private String fcmToken; | ||
private String 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
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/tune_fun/v1/vote/adapter/output/firebase/VoteFirebaseMessagingMapper.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,15 @@ | ||
package com.tune_fun.v1.vote.adapter.output.firebase; | ||
|
||
import com.tune_fun.v1.common.config.BaseMapperConfig; | ||
import com.tune_fun.v1.external.firebase.FirebaseMto; | ||
import com.tune_fun.v1.vote.domain.behavior.SendVotePaperRegisterFcm; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
@Mapper(config = BaseMapperConfig.class) | ||
public abstract class VoteFirebaseMessagingMapper { | ||
|
||
@Mapping(target = "tokens", source = "fcmTokens") | ||
public abstract FirebaseMto.ByTokens fromSendVotePaperRegisterFcmBehavior(final SendVotePaperRegisterFcm behavior); | ||
|
||
} |
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
3 changes: 2 additions & 1 deletion
3
...in/java/com/tune_fun/v1/vote/application/port/input/usecase/RegisterVotePaperUseCase.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,11 +1,12 @@ | ||
package com.tune_fun.v1.vote.application.port.input.usecase; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.tune_fun.v1.vote.application.port.input.command.VotePaperCommands; | ||
import org.springframework.security.core.userdetails.User; | ||
|
||
@FunctionalInterface | ||
public interface RegisterVotePaperUseCase { | ||
|
||
void register(final VotePaperCommands.Register command, User user); | ||
void register(final VotePaperCommands.Register command, User user) throws JsonProcessingException; | ||
|
||
} |
6 changes: 4 additions & 2 deletions
6
.../com/tune_fun/v1/vote/application/port/input/usecase/SendVotePaperRegisterFcmUseCase.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,7 +1,9 @@ | ||
package com.tune_fun.v1.vote.application.port.input.usecase; | ||
|
||
import com.tune_fun.v1.vote.domain.behavior.ProduceVotePaperUploadEvent; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.google.firebase.messaging.FirebaseMessagingException; | ||
import com.tune_fun.v1.vote.domain.behavior.ProduceVotePaperRegisterEvent; | ||
|
||
public interface SendVotePaperRegisterFcmUseCase { | ||
void send(final ProduceVotePaperUploadEvent produceVotePaperUploadEvent); | ||
void send(final ProduceVotePaperRegisterEvent produceVotePaperRegisterEvent) throws JsonProcessingException, FirebaseMessagingException; | ||
} |
5 changes: 3 additions & 2 deletions
5
...in/java/com/tune_fun/v1/vote/application/port/output/ProduceVotePaperUploadEventPort.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,9 +1,10 @@ | ||
package com.tune_fun.v1.vote.application.port.output; | ||
|
||
import com.tune_fun.v1.vote.domain.behavior.ProduceVotePaperUploadEvent; | ||
import com.tune_fun.v1.vote.domain.behavior.ProduceVotePaperRegisterEvent; | ||
import io.awspring.cloud.sqs.operations.SendResult; | ||
|
||
public interface ProduceVotePaperUploadEventPort { | ||
|
||
void produceVotePaperUploadEvent(final ProduceVotePaperUploadEvent produceVotePaperUploadEvent); | ||
SendResult<?> produceVotePaperUploadEvent(final ProduceVotePaperRegisterEvent produceVotePaperRegisterEvent); | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/tune_fun/v1/vote/application/port/output/SendVoteFcmPort.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,4 +1,8 @@ | ||
package com.tune_fun.v1.vote.application.port.output; | ||
|
||
import com.google.firebase.messaging.FirebaseMessagingException; | ||
import com.tune_fun.v1.vote.domain.behavior.SendVotePaperRegisterFcm; | ||
|
||
public interface SendVoteFcmPort { | ||
void notification(final SendVotePaperRegisterFcm sendVotePaperRegisterFcmBehavior) throws FirebaseMessagingException; | ||
} |
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
26 changes: 20 additions & 6 deletions
26
src/main/java/com/tune_fun/v1/vote/application/service/SendVotePaperRegisterFcmService.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,33 +1,47 @@ | ||
package com.tune_fun.v1.vote.application.service; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.google.firebase.messaging.FirebaseMessagingException; | ||
import com.tune_fun.v1.account.application.port.output.device.LoadDevicePort; | ||
import com.tune_fun.v1.account.domain.value.NotificationApprovedDevice; | ||
import com.tune_fun.v1.common.hexagon.UseCase; | ||
import com.tune_fun.v1.common.util.ObjectUtil; | ||
import com.tune_fun.v1.vote.application.port.input.usecase.SendVotePaperRegisterFcmUseCase; | ||
import com.tune_fun.v1.vote.application.port.output.SendVoteFcmPort; | ||
import com.tune_fun.v1.vote.domain.behavior.ProduceVotePaperUploadEvent; | ||
import com.tune_fun.v1.vote.domain.behavior.ProduceVotePaperRegisterEvent; | ||
import com.tune_fun.v1.vote.domain.behavior.SendVotePaperRegisterFcm; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
import static org.springframework.transaction.annotation.Propagation.REQUIRES_NEW; | ||
|
||
@Slf4j | ||
@Service | ||
@UseCase | ||
@RequiredArgsConstructor | ||
public class SendVotePaperRegisterFcmService implements SendVotePaperRegisterFcmUseCase { | ||
|
||
private final LoadDevicePort loadDevicePort; | ||
|
||
private final SendVoteFcmPort sendVoteFcmPort; | ||
|
||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
private final VoteBehaviorMapper voteBehaviorMapper; | ||
|
||
private final ObjectUtil objectUtil; | ||
|
||
@Transactional(propagation = REQUIRES_NEW) | ||
@Override | ||
public void send(ProduceVotePaperUploadEvent produceVotePaperUploadEvent) { | ||
public void send(ProduceVotePaperRegisterEvent produceVotePaperRegisterEvent) throws JsonProcessingException, FirebaseMessagingException { | ||
List<NotificationApprovedDevice> notificationApprovedDevices = loadDevicePort. | ||
loadNotificationApprovedDevice(true, null, null); | ||
|
||
// TODO : FCM 발송 로직 구현 | ||
log.info("notificationApprovedDevices: {}", objectUtil.objectToPrettyJson(notificationApprovedDevices)); | ||
|
||
SendVotePaperRegisterFcm sendVotePaperRegisterFcmBehavior = voteBehaviorMapper | ||
.sendVotePaperRegisterFcm(produceVotePaperRegisterEvent, notificationApprovedDevices); | ||
sendVoteFcmPort.notification(sendVotePaperRegisterFcmBehavior); | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
src/main/java/com/tune_fun/v1/vote/domain/behavior/ProduceVotePaperRegisterEvent.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,4 @@ | ||
package com.tune_fun.v1.vote.domain.behavior; | ||
|
||
public record ProduceVotePaperRegisterEvent(String id, String author, String title, String content) { | ||
} |
Oops, something went wrong.