var state: Option[Todo] = None
private var eventCounter = 0L
override def persistenceId: String = TodoAggregate.name(id)
override def receiveCommand: Receive = {
case Create(requestId, aggregateId, todoGroupId, text) =>
require(aggregateId == id)
val now = ZonedDateTime.now()
state = Some(Todo(id, todoGroupId, text, now, now))
persist(Created(UUID.randomUUID(), aggregateId,
todoGroupId, text, now, now)
) { event =>
sender() ! CreateSuccess(UUID.randomUUID(), requestId,
aggregateId, todoGroupId, text, now, now)
subscriber.foreach(_ ! event)
saveSnapshotEntity()
}
case Update(requestId, aggregateId, text) =>
require(aggregateId == id)
val now = ZonedDateTime.now()
state.map(_.copy(text = text, updateAt = now))
persist(Updated(UUID.randomUUID(),
aggregateId, text, now)
) { event =>
sender() ! UpdateSuccess(UUID.randomUUID(),
requestId, aggregateId, text, now)
subscriber.foreach(_ ! event)
saveSnapshotEntity()
} ɹঢ়ଶΛ࣋ͭ ӬଓԽ*% ίϚϯυϋϯυϥ ΠϕϯτΛӬଓԽ͢Δ ඞཁʹԠͯ͡ εφοϓγϣοτ Λ࡞ TFOEFS ʹ ϨεϙϯεΛฦ͢ 4VCTDSJCFSʹ υϝΠϯΠϕϯτΛ ௨