Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536
  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. tb := sqldef.NewTable("dim_date", "时间维度表").
  9. ID("date_id", 32).Comment("日期ID,主键").End().
  10. Date("date_value").NotNull().Unique().Comment("日期值").End().
  11. Int("year").NotNull().Comment("年份").End().
  12. Int("quarter").NotNull().Comment("季度(1-4)").End().
  13. Int("month").NotNull().Comment("月份(1-12)").End().
  14. Int("week_of_year").NotNull().Comment("年第几周(1-52)").End().
  15. String("season", 10).Comment("季节(春/夏/秋/冬)").End().
  16. String("is_holiday", 1).Default("'0'").Comment("是否节假日(0:否,1:是)").End()
  17. r.RegisterTable(tb.Build())
  18. })
  19. }
  20. type DimDate struct {
  21. DateID string `gorm:"column:date_id;type:varchar(32);primaryKey;not null;comment:日期ID,主键"`
  22. DateValue time.Time `gorm:"column:date_value;type:date;not null;unique;comment:日期值"`
  23. Year int `gorm:"column:year;type:int(4);not null;comment:年份"`
  24. Quarter int `gorm:"column:quarter;type:int(1);not null;comment:季度"`
  25. Month int `gorm:"column:month;type:int(2);not null;comment:月份"`
  26. WeekOfYear int `gorm:"column:week_of_year;type:int(2);not null;comment:年第几周"`
  27. Season string `gorm:"column:season;type:varchar(10);comment:季节"`
  28. IsHoliday string `gorm:"column:is_holiday;type:varchar(1);default:0;comment:是否节假日"`
  29. TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
  30. }
  31. func (DimDate) TableName() string { return "dim_date" }