game

package
v0.0.4-rc Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountIdType

type AccountIdType string

func (AccountIdType) AsString

func (a AccountIdType) AsString() string

func (AccountIdType) Parse

type Controller

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

func NewController

func NewController(gs Service) *Controller

func (*Controller) Create

func (gc *Controller) Create(w http.ResponseWriter, r *http.Request) error

func (*Controller) Delete

func (gc *Controller) Delete(w http.ResponseWriter, r *http.Request) error

func (*Controller) FindByID

func (gc *Controller) FindByID(w http.ResponseWriter, r *http.Request) error

func (*Controller) List

func (gc *Controller) List(w http.ResponseWriter, r *http.Request) error

func (*Controller) Update

func (gc *Controller) Update(w http.ResponseWriter, r *http.Request) error

type CreateRequest

type CreateRequest struct {
	Name        string     `json:"name"`
	Players     []string   `json:"players"`
	Description string     `json:"description"`
	Difficulty  string     `json:"difficulty"`
	StartedAt   *time.Time `json:"startedAt,omitempty"`
	ClosedAt    *time.Time `json:"closedAt,omitempty"`
}

func (CreateRequest) Validate

func (CreateRequest) Validate() error

type Game

type Game struct {
	ID           int64      `json:"id"`
	CurrentRound int        `json:"currentRound"`
	Description  string     `json:"description"`
	Difficulty   string     `json:"difficulty"`
	CreatedAt    time.Time  `json:"createdAt"`
	UpdatedAt    time.Time  `json:"updatedAt"`
	StartedAt    *time.Time `json:"startedAt"`
	ClosedAt     *time.Time `json:"closedAt"`
	Name         string     `json:"name"`
	Players      []Player   `json:"players,omitempty"`
}

type IntervalType

type IntervalType time.Time

func (IntervalType) AsTime

func (k IntervalType) AsTime() time.Time

func (IntervalType) Parse

func (IntervalType) Parse(s string) (IntervalType, error)

type KeyType

type KeyType int64

func (KeyType) AsInt64

func (k KeyType) AsInt64() int64

func (KeyType) Parse

func (c KeyType) Parse(s string) (KeyType, error)

type Player

type Player struct {
	ID        int64  `json:"id"`
	AccountID string `json:"accountId"`
}

type Repository

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

func NewRepository

func NewRepository(db *gorm.DB) *Repository

func (*Repository) Create

func (gs *Repository) Create(r *CreateRequest) (Game, error)

func (*Repository) Delete

func (gs *Repository) Delete(id int64) error

func (*Repository) FindById

func (gs *Repository) FindById(id int64) (Game, error)

func (*Repository) FindByInterval

func (gs *Repository) FindByInterval(accountId string, i api.IntervalParams, p api.PaginationParams) ([]Game, int64, error)

func (*Repository) Update

func (gs *Repository) Update(id int64, r *UpdateRequest) (Game, error)

type Service

type Service interface {
	Create(request *CreateRequest) (Game, error)
	FindById(id int64) (Game, error)
	Delete(id int64) error
	Update(id int64, ug *UpdateRequest) (Game, error)
	FindByInterval(accountId string, i api.IntervalParams, p api.PaginationParams) ([]Game, int64, error)
}

type UpdateRequest

type UpdateRequest struct {
	CurrentRound int        `json:"currentRound"`
	Name         string     `json:"name"`
	Description  string     `json:"description"`
	StartedAt    *time.Time `json:"startedAt,omitempty"`
	ClosedAt     *time.Time `json:"closedAt,omitempty"`
}

func (UpdateRequest) Validate

func (UpdateRequest) Validate() error

Jump to

Keyboard shortcuts

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