| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package model
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("dim_business", "业务词典表").
- ID("id", 64).Comment("主键ID").End().
- String("project_id", 8).NotNull().Comment("项目编号").End().
- String("table_name", 64).NotNull().Comment("表名").End().
- String("field_name", 64).NotNull().Comment("字段名称(英文)").End().
- String("business_alias", 128).NotNull().Comment("业务别名").End().
- String("description", 128).Comment("描述").End().
- String("creator", 32).NotNull().Comment("创建人").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
- DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End()
-
- // 核心唯一索引:同一项目下业务别名必须唯一
- tb.AddUniqueIndex("uk_project_alias", "project_id", "business_alias")
-
- // 常用查询索引
- tb.AddIndex("idx_project_table_field", "project_id", "table_name", "field_name")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- // DimBusiness 业务词典结构体
- type DimBusiness struct {
- ID string `gorm:"column:id;type:varchar(64);primaryKey;comment:主键ID"`
- ProjectID string `gorm:"column:project_id;type:varchar(8);not null;index:idx_project_id;comment:项目编号"`
- TableName string `gorm:"column:table_name;type:varchar(64);not null;comment:表名"`
- FieldName string `gorm:"column:field_name;type:varchar(64);not null;comment:字段名称(英文)"`
- BusinessAlias string `gorm:"column:business_alias;type:varchar(128);not null;comment:业务别名"`
- Description string `gorm:"column:description;type:text;comment:描述"`
- Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
- CreatedAt time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
- }
-
- func (DimBusiness) DimBusiness() string {
- return "dim_business"
- }
|