Documentation ¶
Index ¶
- Constants
- Variables
- func Add(req *router.Request) error
- func Delete(req *router.Request) error
- func GetOne(req *router.Request) error
- func JoinShowSQL(prefix string) string
- func Search(req *router.Request) error
- func SetRoutes(r *mux.Router)
- func ShowExists(id string) (bool, error)
- func Update(req *router.Request) error
- type AddParams
- type DeleteParams
- type GetOneParams
- type Payload
- type PayloadList
- type SearchParams
- type Show
- func (m *Show) BackdropURL() string
- func (s *Show) Create() error
- func (s *Show) CreateQ(q db.Queryable) error
- func (s *Show) Delete() error
- func (s *Show) DeleteQ(q db.Queryable) error
- func (s *Show) FullyDelete() error
- func (s *Show) FullyDeleteQ(q db.Queryable) error
- func (s *Show) IsZero() bool
- func (m *Show) PosterURL() string
- func (s *Show) Save() error
- func (s *Show) SaveQ(q db.Queryable) error
- func (s *Show) Update() error
- func (s *Show) UpdateQ(q db.Queryable) error
- type UpdateParams
Constants ¶
const ( ShowStatusShowing = iota ShowStatusPaused ShowStatusFinished ShowStatusCanceled // ShowStatusEndOfList represent the total number of possible status ShowStatusEndOfList )
const ( EndpointAdd = iota EndpointSearch EndpointUpdate EndpointGetOne EndpointDelete )
Contains the index of all Endpoints
const DefaultNbResultsPerPage = 20
DefaultNbResultsPerPage represents the default number of result per page
const ShowDateFormat = "January 02 2006"
Variables ¶
var Endpoints = router.Endpoints{ EndpointAdd: { Verb: "POST", Path: "/shows", Auth: router.AdminAccess, Handler: Add, Params: &AddParams{}, }, EndpointSearch: { Verb: "GET", Path: "/shows", Auth: nil, Handler: Search, Params: &SearchParams{}, }, EndpointUpdate: { Verb: "PATCH", Path: "/shows/{id}", Auth: router.AdminAccess, Handler: Update, Params: &UpdateParams{}, }, EndpointGetOne: { Verb: "GET", Path: "/shows/{id}", Auth: nil, Handler: GetOne, Params: &GetOneParams{}, }, EndpointDelete: { Verb: "DELETE", Path: "/shows/{id}", Auth: router.AdminAccess, Handler: Delete, Params: &DeleteParams{}, }, }
Endpoints is a list of endpoints for this components
Functions ¶
func JoinShowSQL ¶
JoinShowSQL returns a string ready to be embed in a JOIN query
func ShowExists ¶
ShowExists checks if a show exists for a specific ID
Types ¶
type AddParams ¶
type AddParams struct {
TMDbID int `from:"form" json:"tmdb_id" params:"required"`
}
AddParams represents the params needed by the AddShow handler
type DeleteParams ¶
type DeleteParams struct {
ID string `from:"url" json:"id" params:"uuid"`
}
DeleteParams represents the params needed by the GetOne handler
type GetOneParams ¶
type GetOneParams struct {
ID string `from:"url" json:"id" params:"uuid"`
}
GetOneParams represents the params needed by the GetOne handler
type Payload ¶
type Payload struct { ID string `json:"id"` Name string `json:"name"` OriginalName string `json:"original_name"` YearReleased int `json:"year_released"` Synopsis string `json:"synopsis"` Poster string `json:"poster"` Backdrop string `json:"backdrop"` TMDbID int `json:"tmdb_id"` Status int `json:"status"` DayOfWeek int `json:"day_of_week"` ReturningDate string `json:"returning_date,omitempty"` Website string `json:"website,omitempty"` Wikipedia string `json:"wikipedia"` ExtraLink string `json:"extra_link,omitempty"` IsOnNetflix bool `json:"is_on_netflix"` }
Payload represents a TV Show returnable to the clients
type PayloadList ¶
type PayloadList struct {
Results []*Payload
}
PayloadList represents a list of TV Show that can be returned to the clients
func NewPayloadList ¶
func NewPayloadList(list []*Show) *PayloadList
NewPayloadList turns a list of Shows into a payload
type SearchParams ¶
type SearchParams struct { paginator.HandlerParams // FromProvider will query TMDb instead of the local database FromProvider bool `from:"query" json:"from_provider" default:"false"` // Name represents a string to use to look against the name field Name string `from:"query" json:"name" params:"trim"` // Status represents a list of status separated by "|" // ex ?status=0|1|3 Status string `from:"query" json:"status" params:"trim"` // DayOfWeek filters the day of the week DayOfWeek *int `from:"query" json:"day_of_week"` // OrderBy represents a list of orders separated by "|" // ex ?order=-name|day_of_week will order by name desc and day of week asc // fields are: name, day_of_week, returning_date, created_at OrderBy string `from:"query" json:"order" params:"trim"` }
SearchParams represents the params needed by the Search handler
type Show ¶
type Show struct { ID string `db:"id"` CreatedAt *db.Time `db:"created_at"` UpdatedAt *db.Time `db:"updated_at"` DeletedAt *db.Time `db:"deleted_at"` Name string `db:"name"` OriginalName string `db:"original_name"` YearReleased int `db:"year_released"` Synopsis string `db:"synopsis"` PosterPath string `db:"poster_path"` BackdropPath string `db:"backdrop_path"` TMDbID int `db:"tmdb_id"` Status int `db:"status"` DayOfWeek time.Weekday `db:"day_of_week"` ReturningDate string `db:"returning_date"` Website string `db:"website"` Wikipedia string `db:"wikipedia"` ExtraLink string `db:"extra_link"` IsOnNetflix bool `db:"is_on_netflix"` }
Show represents a TV show from the database
func NewFromTMDb ¶
NewFromTMDb turns a TMDb.Show into a Show
func NewListFromTMDb ¶
NewListFromTMDb turns a list of TMDb.Show into a list of Show
func (*Show) BackdropURL ¶
BackdropURL returns a URL to the backdrop
func (*Show) FullyDelete ¶
FullyDelete removes a show from the database
func (*Show) FullyDeleteQ ¶
FullyDeleteQ removes a show from the database using a transaction
func (*Show) SaveQ ¶
SaveQ creates or updates the article depending on the value of the id using a transaction
type UpdateParams ¶
type UpdateParams struct { ID string `from:"url" json:"id" params:"uuid"` Name string `from:"form" json:"name" params:"trim"` OriginalName string `from:"form" json:"original_name" params:"trim"` Synopsis string `from:"form" json:"synopsis" params:"trim"` Status *int `from:"form" json:"status"` DayOfWeek *int `from:"form" json:"day_of_week"` ReturningDate *string `from:"form" json:"returning_date"` Website *string `from:"form" json:"website" params:"trim"` Wikipedia *string `from:"form" json:"wikipedia" params:"trim"` ExtraLink *string `from:"form" json:"extra_link" params:"trim"` IsOnNetflix *bool `from:"form" json:"is_on_netflix" params:"trim"` }
UpdateParams represents the params needed by the Update handler