Accept sort_order on CreateLessonInput; SQL falls back to max+1. When set, shift sibling lessons and insert at that position (same pattern as module create). Regenerate sqlc and update Swagger. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
// Lesson belongs to a Module.
|
|
type Lesson struct {
|
|
ID int64 `json:"id"`
|
|
ModuleID int64 `json:"module_id"`
|
|
Title string `json:"title"`
|
|
VideoURL *string `json:"video_url,omitempty"`
|
|
Thumbnail *string `json:"thumbnail,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
SortOrder int `json:"sort_order"`
|
|
HasPractice bool `json:"has_practice"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt *time.Time `json:"updated_at,omitempty"`
|
|
Access *LMSEntityAccess `json:"access,omitempty"`
|
|
}
|
|
|
|
type CreateLessonInput struct {
|
|
Title string `json:"title" validate:"required"`
|
|
VideoURL *string `json:"video_url,omitempty"`
|
|
Thumbnail *string `json:"thumbnail,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
// SortOrder within the module when set; omit to append after current max within module_id.
|
|
SortOrder *int `json:"sort_order,omitempty" validate:"omitempty,min=0"`
|
|
}
|
|
|
|
type UpdateLessonInput struct {
|
|
Title *string `json:"title,omitempty"`
|
|
VideoURL *string `json:"video_url,omitempty"`
|
|
Thumbnail *string `json:"thumbnail,omitempty"`
|
|
Description *string `json:"description,omitempty"`
|
|
SortOrder *int `json:"sort_order,omitempty"`
|
|
}
|