Açıklama Yok
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_alias.go 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_alias", "数据库表别名字典表 - 管理数据库表别名字典,比如调拨单(表),又会叫移库单,移仓单").
  9. ID("id", 50).NotNull().Comment("主键").End().
  10. String("table_id", 64).NotNull().Comment("表ID").End().
  11. String("table_alias", 50).NotNull().Comment("别名").End().
  12. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End().
  13. DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End().
  14. DateTime("deleted_at").Comment("删除时间").End()
  15. tb.AddIndex("idx_table_id", "table_id")
  16. tb.AddIndex("idx_table_alias", "table_alias")
  17. tb.AddUniqueIndex("uk_table_alias", "table_alias")
  18. r.RegisterTable(tb.Build())
  19. })
  20. }
  21. type DicTableAlias struct {
  22. ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键"`
  23. TableID string `gorm:"column:table_id;type:varchar(64);not null;comment:表ID"`
  24. TableAlias string `gorm:"column:table_alias;type:varchar(50);not null;comment:别名"`
  25. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  26. UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"`
  27. DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
  28. }
  29. type DicTableAliasDB struct {
  30. ID string `db:"id" json:"id"`
  31. TableID string `db:"table_id" json:"tableID"`
  32. TableAlias string `db:"table_alias" json:"tableAlias"`
  33. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  34. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
  35. DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
  36. }
  37. func (DicTableAlias) TableName() string {
  38. return "dic_table_alias"
  39. }