show

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Overview

Package show provides business API for show.

Index

Constants

This section is empty.

Variables

View Source
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) Create

func (c Core) Create(ctx context.Context, newShow NewShow, now time.Time) (Show, error)

Create inserts a new show into the database.

func (Core) Delete

func (c Core) Delete(ctx context.Context, showID string) error

Delete removes a show from the database.

func (Core) Query

func (c Core) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]Show, error)

Query retrieves a list of existing shows from the database.

func (*Core) QueryAllEnabled

func (c *Core) QueryAllEnabled(ctx context.Context) ([]Show, error)

QueryAllEnabled retrieves all shows which `enable` equals true from the database and saves them in cache.

func (Core) QueryByID

func (c Core) QueryByID(ctx context.Context, showID string) (Show, error)

QueryByID gets the specified show from the database.

func (Core) TotalNum

func (c Core) TotalNum(ctx context.Context) (int64, error)

TotalNum gets the total number of shows from the database.

func (Core) Update

func (c Core) Update(ctx context.Context, showID string, updateShow UpdateShow, now time.Time) error

Update replaces a show document in the database.

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 Show

type Show = kernel.Show

Show represents an individual 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.

Directories

Path Synopsis
Package db contains show related CRUD functionality.
Package db contains show related CRUD functionality.

Jump to

Keyboard shortcuts

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