package model import ( "time" ) // User 用户表 type User struct { ID uint `gorm:"primaryKey" json:"id"` Username string `gorm:"size:64;uniqueIndex;not null" json:"username"` PasswordHash string `gorm:"size:32;not null" json:"-"` // MD5 32字符 Salt string `gorm:"size:32;not null" json:"-"` // 密码盐 Email string `gorm:"size:128;index" json:"email"` // 用于找回密码 Nickname string `gorm:"size:64" json:"nickname"` Avatar string `gorm:"size:512" json:"avatar"` Bio string `gorm:"size:512" json:"bio"` Role string `gorm:"size:16;default:user;index" json:"role"` // user / admin Status string `gorm:"size:16;default:active;index" json:"status"` // active / banned BanReason string `gorm:"size:255" json:"ban_reason"` BannedAt *time.Time `json:"banned_at,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // ContactType 联系方式类型 type ContactType string const ( ContactEmail ContactType = "email" ContactQQ ContactType = "qq" ContactWeChat ContactType = "wechat" ContactPhone ContactType = "phone" ContactAddress ContactType = "address" ContactWorkUnit ContactType = "workunit" ) // ContactMaxCount 各类型联系方式上限 var ContactMaxCount = map[ContactType]int{ ContactEmail: 2, ContactQQ: 5, ContactWeChat: 2, ContactPhone: 5, ContactAddress: 1, ContactWorkUnit: 1, } // UserContact 用户联系方式 type UserContact struct { ID uint `gorm:"primaryKey" json:"id"` UserID uint `gorm:"index;not null" json:"user_id"` Type ContactType `gorm:"size:16;index;not null" json:"type"` Value string `gorm:"size:255;not null" json:"value"` IsPrimary bool `gorm:"default:false" json:"is_primary"` CreatedAt time.Time `json:"created_at"` } // EducationHistory 学习履历(用户必须至少有一条才能创建班级) type EducationHistory struct { ID uint `gorm:"primaryKey" json:"id"` UserID uint `gorm:"index;not null" json:"user_id"` SchoolID uint `gorm:"index" json:"school_id,omitempty"` // 关联平台学校(可选) CollegeID uint `gorm:"index" json:"college_id,omitempty"` // 关联学院(可选) ClassID uint `gorm:"index" json:"class_id,omitempty"` // 关联班级(可选) SchoolName string `gorm:"size:128;not null" json:"school_name"` // 学校名称(冗余,便于自由填写) CollegeName string `gorm:"size:128" json:"college_name"` Major string `gorm:"size:128" json:"major"` Degree string `gorm:"size:64" json:"degree"` // 本科/硕士/博士/高中/初中/小学/幼儿园 StartYear int `json:"start_year"` EndYear int `json:"end_year"` Description string `gorm:"size:512" json:"description"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }