| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package model
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("dim_table", "表字典").
- ID("id", 64).Comment("主键ID").End().
- String("projectId", 8).NotNull().Comment("项目编号").End().
- String("table_name", 64).NotNull().Comment("表名").End(). // 最大64字符
- String("table_name_cn", 128).NotNull().Comment("中文表名").End(). // 中文名可以稍长
- Text("description").Comment("描述").End().
- String("primary_key_field_name", 64).NotNull().Comment("主键字段名").End(). // 修改为64
- String("creator", 32).NotNull().Comment("创建人").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
- r.RegisterTable(tb.Build())
-
- tb.AddIndex("idx_table_name", "table_name")
-
- })
- }
-
- // TableRequest 表字典结构体
- type DimTable struct {
- ID string `gorm:"column:id;type:varchar(64);primaryKey;comment:主键ID"`
- ProjectId string `gorm:"column:project_id;type:varchar(8);not null;comment:项目名称"`
- TableName string `gorm:"column:table_name;type:varchar(64);not null;comment:表名"`
- TableNameCN string `gorm:"column:table_name_cn;type:varchar(128);not null;comment:中文表名"`
- Description string `gorm:"column:description;type:text;comment:描述"`
- PrimaryKeyFieldName string `gorm:"column:primary_key_field_name;type:varchar(64);not null;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:创建时间"`
- }
-
- func (DimTable) DimTable() string {
- return "dim_table"
- }
|