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.

config_user.go 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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("password", 255).NotNull().Comment("密码(bcrypt加密)").End().
  15. TinyInt("status").NotNull().Default("1").Comment("状态:1启用,0禁用").End().
  16. String("email", 128).NotNull().Default("''").Comment("邮箱").End().
  17. String("creator", 32).NotNull().Comment("创建人").End().
  18. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  19. tb.AddIndex("idx_user_id", "user_id")
  20. tb.AddIndex("idx_tenant_id", "tenant_id")
  21. tb.AddIndex("idx_mobile", "mobile")
  22. r.RegisterTable(tb.Build())
  23. })
  24. }
  25. type User struct {
  26. UserID string `gorm:"column:user_id;type:varchar(128);not null;primaryKey;comment:用户ID"`
  27. TenantID string `gorm:"column:tenant_id;type:varchar(128);not null;comment:租户ID"`
  28. Name string `gorm:"column:name;type:varchar(128);not null;default:'';comment:用户名称"`
  29. Mobile string `gorm:"column:mobile;type:varchar(20);not null;default:'';comment:移动电话"`
  30. Password string `gorm:"column:password;type:varchar(255);not null;comment:密码(bcrypt加密)"`
  31. Status int8 `gorm:"column:status;type:tinyint;not null;default:1;comment:状态:1启用,0禁用"`
  32. Email string `gorm:"column:email;type:varchar(128);not null;default:'';comment:邮箱"`
  33. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  34. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  35. }
  36. type UserDB struct {
  37. ID string `db:"id" json:"id"`
  38. UserID string `db:"user_id" json:"userID"`
  39. TenantID string `db:"tenant_id" json:"tenantID"`
  40. Name string `db:"name" json:"name"`
  41. Mobile string `db:"mobile" json:"mobile"`
  42. Password string `db:"password" json:"password"`
  43. Status int8 `db:"status" json:"status"`
  44. Email string `db:"email" json:"email"`
  45. Creator string `db:"creator" json:"creator"`
  46. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  47. }
  48. func (User) TableName() string {
  49. return "config_user"
  50. }