model

package
v0.0.0-...-60e5973 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputIsEmpty     = errors.New("model: non-empty value must be provided")
	ErrUserUpdateFailed = errors.New("model: user update failed")
)

Functions

This section is empty.

Types

type User

type User struct {
	// contains filtered or unexported fields
}

User is a aggregate that combines all entities needed to represent a user.

func NewUser

func NewUser(p entity.Person, email string) (*User, error)

NewUser is a factory to create a new User aggregate.

func NewUserFromEvents

func NewUserFromEvents(events []event.Event) *User

NewFromEvents is a helper method that creates a new user from a series of events.

func (*User) Activate

func (u *User) Activate() error

Activate activates user.

func (*User) Apply

func (u *User) Apply(e event.Event, new bool)

Apply applies user events to the user aggregate.

func (*User) Deactivate

func (u *User) Deactivate() error

Deactivate deactivates user.

func (User) Events

func (u User) Events() []event.Event

Events returns the uncommitted events from the user aggregate.

func (*User) GetEmail

func (u *User) GetEmail() string

GetEmail returns the email of the user.

func (*User) GetEntity

func (u *User) GetEntity() entity.Person

GetEntity returns the user root person entity.

func (*User) GetID

func (u *User) GetID() uuid.UUID

GetID returns the user root ID.

func (*User) GetName

func (u *User) GetName() string

GetName returns the name of the user.

func (*User) IsActivated

func (u *User) IsActivated() bool

IsActivated returns whether the user is activated.

func (*User) UpdateEmail

func (u *User) UpdateEmail(email string) error

UpdateEmail updates the user's email.

func (*User) UpdateName

func (u *User) UpdateName(name string) error

UpdateName updates the user's name.

func (User) Version

func (u User) Version() int

Version returns the last version of the aggregate before changes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL