-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from SKY-HORSE-MAN-POWER/develop
[DEPLOYMENT] 알림 서비스 구현
- Loading branch information
Showing
20 changed files
with
309 additions
and
131 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
15 changes: 3 additions & 12 deletions
15
src/main/java/com/sparos4th2/alarm/application/AlarmService.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,22 +1,13 @@ | ||
package com.sparos4th2.alarm.application; | ||
|
||
import com.sparos4th2.alarm.domain.Alarm; | ||
import com.sparos4th2.alarm.dto.AlarmDto; | ||
import org.springframework.http.codec.ServerSentEvent; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import com.sparos4th2.alarm.data.vo.NotificationResponseVo; | ||
import com.sparos4th2.alarm.data.dto.AlarmDto; | ||
|
||
public interface AlarmService { | ||
|
||
void saveAlarm(); | ||
|
||
Flux<Alarm> getAlarm(String receiverUuid); | ||
|
||
Flux<ServerSentEvent<Object>> connect(String receiverUuid); | ||
|
||
// Mono<Boolean> successMessageSend(String receiverUuid); | ||
|
||
void finish(String receiverUuid); | ||
NotificationResponseVo getAlarm(String receiverUuid, Integer page, Integer size); | ||
|
||
void consume(AlarmDto alarmDto); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...va/com/sparos4th2/alarm/dto/AlarmDto.java → ...m/sparos4th2/alarm/data/dto/AlarmDto.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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/sparos4th2/alarm/data/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,26 @@ | ||
package com.sparos4th2.alarm.data.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
@ToString | ||
public class NotificationDto { | ||
private String message; | ||
private String eventType; | ||
private String alarmUrl; | ||
private LocalDateTime alarmTime; | ||
|
||
@Builder | ||
public NotificationDto(String message, String eventType, String alarmUrl, LocalDateTime alarmTime) { | ||
this.message = message; | ||
this.eventType = eventType; | ||
this.alarmUrl = alarmUrl; | ||
this.alarmTime = alarmTime; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/sparos4th2/alarm/data/vo/NotificationResponseVo.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,27 @@ | ||
package com.sparos4th2.alarm.data.vo; | ||
|
||
import com.sparos4th2.alarm.data.dto.NotificationDto; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@Getter | ||
@ToString | ||
public class NotificationResponseVo { | ||
private List<NotificationDto> notificationDtoList; | ||
private int currentPage; | ||
private boolean hasNext; | ||
|
||
|
||
@Builder | ||
public NotificationResponseVo(List<NotificationDto> notificationDtoList, int currentPage, boolean hasNext) { | ||
this.notificationDtoList = notificationDtoList; | ||
this.currentPage = currentPage; | ||
this.hasNext = hasNext; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/sparos4th2/alarm/data/vo/StreamNotificationResponseVo.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.sparos4th2.alarm.data.vo; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@NoArgsConstructor | ||
public class StreamNotificationResponseVo { | ||
private int alarmCount; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.sparos4th2.alarm.domain; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
@Getter | ||
@Document(collection = "alarm_count") | ||
@NoArgsConstructor | ||
public class AlarmCount { | ||
|
||
@Id | ||
private String id; | ||
private String receiverUuid; | ||
private int alarmCount; | ||
|
||
@Builder | ||
public AlarmCount(String receiverUuid, int alarmCount) { | ||
this.receiverUuid = receiverUuid; | ||
this.alarmCount = alarmCount; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/sparos4th2/alarm/infrastructure/AlarmCountReactiveRepository.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.sparos4th2.alarm.infrastructure; | ||
|
||
import com.sparos4th2.alarm.data.vo.StreamNotificationResponseVo; | ||
import com.sparos4th2.alarm.domain.Alarm; | ||
import com.sparos4th2.alarm.domain.AlarmCount; | ||
import java.util.Optional; | ||
import org.springframework.data.mongodb.repository.Query; | ||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository; | ||
import org.springframework.data.mongodb.repository.Tailable; | ||
import reactor.core.publisher.Flux; | ||
|
||
public interface AlarmCountReactiveRepository extends ReactiveMongoRepository<AlarmCount, String> { | ||
|
||
@Tailable | ||
@Query("{ 'receiverUuid' : ?0 }") | ||
Flux<StreamNotificationResponseVo> findByReceiverUuid(String receiverUuid); | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/sparos4th2/alarm/infrastructure/AlarmCountRepository.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.sparos4th2.alarm.infrastructure; | ||
|
||
import com.sparos4th2.alarm.domain.Alarm; | ||
import com.sparos4th2.alarm.domain.AlarmCount; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface AlarmCountRepository extends MongoRepository<AlarmCount, String> { | ||
Optional<AlarmCount> findByReceiverUuid(String receiverUuid); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/sparos4th2/alarm/infrastructure/AlarmReactiveRepository.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.sparos4th2.alarm.infrastructure; | ||
|
||
import com.sparos4th2.alarm.domain.Alarm; | ||
import org.springframework.data.mongodb.repository.Query; | ||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository; | ||
import reactor.core.publisher.Flux; | ||
|
||
public interface AlarmReactiveRepository extends ReactiveMongoRepository<Alarm, String> { | ||
|
||
@Query("{ 'receiverUuid' : ?0 }") | ||
Flux<Alarm> findAlarmByReceiverUuid(String receiverUuid); | ||
} |
Oops, something went wrong.