Kotlin CQRS Class Generator
Generate Aggregate, Command, Event, Query, and Entity classes for your Kotlin CQRS architecture
Aggregate Entity
Command
Event
Query
Entity
Aggregate Entity Configuration
Package Name
Class Name
Aggregate Variables
Add Variable
Command Handlers
if (!active) { throw UserEventStreamNotExistInEventStoreException( "User Update Password Exception!", ) }
id = command.id, password = command.password, passwordUpdated = true
if (!active) { throw UserEventStreamNotExistInEventStoreException( "User Update Profile Exception!", ) }
id = command.id, firstName = command.firstName, lastName = command.lastName, password = command.password, profileImage = command.profileImage
Add Command Handler
Event Handlers
buildAggregateRoot(event) id = event.id active = true title = event.title firstName = event.firstName lastName = event.lastName email = event.email password = event.password
buildAggregateRoot(event) id = event.id password = event.password passwordUpdated = event.passwordUpdated
buildAggregateRoot(event) id = event.id firstName = event.firstName lastName = event.lastName password = event.password profileImage = event.profileImage
Add Event Handler
Generated Aggregate Class
Infer Entity
Copy
Download
package tech.gyri.cqrs.command.user.entity import tech.gyri.cqrs.framework.core.entity.TenantAggregateRoot import tech.gyri.cqrs.command.user.api.commands.* import tech.gyri.cqrs.shared.user.events.* import tech.gyri.cqrs.command.user.exceptions.UserEventStreamNotExistInEventStoreException class UserAggregate constructor() : TenantAggregateRoot() { var active: Boolean = false private var title: String = "" private var firstName: String = "" private var lastName: String = "" private var email: String = "" private var password: String = "welcome1" private var passwordUpdated: Boolean = false private var status: UserStatusEnum = UserStatusEnum.ACTIVE fun updatePassword(command: UserUpdatePasswordCommand) { if (!active) { throw UserEventStreamNotExistInEventStoreException( "User Update Password Exception!", ) } raiseEvent( UserPasswordUpdatedEvent( id = command.id, password = command.password, passwordUpdated = true ).buildEvent(command), ) } fun updateUserProfile(command: UserProfileUpdateCommand) { if (!active) { throw UserEventStreamNotExistInEventStoreException( "User Update Profile Exception!", ) } raiseEvent( UserProfileUpdatedEvent( id = command.id, firstName = command.firstName, lastName = command.lastName, password = command.password, profileImage = command.profileImage ).buildEvent(command), ) } fun apply(event: UserRegisteredEvent) { buildAggregateRoot(event) id = event.id active = true title = event.title firstName = event.firstName lastName = event.lastName email = event.email password = event.password } fun apply(event: UserPasswordUpdatedEvent) { buildAggregateRoot(event) id = event.id password = event.password passwordUpdated = event.passwordUpdated } fun apply(event: UserProfileUpdatedEvent) { buildAggregateRoot(event) id = event.id firstName = event.firstName lastName = event.lastName password = event.password profileImage = event.profileImage } }