package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("dic_table", "数据库字典表 - 管理数据库表字典"). ID("table_id", 64).NotNull().Comment("表ID").End(). String("table_type", 20).NotNull().Comment("表类型: 实体表,视图,物化视图").End(). String("table_name", 100).NotNull().Comment("表名称").End(). String("description", 500).NotNull().Default("''").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(). DateTime("deleted_at").Comment("删除时间").End() tb.AddIndex("idx_table_id", "table_id") tb.AddIndex("idx_table_name", "table_name") r.RegisterTable(tb.Build()) }) } type DicTable struct { TableID string `gorm:"column:table_id;type:varchar(64);not null;comment:表ID"` TableType string `gorm:"column:table_type;type:varchar(20);not null;comment:表类型: 实体表,视图,物化视图"` Name string `gorm:"column:table_name;type:varchar(100);not null;comment:表名称"` Description string `gorm:"column:description;type:varchar(500);not null;default:'';comment:表描述"` Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"` CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"` UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"` DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"` } type DicTableDB struct { TableID string `db:"table_id" json:"tableID"` TableType string `db:"table_type" json:"tableType"` Name string `db:"table_name" json:"name"` Description string `db:"description" json:"description"` Creator string `db:"creator" json:"creator"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"` } func (DicTable) TableName() string { return "dic_table" }