package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { // 城市档案主表 tb := sqldef.NewTable("dim_city", "城市档案表"). ID("city_id", 32).Comment("城市ID,主键").End(). String("city_code", 32).NotNull().Unique().Comment("城市编码").End(). String("city_name", 64).NotNull().Comment("城市名称").End(). String("country_code", 8).NotNull().Comment("国家代码(CN,US等)").End(). String("temperature_zone", 32).NotNull().Comment("温度带(热带/亚热带/温带/寒带)").End(). Decimal("avg_winter_temp", 5, 2).Comment("冬季平均温度℃").End(). Decimal("avg_summer_temp", 5, 2).Comment("夏季平均温度℃").End(). String("creator", 32).NotNull().Comment("创建人").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End() r.RegisterTable(tb.Build()) }) } type DimCity struct { CityID string `gorm:"column:city_id;type:varchar(32);primaryKey;not null;comment:城市ID,主键"` CityCode string `gorm:"column:city_code;type:varchar(32);not null;unique;comment:城市编码"` CityName string `gorm:"column:city_name;type:varchar(64);not null;comment:城市名称"` CountryCode string `gorm:"column:country_code;type:varchar(8);not null;comment:国家代码"` TemperatureZone string `gorm:"column:temperature_zone;type:varchar(32);not null;comment:温度带"` AvgWinterTemp float64 `gorm:"column:avg_winter_temp;type:decimal(5,2);comment:冬季平均温度℃"` AvgSummerTemp float64 `gorm:"column:avg_summer_temp;type:decimal(5,2);comment:夏季平均温度℃"` Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"` CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"` TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"` } func (DimCity) TableName() string { return "dim_city" }