Documentation ¶
Index ¶
- func Create(ctx context.Context, db sqlx.ExtContext, video Video) error
- func HandleCreate(db *sqlx.DB) web.Handler
- func HandleList(db *sqlx.DB) web.Handler
- func HandleListByCourse(db *sqlx.DB) web.Handler
- func HandleListProgressByCourse(db *sqlx.DB) web.Handler
- func HandleShow(db *sqlx.DB) web.Handler
- func HandleShowFree(db *sqlx.DB) web.Handler
- func HandleShowFull(db *sqlx.DB) web.Handler
- func HandleUpdate(db *sqlx.DB) web.Handler
- func HandleUpdateProgress(db *sqlx.DB) web.Handler
- func UpdateProgress(ctx context.Context, db sqlx.ExtContext, userID string, videoID string, ...) error
- type Progress
- type ProgressUp
- type Video
- func Fetch(ctx context.Context, db sqlx.ExtContext, id string) (Video, error)
- func FetchAll(ctx context.Context, db sqlx.ExtContext) ([]Video, error)
- func FetchAllByCourse(ctx context.Context, db sqlx.ExtContext, courseID string) ([]Video, error)
- func Update(ctx context.Context, db sqlx.ExtContext, video Video) (Video, error)
- type VideoNew
- type VideoUp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleCreate ¶
HandleCreate allows administrators to insert a new video in a course.
func HandleList ¶
HandleList returns all the available videos. It doesn't return the actual URL of videos, so it can be safely exposed.
func HandleListByCourse ¶
HandleListByCourse returns all the available videos of a course. It doesn't return the actual URL of videos, so it can be safely exposed.
func HandleListProgressByCourse ¶
HandleListProgressByCourse returns all the progress of a user on a specific course.
func HandleShow ¶
HandleShow returns the information of a specific video. It doesn't return the actual URL of videos, so it can be safely exposed.
func HandleShowFree ¶
HandleShowFree returns all information useful for presenting the video to users. Only free videos can be retrieved with this function. Thus, it can be safely exposed.
func HandleShowFull ¶
HandleShowFull returns all data useful for presenting the video to users. This returns the URL also, so only owners of a video are allowed to call this.
func HandleUpdate ¶
HandleUpdate allows administrators to update videos' information.
func HandleUpdateProgress ¶
HandleUpdateProgress inserts a progress on a video for a specific user.
func UpdateProgress ¶
func UpdateProgress(ctx context.Context, db sqlx.ExtContext, userID string, videoID string, value int) error
UpdateProgress upserts user's progress on a video.
Types ¶
type Progress ¶
type Progress struct { VideoID string `json:"videoId" db:"video_id"` UserID string `json:"userId" db:"user_id"` Progress int `json:"progress" db:"progress"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` }
Progress models users' progress on videos.
func FetchUserProgressByCourse ¶
func FetchUserProgressByCourse(ctx context.Context, db sqlx.ExtContext, userID string, courseID string) ([]Progress, error)
FetchUserProgressByCourse returns user's progress on videos of a specific course.
type ProgressUp ¶
type ProgressUp struct {
Progress int `json:"progress" validate:"gte=0,lte=100"`
}
ProgressUp contains the data of a progress which can be updated.
type Video ¶
type Video struct { ID string `json:"id" db:"video_id"` CourseID string `json:"courseId" db:"course_id"` Index int `json:"index" db:"index"` Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` Free bool `json:"free" db:"free"` URL string `json:"-" db:"url"` ImageURL string `json:"imageUrl" db:"image_url"` CreatedAt time.Time `json:"createdAt" db:"created_at"` UpdatedAt time.Time `json:"updatedAt" db:"updated_at"` Version int `json:"-" db:"version"` }
Video models videos. A course can contain many videos. A video can be contained by a course only. URL is not marhsalled to JSON to avoid security issues.
func FetchAllByCourse ¶
FetchAllByCourse returns all available videos belonging to a specific course.
type VideoNew ¶
type VideoNew struct { CourseID string `json:"courseId" validate:"required"` Index int `json:"index" validate:"required,gte=0"` Name string `json:"name" validate:"required"` Description string `json:"description" validate:"required"` Free bool `json:"free" validate:"required"` URL string `json:"url" validate:"omitempty,url"` ImageURL string `json:"imageUrl" validate:"required"` }
VideoNew contains all the information needed to insert a new video.
type VideoUp ¶
type VideoUp struct { CourseID *string `json:"courseId"` Index *int `json:"index" validate:"omitempty,gte=0"` Name *string `json:"name"` Description *string `json:"description"` Free *bool `json:"free"` URL *string `json:"url" validate:"omitempty,url"` ImageURL *string `json:"imageUrl"` }
VideoUp specifies the data of videos that can be updated.