Ingen beskrivning
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.

config_user.go 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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("config_user", "配置用户表").
  9. ID("id", 128).NotNull().Comment("主键").End().
  10. String("user_id", 128).NotNull().Comment("用户ID").End().
  11. String("tenant_id", 128).NotNull().Comment("租户ID").End().
  12. String("name", 128).NotNull().Default("''").Comment("用户名称").End().
  13. String("mobile", 20).NotNull().Default("''").Comment("移动电话").End().
  14. String("creator", 32).NotNull().Comment("创建人").End().
  15. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  16. tb.AddIndex("idx_user_id", "user_id")
  17. tb.AddIndex("idx_tenant_id", "tenant_id")
  18. tb.AddIndex("idx_mobile", "mobile")
  19. r.RegisterTable(tb.Build())
  20. })
  21. }
  22. type User struct {
  23. UserID string `gorm:"column:user_id;type:varchar(128);not null;primaryKey;comment:用户ID"`
  24. TenantID string `gorm:"column:tenant_id;type:varchar(128);not null;comment:租户ID"`
  25. Name string `gorm:"column:name;type:varchar(128);not null;default:'';comment:用户名称"`
  26. Mobile string `gorm:"column:mobile;type:varchar(20);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. }
  30. type UserDB struct {
  31. ID string `db:"id"`
  32. UserID string `db:"user_id"`
  33. TenantID string `db:"tenant_id"`
  34. Name string `db:"name"`
  35. Mobile string `db:"mobile"`
  36. Creator string `db:"creator"`
  37. CreatedAt time.Time `db:"created_at"`
  38. }
  39. func (User) TableName() string {
  40. return "config_user"
  41. }