Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dic_table_field_alias.go 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package tables
  2. import (
  3. "time"
  4. "git.x2erp.com/qdy/go-db/sqldef"
  5. )
  6. func init() {
  7. sqldef.AddRegistration(func(r *sqldef.Registry) {
  8. tb := sqldef.NewTable("dic_table_field_alias", "数据库字段别名字典表 - 管理数据库字段别名字典,比如采购入库单里的结算数量(字段),又会叫采购数量,生产数量").
  9. ID("id", 50).NotNull().Comment("主键").End().
  10. String("field_id", 128).NotNull().Comment("字段ID").End().
  11. String("table_id", 64).NotNull().Comment("表ID").End().
  12. String("field_name", 64).NotNull().Comment("字段名称").End().
  13. String("field_alias", 50).NotNull().Comment("字段别名").End().
  14. String("description", 500).NotNull().Default("''").Comment("字段别名描述").End().
  15. String("where_condition", 500).NotNull().Default("''").Comment("此别名获取数据的查询条件描述").End().
  16. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  17. DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End().
  18. DateTime("deleted_at").Comment("删除时间").End()
  19. tb.AddIndex("idx_table_id", "table_id")
  20. tb.AddIndex("idx_field_name", "field_name")
  21. tb.AddIndex("idx_field_alias", "field_alias")
  22. tb.AddUniqueIndex("uk_field_alias", "field_alias")
  23. r.RegisterTable(tb.Build())
  24. })
  25. }
  26. type DicTableFieldAlias struct {
  27. ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键"`
  28. FieldID string `gorm:"column:field_id;type:varchar(128);not null;comment:字段ID"`
  29. TableID string `gorm:"column:table_id;type:varchar(64);not null;comment:表ID"`
  30. FieldName string `gorm:"column:field_name;type:varchar(64);not null;comment:字段名称"`
  31. FieldAlias string `gorm:"column:field_alias;type:varchar(50);not null;comment:字段别名"`
  32. Description string `gorm:"column:description;type:varchar(500);not null;default:'';comment:字段别名描述"`
  33. WhereCondition string `gorm:"column:where_condition;type:varchar(500);not null;default:'';comment:此别名获取数据的查询条件描述"`
  34. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  35. UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  36. DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
  37. }
  38. type DicTableFieldAliasDB struct {
  39. ID string `db:"id" json:"id"`
  40. FieldID string `db:"field_id" json:"fieldID"`
  41. TableID string `db:"table_id" json:"tableID"`
  42. FieldName string `db:"field_name" json:"fieldName"`
  43. FieldAlias string `db:"field_alias" json:"fieldAlias"`
  44. Description string `db:"description" json:"description"`
  45. WhereCondition string `db:"where_condition" json:"whereCondition"`
  46. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  47. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
  48. DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
  49. }
  50. func (DicTableFieldAlias) TableName() string {
  51. return "dic_table_field_alias"
  52. }