package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("dic_table_field", "数据库表字段字典表 - 管理数据库表字段字典"). ID("id", 128).NotNull().Comment("主键。table_id.field_id组成").End(). String("field_id", 128).NotNull().Comment("字段ID").End(). String("table_id", 64).NotNull().Comment("表ID").End(). String("filed_type", 20).NotNull().Comment("字段类型: 实际字段,计算字段").End(). String("data_type", 20).NotNull().Comment("数据类型: 字符型,数值型等").End(). String("field_name", 64).NotNull().Comment("字段名称").End(). String("field_name_cn", 64).NotNull().Default("''").Comment("字段中文名称 (ERP中业务名称)").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_field_id", "field_id") tb.AddIndex("idx_table_id", "table_id") tb.AddIndex("idx_field_name", "field_name") r.RegisterTable(tb.Build()) }) } type DicTableField struct { ID string `gorm:"column:id;type:varchar(128);not null;primaryKey;comment:主键"` FieldID string `gorm:"column:field_id;type:varchar(128);not null;comment:字段ID"` TableID string `gorm:"column:table_id;type:varchar(64);not null;comment:表ID"` FiledType string `gorm:"column:filed_type;type:varchar(20);not null;comment:字段类型: 实际字段,计算字段"` DataType string `gorm:"column:data_type;type:varchar(20);not null;comment:数据类型: 字符型,数值型等"` FieldName string `gorm:"column:field_name;type:varchar(64);not null;comment:字段名称"` FieldNameCN string `gorm:"column:field_name_cn;type:varchar(64);not null;default:'';comment:字段中文名称 (ERP中业务名称)"` 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 DicTableFieldDB struct { ID string `db:"id" json:"id"` FieldID string `db:"field_id" json:"fieldID"` TableID string `db:"table_id" json:"tableID"` FiledType string `db:"filed_type" json:"filedType"` DataType string `db:"data_type" json:"dataType"` FieldName string `db:"field_name" json:"fieldName"` FieldNameCN string `db:"field_name_cn" json:"fieldNameCN"` 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 (DicTableField) TableName() string { return "dic_table_field" }