説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dic_table.go 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. TableID string `gorm:"column:table_id;type:varchar(64);not null;primaryKey;comment:表ID"`
  25. TableType string `gorm:"column:table_type;type:varchar(20);not null;comment:表类型: 实体表,视图,物化视图"`
  26. Name string `gorm:"column:table_name;type:varchar(100);not null;comment:表名称"`
  27. Description string `gorm:"column:description;type:varchar(500);not null;default:'';comment:表描述"`
  28. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  29. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  30. UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  31. DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
  32. }
  33. type DicTableDB struct {
  34. ID string `db:"id" json:"id"`
  35. TableID string `db:"table_id" json:"tableID"`
  36. TableType string `db:"table_type" json:"tableType"`
  37. Name string `db:"table_name" json:"name"`
  38. Description string `db:"description" json:"description"`
  39. Creator string `db:"creator" json:"creator"`
  40. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  41. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
  42. DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
  43. }
  44. func (DicTable) TableName() string {
  45. return "dic_table"
  46. }