✨ datastore-mariadb-reactive 추가
This commit is contained in:
11
infrastructure/datastore-mariadb-reactive/build.gradle.kts
Normal file
11
infrastructure/datastore-mariadb-reactive/build.gradle.kts
Normal file
@@ -0,0 +1,11 @@
|
||||
dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-webflux")
|
||||
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
|
||||
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
|
||||
runtimeOnly("org.mariadb:r2dbc-mariadb:1.1.3")
|
||||
|
||||
implementation(project(":util:common-util"))
|
||||
implementation(project(":core:demo-reactive-core"))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.jiniworld.demohx.persistence.notice
|
||||
|
||||
import me.jiniworld.demohx.application.notice.domain.Notice
|
||||
import org.springframework.data.annotation.CreatedDate
|
||||
import org.springframework.data.annotation.Id
|
||||
import org.springframework.data.annotation.LastModifiedDate
|
||||
import org.springframework.data.relational.core.mapping.Table
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Table("notice")
|
||||
internal class NoticeDocument {
|
||||
@Id
|
||||
var id: String = ""
|
||||
|
||||
var title: String = ""
|
||||
|
||||
var content: String = ""
|
||||
|
||||
@CreatedDate
|
||||
var createdAt: LocalDateTime = LocalDateTime.now()
|
||||
|
||||
@LastModifiedDate
|
||||
var updatedAt: LocalDateTime? = null
|
||||
|
||||
fun mapToNotice() =
|
||||
Notice(id = id, title = title, content = content, createdAt = createdAt)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.jiniworld.demohx.persistence.notice
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import me.jiniworld.demohx.annotation.PersistenceAdapter
|
||||
import me.jiniworld.demohx.application.notice.domain.Notice
|
||||
import me.jiniworld.demohx.application.notice.port.output.LoadNoticePort
|
||||
import org.springframework.data.domain.Pageable
|
||||
|
||||
@PersistenceAdapter
|
||||
internal class NoticePersistenceAdapter(
|
||||
private val noticeRepository: NoticeRepository,
|
||||
) : LoadNoticePort {
|
||||
override fun loadNotices(pageable: Pageable): Flow<Notice> {
|
||||
return noticeRepository.findAllBy(pageable).map { it.mapToNotice() }
|
||||
}
|
||||
|
||||
override suspend fun loadNotice(id: String): Notice? {
|
||||
return noticeRepository.findById(id)?.mapToNotice()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.jiniworld.demohx.persistence.notice
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.repository.kotlin.CoroutineCrudRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
internal interface NoticeRepository: CoroutineCrudRepository<NoticeDocument, String> {
|
||||
fun findAllBy(pageable: Pageable): Flow<NoticeDocument>
|
||||
}
|
||||
@@ -3,13 +3,12 @@ rootProject.name = "demo-hexagonal"
|
||||
|
||||
include(
|
||||
"core:demo-core",
|
||||
"core:demo-reactive-core",
|
||||
"infrastructure:datastore-mariadb",
|
||||
"infrastructure:datastore-mongodb-reactive",
|
||||
"infrastructure:datastore-mariadb-reactive",
|
||||
"server:demo-app",
|
||||
"server:demo-reactive-app",
|
||||
"util:common-util",
|
||||
"server:demo-all-in-one-app"
|
||||
)
|
||||
include("server:demo-reactive-app")
|
||||
findProject(":server:demo-reactive-app")?.name = "demo-reactive-app"
|
||||
include("core:demo-reactive-core")
|
||||
findProject(":core:demo-reactive-core")?.name = "demo-reactive-core"
|
||||
)
|
||||
Reference in New Issue
Block a user