Documentation
¶
Index ¶
- type AvailablePlayers
- type ControllerPlayer
- func (cp *ControllerPlayer) GetPlayerByID(id string) (model.Player, error)
- func (cp *ControllerPlayer) GetPlayerByNickname(nickname string) (model.Player, error)
- func (cp *ControllerPlayer) GetPlayers() ([]model.Player, error)
- func (cp *ControllerPlayer) GetPlayersRankedBy(sortField string, sortFields ...string) ([]model.Player, error)
- func (cp *ControllerPlayer) Init(db *psdb.PostgreDB)
- func (cp *ControllerPlayer) UpdatePlayers(matchResult model.Result) (int64, error)
- type Router
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvailablePlayers ¶
type ControllerPlayer ¶
type ControllerPlayer struct {
// contains filtered or unexported fields
}
ControllerPlayer handles all the player persist logic
func (*ControllerPlayer) GetPlayerByID ¶
func (cp *ControllerPlayer) GetPlayerByID(id string) (model.Player, error)
GetPlayerByID (GET /players/:id) check in the DB the player finding by id
func (*ControllerPlayer) GetPlayerByNickname ¶
func (cp *ControllerPlayer) GetPlayerByNickname(nickname string) (model.Player, error)
GetPlayerByNickname (GET /players/) found a player by their nickname
func (*ControllerPlayer) GetPlayers ¶
func (cp *ControllerPlayer) GetPlayers() ([]model.Player, error)
GetPlayers (GET /players) check in the DB all the stored players and return them in JSON format
func (*ControllerPlayer) GetPlayersRankedBy ¶
func (cp *ControllerPlayer) GetPlayersRankedBy(sortField string, sortFields ...string) ([]model.Player, error)
GetPlayersRankedBy : sortField (might be elo, rank, age) | sortFields (optional) - list of more fields to sort (GET /players) returns all the players sorted by their elo, maybe you can think "ok, but you can use getplayers and then sort it" but no... queries in an SQL motor are more performant than in the code
func (*ControllerPlayer) Init ¶
func (cp *ControllerPlayer) Init(db *psdb.PostgreDB)
func (*ControllerPlayer) UpdatePlayers ¶
func (cp *ControllerPlayer) UpdatePlayers(matchResult model.Result) (int64, error)
UpdatePlayers (POST /players/:id/update) updates the players fields given a match result and return the updated rows count (NOTE: this function receives a map[int]int that contains the id of the player and the goals
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) StartRouter ¶
func (r *Router) StartRouter()
StartRouter turns on the gin-gonic server and initialize the entire REST-API routes and endpoints