team

package
v0.0.0-...-61e3c9a Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidGroup     = errors.New("model: team has to be a valid group")
	ErrTeamUpdateFailed = errors.New("model: team update failed")
)
View Source
var (
	ErrTeamNotFound      = errors.New("repository: the team was not found")
	ErrTeamAlreadyExists = errors.New("repository: team already exists")
	ErrTeamHasNoUpdates  = errors.New("repository: failed to update team")
)

Functions

This section is empty.

Types

type PlayerAssignedToTeam

type PlayerAssignedToTeam struct {
	ID         uuid.UUID `json:"id"`
	PlayerId   uuid.UUID `json:"player_id"`
	PlayerName string    `json:"player_name"`
}

PlayerAssignedToTeam event.

func (PlayerAssignedToTeam) EventName

func (e PlayerAssignedToTeam) EventName() string

type PlayerUnassignedFromTeam

type PlayerUnassignedFromTeam struct {
	ID         uuid.UUID `json:"id"`
	PlayerId   uuid.UUID `json:"player_id"`
	PlayerName string    `json:"player_name"`
}

PlayerUnassignedFromTeam event.

func (PlayerUnassignedFromTeam) EventName

func (e PlayerUnassignedFromTeam) EventName() string

type Team

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

Team is a aggregate that combines all entities needed to represent a team.

func NewTeam

func NewTeam(g core.Group) (*Team, error)

NewTeam is a factory to create a new Team aggregate.

func NewTeamFromEvents

func NewTeamFromEvents(events []core.Event) *Team

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

func (*Team) Activate

func (t *Team) Activate() error

Activate activates team.

func (*Team) Apply

func (t *Team) Apply(e core.Event, new bool)

Apply applies team events to the team aggregate.

func (*Team) AssignPlayer

func (t *Team) AssignPlayer(p core.Person) error

AssignPlayer assigns player to team.

func (*Team) Deactivate

func (t *Team) Deactivate() error

Deactivate deactivates team.

func (Team) Events

func (t Team) Events() []core.Event

Events returns the uncommitted events from the team aggregate.

func (*Team) GetEntity

func (t *Team) GetEntity() core.Group

GetEntity returns the team root core.

func (*Team) GetID

func (t *Team) GetID() uuid.UUID

GetID returns the team root ID.

func (*Team) GetName

func (t *Team) GetName() string

GetName returns the name of the team.

func (*Team) GetPlayers

func (t *Team) GetPlayers() (players []core.Person)

GetPlayers returns a team's players.

func (*Team) IsActivated

func (t *Team) IsActivated() bool

IsActivated returns whether the team is activated.

func (*Team) UnassignPlayer

func (t *Team) UnassignPlayer(p core.Person) error

UassignPlayer assigns player from team.

func (Team) Version

func (t Team) Version() int

Version returns the last version of the aggregate before changes.

type TeamActivated

type TeamActivated struct {
	ID uuid.UUID `json:"id"`
}

TeamActivated event.

func (TeamActivated) EventName

func (e TeamActivated) EventName() string

type TeamCreated

type TeamCreated struct {
	ID   uuid.UUID `json:"id"`
	Name string    `json:"name"`
}

TeamCreated event.

func (TeamCreated) EventName

func (e TeamCreated) EventName() string

type TeamDeactivated

type TeamDeactivated struct {
	ID uuid.UUID `json:"id"`
}

TeamDeactivated event.

func (TeamDeactivated) EventName

func (e TeamDeactivated) EventName() string

type TeamRepository

type TeamRepository interface {
	Get(core.Group) (*Team, error)
	GetPlayers(core.Group) ([]core.Person, error)
	Add(*Team) error
	Update(*Team) error
}

TeamRepository defines the interface for the team repository.

Jump to

Keyboard shortcuts

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