| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("config_user", "配置用户表").
- ID("id", 128).NotNull().Comment("主键").End().
- String("user_id", 128).NotNull().Comment("用户ID").End().
- String("tenant_id", 128).NotNull().Comment("租户ID").End().
- String("name", 128).NotNull().Default("''").Comment("用户名称").End().
- String("mobile", 20).NotNull().Default("''").Comment("移动电话").End().
- String("password", 255).NotNull().Comment("密码(bcrypt加密)").End().
- TinyInt("status").NotNull().Default("1").Comment("状态:1启用,0禁用").End().
- String("email", 128).NotNull().Default("''").Comment("邮箱").End().
- String("creator", 32).NotNull().Comment("创建人").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
-
- tb.AddIndex("idx_user_id", "user_id")
- tb.AddIndex("idx_tenant_id", "tenant_id")
- tb.AddIndex("idx_mobile", "mobile")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type User struct {
- UserID string `gorm:"column:user_id;type:varchar(128);not null;primaryKey;comment:用户ID"`
- TenantID string `gorm:"column:tenant_id;type:varchar(128);not null;comment:租户ID"`
- Name string `gorm:"column:name;type:varchar(128);not null;default:'';comment:用户名称"`
- Mobile string `gorm:"column:mobile;type:varchar(20);not null;default:'';comment:移动电话"`
- Password string `gorm:"column:password;type:varchar(255);not null;comment:密码(bcrypt加密)"`
- Status int8 `gorm:"column:status;type:tinyint;not null;default:1;comment:状态:1启用,0禁用"`
- Email string `gorm:"column:email;type:varchar(128);not null;default:'';comment:邮箱"`
- Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
- CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- }
-
- type UserDB struct {
- ID string `db:"id" json:"id"`
- UserID string `db:"user_id" json:"userID"`
- TenantID string `db:"tenant_id" json:"tenantID"`
- Name string `db:"name" json:"name"`
- Mobile string `db:"mobile" json:"mobile"`
- Password string `db:"password" json:"password"`
- Status int8 `db:"status" json:"status"`
- Email string `db:"email" json:"email"`
- Creator string `db:"creator" json:"creator"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- }
-
- func (User) TableName() string {
- return "config_user"
- }
|