后端: 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
63 lines
2.3 KiB
Go
63 lines
2.3 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
// RegionLevel 地区层级
|
|
type RegionLevel string
|
|
|
|
const (
|
|
LevelCountry RegionLevel = "country"
|
|
LevelProvince RegionLevel = "province" // 省/州/直辖市
|
|
LevelCounty RegionLevel = "county" // 县/区(最低级)
|
|
)
|
|
|
|
// Region 地区表,自关联三级:国家 -> 省/州 -> 县/区
|
|
type Region struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Name string `gorm:"size:128;not null;index" json:"name"`
|
|
NameEn string `gorm:"size:128" json:"name_en"`
|
|
Level RegionLevel `gorm:"size:16;index;not null" json:"level"`
|
|
ParentID uint `gorm:"index" json:"parent_id"`
|
|
Code string `gorm:"size:32;index" json:"code"` // 行政区划代码/国家代码,可选
|
|
SortOrder int `gorm:"default:0" json:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// SchoolType 学校类型
|
|
type SchoolType string
|
|
|
|
const (
|
|
SchoolUniversity SchoolType = "university" // 大学(含学院层级)
|
|
SchoolJuniorHigh SchoolType = "junior_high" // 初中
|
|
SchoolSeniorHigh SchoolType = "senior_high" // 高中
|
|
SchoolPrimary SchoolType = "primary" // 小学
|
|
SchoolKindergarten SchoolType = "kindergarten" // 幼儿园
|
|
SchoolVocational SchoolType = "vocational" // 职业学校/中专(也可设学院)
|
|
SchoolOther SchoolType = "other"
|
|
)
|
|
|
|
// HasCollege 该类型学校是否有学院层级
|
|
func (s SchoolType) HasCollege() bool {
|
|
return s == SchoolUniversity || s == SchoolVocational
|
|
}
|
|
|
|
// School 学校
|
|
type School struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
RegionID uint `gorm:"index;not null" json:"region_id"` // 必须挂在 county 级地区下
|
|
Name string `gorm:"size:128;not null;index" json:"name"`
|
|
NameEn string `gorm:"size:128" json:"name_en"`
|
|
SchoolType SchoolType `gorm:"size:24;index;not null" json:"school_type"`
|
|
Address string `gorm:"size:255" json:"address"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// College 学院(仅大学/职业学校有)
|
|
type College struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
SchoolID uint `gorm:"index;not null" json:"school_id"`
|
|
Name string `gorm:"size:128;not null" json:"name"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|