mirror of https://github.com/usbharu/Hideout.git
feat: Timelineの構築に必要なものを追加
This commit is contained in:
parent
3f92ccab98
commit
ed872610f7
|
@ -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")
|
||||||
|
}
|
|
@ -1,3 +1,30 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.timeline
|
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
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.timeline
|
package dev.usbharu.hideout.core.domain.model.timeline
|
||||||
|
|
||||||
class TimelineId {
|
@JvmInline
|
||||||
|
value class TimelineId(val value: Long)
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.timeline
|
package dev.usbharu.hideout.core.domain.model.timeline
|
||||||
|
|
||||||
class TimelineName {
|
@JvmInline
|
||||||
|
value class TimelineName(val value: String)
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
package dev.usbharu.hideout.core.domain.model.timelinebuilder
|
package dev.usbharu.hideout.core.domain.model.timelinebuilder
|
||||||
|
|
||||||
class TimelineBuilderId {
|
@JvmInline
|
||||||
|
value class TimelineBuilderId(val value: Long)
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue