| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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_alias", "数据库字段别名字典表 - 管理数据库字段别名字典,比如采购入库单里的结算数量(字段),又会叫采购数量,生产数量").
- ID("id", 32).NotNull().Comment("主键").End().
- String("field_id", 128).NotNull().Comment("字段ID").End().
- String("table_id", 64).NotNull().Comment("表ID").End().
- String("field_name", 64).NotNull().Comment("字段名称").End().
- String("field_alias", 32).NotNull().Comment("字段别名").End().
- String("description", 500).NotNull().Default("''").Comment("字段别名描述").End().
- String("where", 500).NotNull().Default("''").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_field_name", "field_name")
- tb.AddIndex("idx_field_alias", "field_alias")
- tb.AddUniqueIndex("uk_field_alias", "field_alias")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type DicTableFieldAlias struct {
- 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"`
- FieldName string `gorm:"column:field_name;type:varchar(64);not null;comment:字段名称"`
- FieldAlias string `gorm:"column:field_alias;type:varchar(32);not null;primaryKey;comment:字段别名"`
- Description string `gorm:"column:description;type:varchar(500);not null;default:'';comment:字段别名描述"`
- WhereCondition string `gorm:"column:where;type:varchar(500);not null;default:'';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 DicTableFieldAliasDB struct {
- ID string `db:"id" json:"id"`
- FieldID string `db:"field_id" json:"fieldID"`
- TableID string `db:"table_id" json:"tableID"`
- FieldName string `db:"field_name" json:"fieldName"`
- FieldAlias string `db:"field_alias" json:"fieldAlias"`
- Description string `db:"description" json:"description"`
- WhereCondition string `db:"where" json:"whereCondition"`
- 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 (DicTableFieldAlias) TableName() string {
- return "dic_table_field_alias"
- }
|