team

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateInput

type CreateInput struct {
	Name, Description, League, Division, LeagueTable, Fixtures, Coach, Physio, ContactEmail string

	IsActive bool
	IsYouth  bool
	Ages     int
}

CreateInput is a new team. Ages below 19 always make a youth team.

type Detacher

type Detacher interface {
	DetachTeam(ctx context.Context, teamID int) error
}

Detacher unlinks records that reference a team before it is deleted (satisfied by the player, sponsor and user stores).

type Handlers

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

Handlers serves /teams (the detail view GET /teams/{id} is served by the site package, because it aggregates players, managers and sponsors).

func NewHandlers

func NewHandlers(svc *Service) *Handlers

func (*Handlers) Register

func (h *Handlers) Register(g *echo.Group, guards web.Guards)

Register mounts the team routes on the /api/v1 group.

type Public

type Public struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	Description    string `json:"description,omitempty"`
	League         string `json:"league,omitempty"`
	Division       string `json:"division,omitempty"`
	LeagueTableURL string `json:"leagueTableUrl,omitempty"`
	FixturesURL    string `json:"fixturesUrl,omitempty"`
	Coach          string `json:"coach,omitempty"`
	Physio         string `json:"physio,omitempty"`
	ContactEmail   string `json:"contactEmail,omitempty"`
	ImageURL       string `json:"imageUrl,omitempty"`
	IsActive       bool   `json:"isActive"`
	IsYouth        bool   `json:"isYouth"`
	Ages           int    `json:"ages"`
}

Public is a team as the API returns it.

type Service

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

Service is the team business logic.

func NewService

func NewService(store store, files *upload.Files, detachers ...Detacher) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, in CreateInput, image *upload.File) (Public, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id int) (Public, error)

Delete unlinks the team's players, sponsors and managers, then deletes the team and its image. If any unlink fails, the team is kept.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id int) (Public, error)

func (*Service) List

func (s *Service) List(ctx context.Context, includeInactive bool) ([]Public, error)

List returns active teams, or every team when includeInactive is set (logged-in users see inactive teams too).

func (*Service) Update

func (s *Service) Update(ctx context.Context, id int, in UpdateInput, image *upload.File) (Public, error)

func (*Service) WithSquadAges

func (s *Service) WithSquadAges(squads SquadAges) *Service

WithSquadAges makes Update refuse to turn a youth team into a senior team while it has players under 18: senior teams are adults only.

type SquadAges

type SquadAges interface {
	HasUnder18s(ctx context.Context, teamID int) (bool, error)
}

SquadAges checks a team's players (satisfied by *player.Store; team can't import player, which imports team).

type Store

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

Store stores the dependencies

func NewTeamRepo

func NewTeamRepo(db *sqlx.DB) *Store

NewTeamRepo stores our dependency

func (*Store) AddTeam

func (s *Store) AddTeam(ctx context.Context, teamParam Team) (Team, error)

func (*Store) DeleteTeam

func (s *Store) DeleteTeam(ctx context.Context, teamParam Team) error

func (*Store) EditTeam

func (s *Store) EditTeam(ctx context.Context, teamParam Team) (Team, error)

func (*Store) GetTeam

func (s *Store) GetTeam(ctx context.Context, teamParam Team) (Team, error)

func (*Store) GetTeams

func (s *Store) GetTeams(ctx context.Context) ([]Team, error)

func (*Store) GetTeamsActive

func (s *Store) GetTeamsActive(ctx context.Context) ([]Team, error)

type Team

type Team struct {
	ID          int         `db:"id" json:"id"`
	Name        string      `db:"name" json:"name"`
	Description null.String `db:"description" json:"description"`
	League      null.String `db:"league" json:"league"`
	Division    null.String `db:"division" json:"division"`
	LeagueTable null.String `db:"league_table" json:"league_table"`
	Fixtures    null.String `db:"fixtures" json:"fixtures"`
	Coach       null.String `db:"coach" json:"coach"`
	Physio      null.String `db:"physio" json:"physio"`
	// ContactEmail is the team's own shared address; see setting.TeamEmailMode.
	ContactEmail null.String `db:"contact_email" json:"contact_email"`
	FileName     null.String `db:"file_name" json:"file_name"`
	IsActive     bool        `db:"active" json:"is_active"`
	IsYouth      bool        `db:"youth" json:"is_youth"`
	Ages         int         `db:"ages" json:"ages"`
}

type UpdateInput

type UpdateInput struct {
	Name, Description, League, Division, LeagueTable, Fixtures, Coach, Physio, ContactEmail *string

	IsActive    *bool
	IsYouth     *bool
	Ages        *int
	RemoveImage bool
}

UpdateInput changes a team; nil fields are left unchanged and empty strings clear optional fields.

Jump to

Keyboard shortcuts

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