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"` }