From 8dd98886523d007c2ae1a234b9d45ef7244dcd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=9D=B8=EC=A4=80?= <54973090+dlswns2480@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:38:39 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EB=B0=B0=EC=B9=98=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC,=20=EB=B0=B0=EC=B9=98-=EC=BB=A8=ED=85=90=EC=B8=A0=20?= =?UTF-8?q?=EB=A7=A4=EC=B9=AD,=20fcm=ED=86=A0=ED=81=B0=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20(#112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alert/persist/AlertBatchEntity.kt | 35 +++++++++++++++++++ .../alert/persist/AlertContentEntity.kt | 34 ++++++++++++++++++ .../user/persist/FcmTokenEntity.kt | 26 ++++++++++++++ .../com/pokit/alert/model/AlertBatch.kt | 8 +++++ .../com/pokit/alert/model/AlertContent.kt | 6 ++++ .../kotlin/com/pokit/user/model/FcmToken.kt | 6 ++++ 6 files changed, 115 insertions(+) create mode 100644 adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertBatchEntity.kt create mode 100644 adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertContentEntity.kt create mode 100644 adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/user/persist/FcmTokenEntity.kt create mode 100644 domain/src/main/kotlin/com/pokit/alert/model/AlertBatch.kt create mode 100644 domain/src/main/kotlin/com/pokit/alert/model/AlertContent.kt create mode 100644 domain/src/main/kotlin/com/pokit/user/model/FcmToken.kt diff --git a/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertBatchEntity.kt b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertBatchEntity.kt new file mode 100644 index 00000000..2058bcf0 --- /dev/null +++ b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertBatchEntity.kt @@ -0,0 +1,35 @@ +package com.pokit.out.persistence.alert.persist + +import com.pokit.alert.model.AlertBatch +import com.pokit.out.persistence.BaseEntity +import jakarta.persistence.* +import java.time.LocalDate + +@Table(name = "ALERT_BATCH") +@Entity +class AlertBatchEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + val id: Long = 0L, + + @Column(name = "user_id") + val userId: Long, + + @Column(name = "should_be_send_at") + val shouldBeSentAt: LocalDate, + + @Column(name = "is_sent") + var sent: Boolean = false +) : BaseEntity() { + fun sent() { + this.sent = true + } + + companion object { + fun of(alertBatch: AlertBatch) = AlertBatchEntity( + userId = alertBatch.userId, + shouldBeSentAt = alertBatch.shouldBeSentAt, + ) + } +} diff --git a/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertContentEntity.kt b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertContentEntity.kt new file mode 100644 index 00000000..16fd9bb7 --- /dev/null +++ b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/alert/persist/AlertContentEntity.kt @@ -0,0 +1,34 @@ +package com.pokit.out.persistence.alert.persist + +import com.pokit.alert.model.AlertContent +import com.pokit.out.persistence.BaseEntity +import jakarta.persistence.* + +@Table(name = "alert_content") +@Entity +class AlertContentEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + val id: Long = 0L, + + @Column(name = "alert_batch_id") + val alertBatchId: Long, + + @Column(name = "content_id") + val contentId: Long, + + @Column(name = "is_deleted") + var delete: Boolean = false +) : BaseEntity() { + fun delete() { + this.delete = true + } + + companion object { + fun of(alertContent: AlertContent) = AlertContentEntity( + alertBatchId = alertContent.alertBatchId, + contentId = alertContent.contentId + ) + } +} diff --git a/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/user/persist/FcmTokenEntity.kt b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/user/persist/FcmTokenEntity.kt new file mode 100644 index 00000000..dc23e66e --- /dev/null +++ b/adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/user/persist/FcmTokenEntity.kt @@ -0,0 +1,26 @@ +package com.pokit.out.persistence.user.persist + +import com.pokit.user.model.FcmToken +import jakarta.persistence.* + +@Table(name = "FCM_TOKEN") +@Entity +class FcmTokenEntity( + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + val id: Long = 0L, + + @Column(name = "user_id") + val userId: Long, + + @Column(name = "token") + val token: String +) { + companion object { + fun of(fcmToken: FcmToken) = FcmTokenEntity( + userId = fcmToken.userId, + token = fcmToken.token + ) + } +} diff --git a/domain/src/main/kotlin/com/pokit/alert/model/AlertBatch.kt b/domain/src/main/kotlin/com/pokit/alert/model/AlertBatch.kt new file mode 100644 index 00000000..03aedd39 --- /dev/null +++ b/domain/src/main/kotlin/com/pokit/alert/model/AlertBatch.kt @@ -0,0 +1,8 @@ +package com.pokit.alert.model + +import java.time.LocalDate + +data class AlertBatch( + val userId: Long, + val shouldBeSentAt: LocalDate, +) diff --git a/domain/src/main/kotlin/com/pokit/alert/model/AlertContent.kt b/domain/src/main/kotlin/com/pokit/alert/model/AlertContent.kt new file mode 100644 index 00000000..a97bd878 --- /dev/null +++ b/domain/src/main/kotlin/com/pokit/alert/model/AlertContent.kt @@ -0,0 +1,6 @@ +package com.pokit.alert.model + +data class AlertContent( + val alertBatchId: Long, + val contentId: Long +) diff --git a/domain/src/main/kotlin/com/pokit/user/model/FcmToken.kt b/domain/src/main/kotlin/com/pokit/user/model/FcmToken.kt new file mode 100644 index 00000000..7e9b7c45 --- /dev/null +++ b/domain/src/main/kotlin/com/pokit/user/model/FcmToken.kt @@ -0,0 +1,6 @@ +package com.pokit.user.model + +data class FcmToken( + val userId: Long, + val token: String +)