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.go 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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", "数据库字典表 - 管理数据库表字典").
  9. ID("table_id", 64).NotNull().Comment("表ID").End().
  10. String("table_type", 20).NotNull().Comment("表类型: 实体表,视图,物化视图").End().
  11. String("table_name", 100).NotNull().Comment("表名称").End().
  12. String("description", 500).NotNull().Default("''").Comment("表描述").End().
  13. String("creator", 32).NotNull().Comment("创建人").End().
  14. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  15. DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End().
  16. DateTime("deleted_at").Comment("删除时间").End()
  17. tb.AddIndex("idx_table_id", "table_id")
  18. tb.AddIndex("idx_table_name", "table_name")
  19. r.RegisterTable(tb.Build())
  20. })
  21. }
  22. type DicTable struct {
  23. TableID string `gorm:"column:table_id;type:varchar(64);not null;comment:表ID"`
  24. TableType string `gorm:"column:table_type;type:varchar(20);not null;comment:表类型: 实体表,视图,物化视图"`
  25. Name string `gorm:"column:table_name;type:varchar(100);not null;comment:表名称"`
  26. Description string `gorm:"column:description;type:varchar(500);not null;default:'';comment:表描述"`
  27. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  28. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  29. UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  30. DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
  31. }
  32. type DicTableDB struct {
  33. TableID string `db:"table_id" json:"tableID"`
  34. TableType string `db:"table_type" json:"tableType"`
  35. Name string `db:"table_name" json:"name"`
  36. Description string `db:"description" json:"description"`
  37. Creator string `db:"creator" json:"creator"`
  38. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  39. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
  40. DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
  41. }
  42. func (DicTable) TableName() string {
  43. return "dic_table"
  44. }