54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package Model
|
|
|
|
import (
|
|
_ "fmt"
|
|
//database_SQL
|
|
"gorm.io/gorm"
|
|
//end_database_SQL
|
|
)
|
|
|
|
// database_SQL
|
|
type CourseModel struct {
|
|
gorm.Model
|
|
ID uint `gorm:"column:id;primary_key"`
|
|
Title string `gorm:"column:title"`
|
|
Desc string `gorm:"column:desc"`
|
|
TimeCourse string `gorm:"column:time_course"`
|
|
DayCourse int `gorm:"column:Day_course"`
|
|
URLFileImg string `gorm:"column:url_file_img"`
|
|
Users []UserModel `gorm:"many2many:rh_user_course;foreignKey:id;References:id"`
|
|
Exercises []ExerciseModel `gorm:"many2many:rh_exercise_course;foreignKey:id;References:id"`
|
|
}
|
|
|
|
func (CourseModel) TableName() string {
|
|
return "rh_course"
|
|
}
|
|
|
|
type ExerciseModel struct {
|
|
gorm.Model
|
|
ID uint `gorm:"column:id;primary_key"`
|
|
Title string `gorm:"column:title"`
|
|
Desc string `gorm:"column:desc"`
|
|
URLFile string `gorm:"column:url_file"`
|
|
URLFileImg string `gorm:"column:url_file_img"`
|
|
Courses []CourseModel `gorm:"many2many:rh_exercise_course;foreignKey:id;References:id"`
|
|
}
|
|
|
|
func (ExerciseModel) TableName() string {
|
|
return "rh_exercise"
|
|
}
|
|
|
|
type ExerciseCourseModel struct {
|
|
gorm.Model
|
|
IDCourse uint `gorm:"column:exercise_model_id"`
|
|
IDExercise uint `gorm:"column:course_model_id"`
|
|
Day int `gorm:"column:day"`
|
|
Position int `gorm:"column:position"`
|
|
Time string `gorm:"column:time"`
|
|
Users []UserModel `gorm:"many2many:rh_users_exercise_course;foreignKey:id;References:id"`
|
|
}
|
|
|
|
func (ExerciseCourseModel) TableName() string {
|
|
return "rh_exercise_course"
|
|
}
|