Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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