Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chapter ¶
type Chapter struct {
ID uint `gorm:"primarykey;auto_increment" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Name string `gorm:"column:name;type:varchar(50);not null" json:"name"`
Description string `gorm:"column:description;type:text" json:"description"`
NumberOfSub int `gorm:"column:number_of_sub;not null" json:"number_of_sub"`
CourseID uint `gorm:"column:course_id;not null" json:"course_id"`
Course Course `gorm:"foreignKey:CourseID;references:ID" json:"course"`
Subchapters []Subchapter `gorm:"foreignKey:ChapterID;constraint:OnDelete:CASCADE;" json:"subchapters"`
Order uint `gorm:"column:order;default:0" json:"order"`
}
type ChapterDTO ¶
type Course ¶
type Course struct {
ID uint `gorm:"primarykey;auto_increment" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Name string `gorm:"column:name;type:varchar(64);not null" json:"name"`
Description string `gorm:"column:description;type:text;not null;default:''" json:"description"`
TimeEstimated uint `gorm:"column:time_estimated;not null" json:"time_estimated"`
Rating float32 `gorm:"column:rating;type:float;not null;" json:"rating"`
CategoryID uint `gorm:"column:category_id" json:"category_id"`
Chapters []Chapter `gorm:"foreignKey:CourseID;constraint:OnDelete:CASCADE;" json:"chapters"`
Category Category `gorm:"foreignKey:CategoryID;references:ID"`
}
type CourseStructure ¶
type CourseStructure struct {
CourseID int `gorm:"primaryKey"`
ChapterID *int `gorm:"uniqueIndex:idx_course_chapter_subchapter"`
SubchapterID *int `gorm:"uniqueIndex:idx_course_chapter_subchapter"`
// Foreign key relation to CourseStructure
UserProgress UserProgress `gorm:"foreignKey:CourseID,ChapterID,SubchapterID;references:CourseID,ChapterID,SubchapterID;constraint:OnDelete:CASCADE"`
}
type Review ¶
type Review struct {
ID uint `gorm:"primarykey;auto_increment" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Content string `gorm:"column:content;not null" json:"content"`
Timestamp time.Time `gorm:"column:timestamptz;not null;default:CURRENT_TIMESTAMP" json:"timestamp"`
UserID uint `gorm:"column:user_id;not null" json:"user_id"`
CourseID uint `gorm:"column:course_id;not null" json:"course_id"`
User User `gorm:"foreignKey:UserID;references:ID"`
Course Course `gorm:"foreignKey:CourseID;references:ID"`
}
type Role ¶
type Role int
Role type definition
type Subchapter ¶
type Subchapter struct {
ID uint `gorm:"primarykey;auto_increment" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Name string `gorm:"column:name;size:64;not null" json:"name"`
Content string `gorm:"column:content;type:text;not null" json:"content"`
ChapterID uint `gorm:"column:chapter_id;not null" json:"chapter_id"`
Chapter Chapter `gorm:"foreignKey:ChapterID;references:ID" json:"-"`
Order uint `gorm:"column:order;default:0" json:"order"`
}
type SubchapterDTO ¶
type User ¶
type User struct {
ID uint `gorm:"primarykey;auto_increment" json:"id"`
Username string `gorm:"size:24;unique;not null;default:''" json:"username"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
FullName string `gorm:"column:full_name;size:64;unique;not null;default:''" json:"full_name"`
Email string `gorm:"column:email;size:64;unique;not null" json:"email"`
About string `gorm:"column:about;type:text" json:"about"`
Role string `gorm:"column:role;type:varchar(32);not null;check:role IN ('admin', 'student')" json:"role"`
Password string `gorm:"column:password;size:255;not null;default:''" json:"password"`
ImageURL string `gorm:"column:image_url;" json:"image_url"`
}
type UserCourseInteraction ¶
type UserCourseInteraction struct {
ID uint `gorm:"primarykey;auto_increment" json:"id"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
LastInteraction time.Time `gorm:"column:last_interaction;" json:"last_interaction"`
TimeSpent uint `gorm:"column:time_spent;default:0" json:"time_spent"`
Viewed bool `gorm:"column:viewed;default:false" json:"viewed"`
Registered bool `gorm:"column:registered;default:false" json:"registered"`
Completed bool `gorm:"column:completed;default:false" json:"completed"`
CompletionRate float32 `gorm:"column:completion_rate;check:completion_rate >= 0 AND completion_rate <= 1" json:"completion_rate"`
UserID uint `gorm:"column:user_id;not null" json:"user_id"`
CourseID uint `gorm:"column:course_id;not null" json:"course_id"`
NCompletedChapters uint `gorm:"column:n_completed_chapters;not null;default: 0" json:"n_completed_chapters"`
NCompletedSubChapters uint `gorm:"column:n_completed_sub_chapters;not null;default: 0" json:"n_completed_sub_chapters"`
// Association
User User `gorm:"foreignKey:UserID;references:ID"`
Course Course `gorm:"foreignKey:CourseID;references:ID"`
}
Click to show internal directories.
Click to hide internal directories.