Documentation ¶
Overview ¶
Package show provides business API for show.
Index ¶
- Variables
- type Core
- func (c Core) Create(ctx context.Context, newShow NewShow, now time.Time) (Show, error)
- func (c Core) Delete(ctx context.Context, showID string) error
- func (c Core) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]Show, error)
- func (c *Core) QueryAllEnabled(ctx context.Context) ([]Show, error)
- func (c Core) QueryByID(ctx context.Context, showID string) (Show, error)
- func (c Core) TotalNum(ctx context.Context) (int64, error)
- func (c Core) Update(ctx context.Context, showID string, updateShow UpdateShow, now time.Time) error
- type NewShow
- type Show
- type UpdateShow
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("show not found") ErrInvalidID = errors.New("ID is not in its proper form") ErrInvalidPostCmds = errors.New("PostCmds is not valid") ErrInvalidSplitRule = errors.New("SplitRule is not valid") )
Set of error variables for CRUD operations.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the set of APIs for show access.
func NewCore ¶
func NewCore(log *zap.SugaredLogger, sqlxDB *sqlx.DB) Core
NewCore constructs a core for show api access.
func (*Core) QueryAllEnabled ¶
QueryAllEnabled retrieves all shows which `enable` equals true from the database and saves them in cache.
type NewShow ¶
type NewShow struct { Enable bool `json:"enable"` Platform string `json:"platform" validate:"required"` RoomID string `json:"room_id" validate:"required"` StreamerName string `json:"streamer_name"` OutTmpl string `json:"out_tmpl"` Parser string `json:"parser"` SaveDir string `json:"save_dir"` PostCmds string `json:"post_cmds"` SplitRule string `json:"split_rule"` }
NewShow contains information needed to create a new Show.
type UpdateShow ¶
type UpdateShow struct { Enable *bool `json:"enable"` Platform *string `json:"platform"` RoomID *string `json:"room_id"` StreamerName *string `json:"streamer_name"` OutTmpl *string `json:"out_tmpl"` Parser *string `json:"parser"` SaveDir *string `json:"save_dir"` PostCmds *string `json:"post_cmds"` SplitRule *string `json:"split_rule"` }
UpdateShow defines what information may be provided to modify an existing Show. All fields are optional so clients can send just the fields they want changed. It uses pointer fields so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types but we make exceptions around marshalling/unmarshalling.