Skip to content

Commit

Permalink
feat: use jsonignore annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoo0515 committed Jul 19, 2024
1 parent 668bc05 commit 816e527
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SccServerPersistentEventRecorder(
val serverEvent = try {
ServerEvent(
id = EntityIdGenerator.generateRandom(),
type = payload.type(),
type = payload.type,
payload = payload,
createdAt = SccClock.instant(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ dependencies {
val kotlinxSerializationVersion: String by project
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinxSerializationVersion")

val jacksonModuleKotlinVersion: String by project
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonModuleKotlinVersion")

val jUnitJupiterVersion: String by project
testImplementation("org.junit.jupiter:junit-jupiter-api:$jUnitJupiterVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jUnitJupiterVersion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package club.staircrusher.domain.server_event
data class NewsletterSubscribedOnSignupPayload(
val userId: String,
) : ServerEventPayload {
override fun type() = ServerEventType.NEWSLETTER_SUBSCRIBED_ON_SIGN_UP
override val type = ServerEventType.NEWSLETTER_SUBSCRIBED_ON_SIGN_UP
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ data class ServerEvent(
val createdAt: Instant,
) {
init {
check(type == payload.type())
check(type == payload.type)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package club.staircrusher.domain.server_event

import com.fasterxml.jackson.annotation.JsonIgnore

interface ServerEventPayload {
// getType 으로 이름을 붙이면 jackson 에서 getter 로 인식하면서 함께 직렬화가 된다
fun type(): ServerEventType
@get:JsonIgnore
val type: ServerEventType
}

0 comments on commit 816e527

Please sign in to comment.