Accept sort_order in CreateModuleInput, shift siblings when set, and default to max+1 when omitted. Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package domain
|
||
|
||
import "time"
|
||
|
||
// Module belongs to a Course. program_id is the course’s program (stored for querying; not required from the client on create).
|
||
type Module struct {
|
||
ID int64 `json:"id"`
|
||
ProgramID int64 `json:"program_id"`
|
||
CourseID int64 `json:"course_id"`
|
||
Name string `json:"name"`
|
||
Description *string `json:"description,omitempty"`
|
||
Icon *string `json:"icon,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 CreateModuleInput struct {
|
||
Name string `json:"name" validate:"required"`
|
||
Description *string `json:"description,omitempty"`
|
||
Icon *string `json:"icon,omitempty"`
|
||
// SortOrder within the course when set; omit to append after current max within course_id (uniqueness is per-course).
|
||
SortOrder *int `json:"sort_order,omitempty" validate:"omitempty,min=0"`
|
||
}
|
||
|
||
type UpdateModuleInput struct {
|
||
Name *string `json:"name,omitempty"`
|
||
Description *string `json:"description,omitempty"`
|
||
Icon *string `json:"icon,omitempty"`
|
||
SortOrder *int `json:"sort_order,omitempty"`
|
||
}
|