package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { // 温度带季节上下架子表 tb := sqldef.NewTable("dim_city_temperature", "温度带季节波段表"). ID("band_id", 32).Comment("波段ID,主键").End(). String("temperature_zone", 32).NotNull().Comment("温度带").End(). String("season", 32).NotNull().Comment("季节(春/夏/秋/冬)").End(). Int("start_month").NotNull().Comment("开始月份(1-12)").End(). Int("start_day").NotNull().Comment("开始日期(1-31)").End(). Int("end_month").NotNull().Comment("结束月份(1-12)").End(). Int("end_day").NotNull().Comment("结束日期(1-31)").End(). String("season_id", 32).NotNull().Comment("服装类型(春装/夏装/秋装/冬装)").End(). String("creator", 32).NotNull().Comment("创建人").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End() // 添加唯一索引,防止重复配置 //tb.Index("uk_temperature_season", "temperature_zone", "season", "clothing_type").Unique().End() r.RegisterTable(tb.Build()) }) } type DimTemperatureSeasonBand struct { BandID string `gorm:"column:band_id;type:varchar(32);primaryKey;not null;comment:波段ID,主键"` TemperatureZone string `gorm:"column:temperature_zone;type:varchar(32);not null;comment:温度带"` Season string `gorm:"column:season;type:varchar(32);not null;comment:季节"` StartMonth int `gorm:"column:start_month;type:int(2);not null;comment:开始月份"` StartDay int `gorm:"column:start_day;type:int(2);not null;comment:开始日期"` EndMonth int `gorm:"column:end_month;type:int(2);not null;comment:结束月份"` EndDay int `gorm:"column:end_day;type:int(2);not null;comment:结束日期"` ClothingType string `gorm:"column:clothing_type;type:varchar(32);not null;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 (DimTemperatureSeasonBand) TableName() string { return "dim_temperature_season_band" }