| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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("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:移动电话"`
- 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"`
- UserID string `db:"user_id"`
- TenantID string `db:"tenant_id"`
- Name string `db:"name"`
- Mobile string `db:"mobile"`
- Creator string `db:"creator"`
- CreatedAt time.Time `db:"created_at"`
- }
-
- func (User) TableName() string {
- return "config_user"
- }
|