Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

dic_table.go 2.5KB

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