| 123456789101112131415161718192021222324252627282930313233343536 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("dim_date", "时间维度表").
- ID("date_id", 32).Comment("日期ID,主键").End().
- Date("date_value").NotNull().Unique().Comment("日期值").End().
- Int("year").NotNull().Comment("年份").End().
- Int("quarter").NotNull().Comment("季度(1-4)").End().
- Int("month").NotNull().Comment("月份(1-12)").End().
- Int("week_of_year").NotNull().Comment("年第几周(1-52)").End().
- String("season", 10).Comment("季节(春/夏/秋/冬)").End().
- String("is_holiday", 1).Default("'0'").Comment("是否节假日(0:否,1:是)").End()
- r.RegisterTable(tb.Build())
- })
- }
-
- type DimDate struct {
- DateID string `gorm:"column:date_id;type:varchar(32);primaryKey;not null;comment:日期ID,主键"`
- DateValue time.Time `gorm:"column:date_value;type:date;not null;unique;comment:日期值"`
- Year int `gorm:"column:year;type:int(4);not null;comment:年份"`
- Quarter int `gorm:"column:quarter;type:int(1);not null;comment:季度"`
- Month int `gorm:"column:month;type:int(2);not null;comment:月份"`
- WeekOfYear int `gorm:"column:week_of_year;type:int(2);not null;comment:年第几周"`
- Season string `gorm:"column:season;type:varchar(10);comment:季节"`
- IsHoliday string `gorm:"column:is_holiday;type:varchar(1);default:0;comment:是否节假日"`
- TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"`
- }
-
- func (DimDate) TableName() string { return "dim_date" }
|