Нема описа
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.go 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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", "数据库表字段字典表 - 管理数据库表字段字典").
  9. ID("id", 128).NotNull().Comment("主键。table_id.field_id组成").End().
  10. String("field_id", 128).NotNull().Comment("字段ID").End().
  11. String("table_id", 64).NotNull().Comment("表ID").End().
  12. String("filed_type", 20).NotNull().Comment("字段类型: 实际字段,计算字段").End().
  13. String("data_type", 20).NotNull().Comment("数据类型: 字符型,数值型等").End().
  14. String("field_name", 64).NotNull().Comment("字段名称").End().
  15. String("field_name_cn", 64).NotNull().Default("''").Comment("字段中文名称 (ERP中业务名称)").End().
  16. String("description", 500).NotNull().Default("''").Comment("字段描述").End().
  17. String("creator", 32).NotNull().Comment("创建人").End().
  18. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  19. DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End().
  20. DateTime("deleted_at").Comment("删除时间").End()
  21. tb.AddIndex("idx_field_id", "field_id")
  22. tb.AddIndex("idx_table_id", "table_id")
  23. tb.AddIndex("idx_field_name", "field_name")
  24. r.RegisterTable(tb.Build())
  25. })
  26. }
  27. type DicTableField struct {
  28. ID string `gorm:"column:id;type:varchar(128);not null;primaryKey;comment:主键"`
  29. FieldID string `gorm:"column:field_id;type:varchar(128);not null;comment:字段ID"`
  30. TableID string `gorm:"column:table_id;type:varchar(64);not null;comment:表ID"`
  31. FiledType string `gorm:"column:filed_type;type:varchar(20);not null;comment:字段类型: 实际字段,计算字段"`
  32. DataType string `gorm:"column:data_type;type:varchar(20);not null;comment:数据类型: 字符型,数值型等"`
  33. FieldName string `gorm:"column:field_name;type:varchar(64);not null;comment:字段名称"`
  34. FieldNameCN string `gorm:"column:field_name_cn;type:varchar(64);not null;default:'';comment:字段中文名称 (ERP中业务名称)"`
  35. Description string `gorm:"column:description;type:varchar(500);not null;default:'';comment:字段描述"`
  36. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  37. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  38. UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  39. DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
  40. }
  41. type DicTableFieldDB struct {
  42. ID string `db:"id" json:"id"`
  43. FieldID string `db:"field_id" json:"fieldID"`
  44. TableID string `db:"table_id" json:"tableID"`
  45. FiledType string `db:"filed_type" json:"filedType"`
  46. DataType string `db:"data_type" json:"dataType"`
  47. FieldName string `db:"field_name" json:"fieldName"`
  48. FieldNameCN string `db:"field_name_cn" json:"fieldNameCN"`
  49. Description string `db:"description" json:"description"`
  50. Creator string `db:"creator" json:"creator"`
  51. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  52. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
  53. DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
  54. }
  55. func (DicTableField) TableName() string {
  56. return "dic_table_field"
  57. }