Documentation ¶
Index ¶
- Variables
- func DeleteAllTournamentPlayers(tournamentParam string, db *gorm.DB) func(*gin.Context)
- func DeletePlayer(param string, db *gorm.DB) func(*gin.Context)
- func DeleteTournament(tournamentParam string, db *gorm.DB) func(*gin.Context)
- func DeleteTournamentPlayer(tournamentParam string, playerParam string, db *gorm.DB) func(*gin.Context)
- func DeleteTournamentTable(tournamentParam string, tableParam string, db *gorm.DB) func(*gin.Context)
- func GetGame(param string, db *gorm.DB) func(*gin.Context)
- func GetGameEvents(param string) func(c *gin.Context)
- func GetGameStart(param string, db *gorm.DB) func(*gin.Context)
- func GetGames(db *gorm.DB) func(*gin.Context)
- func GetGamesInTournament(param string, db *gorm.DB) func(*gin.Context)
- func GetPlayer(param string, db *gorm.DB) func(*gin.Context)
- func GetPlayerEvents(param string) func(c *gin.Context)
- func GetPlayers(db *gorm.DB) func(*gin.Context)
- func GetRandomGames(param string, db *gorm.DB) func(*gin.Context)
- func GetTable(param string, db *gorm.DB) func(*gin.Context)
- func GetTables(db *gorm.DB) func(*gin.Context)
- func GetTournament(param string, db *gorm.DB) func(*gin.Context)
- func GetTournamentHistory(tournamentParam string, db *gorm.DB) func(*gin.Context)
- func GetTournamentPlayeHistory(tournamentParam string, playerParam string, db *gorm.DB) func(*gin.Context)
- func GetTournamentPlayes(param string, db *gorm.DB) func(*gin.Context)
- func GetTournamentTables(param string, db *gorm.DB) func(*gin.Context)
- func GetTournaments(db *gorm.DB) func(*gin.Context)
- func HandlePanic(c *gin.Context)
- func HandlePanicInTransaction(c *gin.Context, tx *gorm.DB)
- func PostGame(tournamentParam string, tableParam string, db *gorm.DB) func(*gin.Context)
- func PostPlayer(db *gorm.DB) func(*gin.Context)
- func PostTable(db *gorm.DB) func(*gin.Context)
- func PostTournament(db *gorm.DB) func(*gin.Context)
- func PostTournamentPlayer(param string, db *gorm.DB) func(*gin.Context)
- func PostTournamentTables(param string, db *gorm.DB) func(*gin.Context)
- type AddPlayerRequest
- type AddTableRequest
- type CreatePlayerRequest
- type CreateTableRequest
- type CreateTournamentRequest
- type ErrorResponse
- type EventPublisher
- type GameResultRequest
- type GameStartEventRepresentation
- type TournamentHistoryRepresenatation
- type TournamentPlayerRepresenatation
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DeleteAllTournamentPlayers ¶ added in v0.8.9
DeleteAllTournamentPlayers remove all players from a tournament @Summary Remove all players from tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Success 204 @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/players [delete]
func DeletePlayer ¶
DeletePlayer deletes a player @Summary Delete player @Tags player @Accept json @Produce json @Param id path string true "Player ID" @Success 204 @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /players/{id} [delete]
func DeleteTournament ¶
DeleteTournament removes a tournament @Summary Remove tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Success 204 @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id} [delete]
func DeleteTournamentPlayer ¶
func DeleteTournamentPlayer(tournamentParam string, playerParam string, db *gorm.DB) func(*gin.Context)
DeleteTournamentPlayer removes player from a tournament @Summary Remove player from tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Param player path string true "Player ID" @Success 204 @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/players/{player} [delete]
func DeleteTournamentTable ¶
func DeleteTournamentTable(tournamentParam string, tableParam string, db *gorm.DB) func(*gin.Context)
DeleteTournamentTable deletes a table from a tournament @Summary Remove table from tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Param tableId path string true "Table ID" @Success 204 @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/tables/{tableId} [delete]
func GetGame ¶
GetGame returns a game played @Summary Get gamne results @Tags game @Accept json @Produce json @Param id path string true "Game ID" @Success 200 {object} model.GameJson @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /games/{id} [get]
func GetGameEvents ¶
GetGameEvents creats web socket with tournamnent game events @Summary Opens a web socket for tournamnent game start events @Tags events @Produce json-stream @Param id path string true "Tournament ID" @Success 200 {object} GameStartEventRepresentation @Router /tournaments/{id}/events/game [get]
func GetGameStart ¶
GetGameStart publishes a game start event using web socket @Summary Publishes a game start event @Tags actions @Accept json @Produce json @Param id path string true "Tournament ID" @Success 204 @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/games/start [get]
func GetGames ¶
GetGames returns all games @Summary Get all gamne results @Tags game @Accept json @Produce json @Success 200 {array} model.GameJson @Router /games [get]
func GetGamesInTournament ¶
GetGamesInTournament find all games in tournament @Summary Get all games in a tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Success 200 {array} model.GameJson @Router /tournaments/{id}/games [get]
func GetPlayer ¶
GetPlayer gets player info @Summary Get player @Tags player @Accept json @Produce json @Param id path string true "Player ID" @Success 200 {object} model.Player @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /players/{id} [get]
func GetPlayerEvents ¶
GetPlayerEvents creats web socket with tournamnent player events @Summary Opens a web socket for tournamnent player events @Tags events @Produce json-stream @Param id path string true "Tournament ID" @Success 200 {object} TournamentPlayerRepresenatation @Router /tournaments/{id}/events/player [get]
func GetPlayers ¶
GetPlayers get a list of all players @Summary List players @Tags player @Accept json @Produce json @Param exclude query int false "exlude tournament from list" @Success 200 {array} model.Player @Router /players [get]
func GetRandomGames ¶
GetRandomGames for a tournament @Summary Get random game for a tournament @Tags actions @Accept json @Produce json @Param id path string true "Tournament ID" @Success 200 {array} model.GameJson @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/games/random [get]
func GetTable ¶
GetTable get info about a table @Summary Get table @Tags table @Accept json @Produce json @Param id path string true "Table ID" @Success 200 {object} model.Table @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tables/{id} [get]
func GetTables ¶
GetTables get list of all tables @Summary Get all tables @Tags table @Accept json @Produce json @Param exclude query int false "exlude tournament from list" @Success 200 {array} model.Table @Router /tables [get]
func GetTournament ¶
GetTournament gets info about a tournament @Summary Get tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Success 200 {object} model.Tournament @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id} [get]
func GetTournamentHistory ¶
GetTournamentHistory get ranking history for a given tournament @Summary Get ranking history for a tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Param from query string true "The RFC3339 date to get history from" Format(date) @Success 200 {array} TournamentHistoryRepresenatation @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/history [get]
func GetTournamentPlayeHistory ¶
func GetTournamentPlayeHistory(tournamentParam string, playerParam string, db *gorm.DB) func(*gin.Context)
GetTournamentPlayeHistory get player ranking history in a given tournament @Summary Get player ranking history in tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Param nickname path string true "Player nickname" @Param from query string true "The RFC3339 date to get history from" Format(date) @Success 200 {array} model.TournamentPlayerHistory @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/players/{nickname}/history [get]
func GetTournamentPlayes ¶
GetTournamentPlayes get players in a given tournament @Summary Get players in tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Success 200 {array} TournamentPlayerRepresenatation @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/players [get]
func GetTournamentTables ¶
GetTournamentTables list tables in a tournament @Summary Get tables in a tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Success 200 {array} model.TournamentTable @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/tables [get]
func GetTournaments ¶
GetTournaments gets a list of all tournaments @Summary Get all tournaments @Tags tournament @Accept json @Produce json @Success 200 {array} model.Tournament @Router /tournaments [get]
func HandlePanic ¶
HandlePanic provides a defer function to handle panics
func HandlePanicInTransaction ¶
HandlePanicInTransaction provides a defer function to handle panics when a transaction has been started
func PostGame ¶
PostGame saves a played game @Summary Submit gamne results @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Param table path string true "Table ID" @Param game body GameResultRequest true "Submit game results" @Success 200 {object} model.GameJson @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/tables/{table}/games [post]
func PostPlayer ¶
PostPlayer creates a new player @Summary Create a new player @Tags player @Accept json @Produce json @Param player body CreatePlayerRequest true "Create player" @Success 201 {object} model.Player @Failure 400 {object} ErrorResponse @Failure 409 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /players [post]
func PostTable ¶
PostTable creats new table @Summary Create table @Tags table @Accept json @Produce json @Param table body CreateTableRequest true "The table" @Success 200 {object} model.Table @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tables/ [post]
func PostTournament ¶
PostTournament creats tournament @Summary Create tournament @Tags tournament @Accept json @Produce json @Param tournament body CreateTournamentRequest true "The tournament" @Success 200 {object} model.Tournament @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments [post]
func PostTournamentPlayer ¶
PostTournamentPlayer addes player to a tournament @Summary Add player to tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Param player body AddPlayerRequest true "The tournament" @Success 200 {object} TournamentPlayerRepresenatation @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/players [post]
func PostTournamentTables ¶
PostTournamentTables adds a table to a tournament @Summary Add table to tournament @Tags tournament @Accept json @Produce json @Param id path string true "Tournament ID" @Param table body AddTableRequest true "The table" @Success 201 {object} model.TournamentTable @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /tournaments/{id}/tables [post]
Types ¶
type AddPlayerRequest ¶
type AddTableRequest ¶
type AddTableRequest struct { ID uint `json:"id" binding:"required"` } //@name AddTable
type CreatePlayerRequest ¶
type CreateTableRequest ¶
type CreateTournamentRequest ¶
type ErrorResponse ¶
type ErrorResponse struct { Error string `json:"error" binding:"required"` } //@name Error
ErrorResponse provides an error response for the API
func NewErrorResponse ¶
func NewErrorResponse(error string) *ErrorResponse
NewError creates an new error response
type EventPublisher ¶
func NewEventPublisher ¶
func NewEventPublisher() *EventPublisher
func (*EventPublisher) Publish ¶
func (e *EventPublisher) Publish(id string, data interface{})
func (*EventPublisher) Register ¶
func (e *EventPublisher) Register(id string, conn *websocket.Conn)
func (*EventPublisher) Unregister ¶
func (e *EventPublisher) Unregister(id string)
type GameResultRequest ¶
type GameResultRequest struct { RightPlayers []string `json:"rightPlayers" binding:"required,gte=1,lte=2"` LeftPlayers []string `json:"leftPlayers" binding:"required,gte=1,lte=2"` Winner model.Winner `json:"winner,omitempty" enums:"right,left,draw" binding:"gamewinner,required"` } //@name GameResult
GameResultRequest represents a played game
type GameStartEventRepresentation ¶
type GameStartEventRepresentation struct { Id string `json:"id" binding:"required"` } //@name GameStartEvent
type TournamentPlayerRepresenatation ¶
type TournamentPlayerRepresenatation struct { Nickname string `json:"nickname" binding:"required"` RealName string `json:"realname"` RFID string `json:"rfid,omitempty"` Active bool `json:"active" binding:"required"` Ranking uint `json:"ranking,omitempty"` Latest *time.Time `json:"latest,omitempty"` } //@name TournamentPlayer
TournamentPlayerRepresenatation represents a player in a tournament
func NewPlayerRepresentation ¶
func NewPlayerRepresentation(tp *model.TournamentPlayer) TournamentPlayerRepresenatation