Documentation
¶
Index ¶
- type CreateInput
- type Detacher
- type Handlers
- type Public
- type Service
- func (s *Service) Create(ctx context.Context, in CreateInput, image *upload.File) (Public, error)
- func (s *Service) Delete(ctx context.Context, id int) (Public, error)
- func (s *Service) Get(ctx context.Context, id int) (Public, error)
- func (s *Service) List(ctx context.Context, includeInactive bool) ([]Public, error)
- func (s *Service) Update(ctx context.Context, id int, in UpdateInput, image *upload.File) (Public, error)
- func (s *Service) WithSquadAges(squads SquadAges) *Service
- type SquadAges
- type Store
- func (s *Store) AddTeam(ctx context.Context, teamParam Team) (Team, error)
- func (s *Store) DeleteTeam(ctx context.Context, teamParam Team) error
- func (s *Store) EditTeam(ctx context.Context, teamParam Team) (Team, error)
- func (s *Store) GetTeam(ctx context.Context, teamParam Team) (Team, error)
- func (s *Store) GetTeams(ctx context.Context) ([]Team, error)
- func (s *Store) GetTeamsActive(ctx context.Context) ([]Team, error)
- type Team
- type UpdateInput
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 ¶
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 ¶
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 (*Service) Delete ¶
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) List ¶
List returns active teams, or every team when includeInactive is set (logged-in users see inactive teams too).
func (*Service) WithSquadAges ¶
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 ¶
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
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"`
}