后端: Go(Gin+GORM+MySQL+Redis) - 17张业务表(yz_pw_前缀), 自动迁移 - JWT认证(3小时) + 盐+MD5密码 + 图形验证码 - 班级CRUD/加入(8人姓名验证/邀请码)/审核/30天自动清理 - 系统配置(16项)/菜单管理(动态路由)/数据统计 - 文件MD5去重/数据隔离/账号封禁/敏感词DFA检测 前端: Vue3+Vite+Element Plus+Less+ECharts+FontAwesome - 动态路由(数据库菜单驱动) - 蓝白配色, H5响应式 - 登录/注册/忘记密码/个人中心 - 班级创建向导/详情/加入/列表 - 管理后台: 审核/配置/菜单/统计/用户/敏感词 数据库: MySQL 10.31.100.3:3306/photowall 管理员: hero920103 / 920103
74 lines
3.0 KiB
Go
74 lines
3.0 KiB
Go
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"`
|
|
}
|