Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Course ¶
type Course struct {
gorm.Model
Name string `json:"name" gorm:"unique"`
Desc string `json:"desc"`
News []News `gorm:"many2many:course_has_news;" json:"news"`
Papers []Paper `gorm:"many2many:course_has_papers;" json:"papers"`
Questions []Question `gorm:"many2many:course_has_questions;" json:"questions"`
}
Course 课程,相当于分类的功能
type News ¶
type News struct {
gorm.Model
Title string `json:"title"`
Content string `gorm:"type:text;" json:"content"`
Bg string `json:"bg"` // 背景大图
Up int `gorm:"default:0;" json:"up"` // 被赞了多少次
Down int `gorm:"default:0;" json:"down"` // 被踩了多少次
UserID uint `json:"user"`
Courses []Course `gorm:"many2many:course_has_news;"`
}
News is users put news to this site
type Paper ¶
type Paper struct {
gorm.Model
Title string `json:"title"`
Alert string `json:"alert"` // 提示信息,警告信息什么的
Score float32 `json:"score"` // 可获得学分数量
Hero string `json:"hero"` // 图片
Questions []Question `gorm:"many2many:paper_has_questions;" json:"questions"`
Courses []Course `gorm:"many2many:course_has_papers;" json:"courses"`
Teacher uint ` json:"teacher"` // 卷子和教师是一对多的关系
Students []StudentPaper `json:"students"` // 卷子和学生是多对多的关系
}
Paper 考试卷子
type Question ¶
type Question struct {
gorm.Model
Title string `json:"title"`
Content string `json:"content"`
Answers string `gorm:"type:json;" json:"answers"`
Correct string `gorm:"type:json;" json:"correct"` // 正确答案的index
HasBug int `gorm:"default:'0'" json:"hasBug"`
Stared int `gorm:"default:'0'" json:"stared"`
Score int `gorm:"default:'0'" json:"score"` // 答对这道题,能得的分数
Courses []Course `gorm:"many2many:course_has_questions" json:"courses"`
}
Question is all the question
type StudentPaper ¶
type StudentPaper struct {
gorm.Model
Student uint `gorm:"ForeignKey:UserID" json:"studentID"`
Paper uint `gorm:"ForeignKey:PaperID" json:"paperID"`
PaperContent Paper `json:"paper"`
StudentContent User `json:"student"`
Score float32 `json:"score"`
}
StudentPaper is student has done many paper
type User ¶
type User struct {
gorm.Model
Role int `json:"role"` // 10-19 学生 20-29 教师
Name string `json:"name"`
SchoolID string `json:"schoolId"` // 学号,教师号什么的
Pwd string `json:"-"`
Avatar string `json:"avatar"` // 头像
PaperDone []StudentPaper `json:"paperDone"` // 完成的卷子,学生
Papers []Paper `gorm:"ForeignKey:Teacher" json:"papers"` // 自己所拥有的卷子, 教师
News []News `gorm:"ForeignKey:UserID" json:"news"`
PaperDoneByStudent []StudentPaper `json:"PaperDoneByStudent"` // 被学生完成的卷子
}
User is user model
Click to show internal directories.
Click to hide internal directories.