feat: Timelineの構築に必要なものを追加

This commit is contained in:
usbharu 2024-06-29 19:25:19 +09:00
parent 3f92ccab98
commit ed872610f7
Signed by: usbharu
GPG Key ID: 6556747BF94EEBC8
5 changed files with 50 additions and 10 deletions

View File

@ -0,0 +1,16 @@
package dev.usbharu.hideout.core.domain.event.timeline
import dev.usbharu.hideout.core.domain.model.timeline.Timeline
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEvent
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventBody
class TimelineEventFactory(private val timeline: Timeline) {
fun createEvent(timelineEvent: TimelineEvent): DomainEvent<TimelineEventBody> =
DomainEvent.create(timelineEvent.eventName, TimelineEventBody(timeline))
}
class TimelineEventBody(timeline: Timeline) : DomainEventBody(mapOf("timeline" to timeline))
enum class TimelineEvent(val eventName: String) {
CHANGE_VISIBILITY("ChangeVisibility")
}

View File

@ -1,3 +1,30 @@
package dev.usbharu.hideout.core.domain.model.timeline
class Timeline(val id: TimelineId, val name: TimelineName, val visibility: TimelineVisibility, val isSystem: Boolean)
import dev.usbharu.hideout.core.domain.event.timeline.TimelineEvent
import dev.usbharu.hideout.core.domain.event.timeline.TimelineEventFactory
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetail
import dev.usbharu.hideout.core.domain.model.userdetails.UserDetailId
import dev.usbharu.hideout.core.domain.shared.domainevent.DomainEventStorable
class Timeline(
val id: TimelineId,
val userDetailId: UserDetailId,
name: TimelineName,
visibility: TimelineVisibility,
val isSystem: Boolean
) : DomainEventStorable() {
var visibility = visibility
private set
fun setVisibility(visibility: TimelineVisibility, userDetail: UserDetail) {
check(isSystem.not())
require(userDetailId == userDetail.id)
this.visibility = visibility
addDomainEvent(TimelineEventFactory(this).createEvent(TimelineEvent.CHANGE_VISIBILITY))
}
var name = name
private set
}

View File

@ -1,5 +1,4 @@
package dev.usbharu.hideout.core.domain.model.timeline
class TimelineId {
}
@JvmInline
value class TimelineId(val value: Long)

View File

@ -1,5 +1,4 @@
package dev.usbharu.hideout.core.domain.model.timeline
class TimelineName {
}
@JvmInline
value class TimelineName(val value: String)

View File

@ -1,5 +1,4 @@
package dev.usbharu.hideout.core.domain.model.timelinebuilder
class TimelineBuilderId {
}
@JvmInline
value class TimelineBuilderId(val value: Long)