feat:完善信息
This commit is contained in:
@ -1,48 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TenantUser struct {
|
||||
Model
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_tenant_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;index:idx_tenant_user_mobile;type:varchar(15);default:null;comment:联系方式" json:"mobile"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
||||
Password string `gorm:"column:password;type:varchar(100);default:null;comment:密码" json:"-"`
|
||||
Salt string `gorm:"column:salt;type:varchar(10);default:null;comment:盐值" json:"-"`
|
||||
Province uint64 `gorm:"column:province;type:int;default:0;comment:所在省" json:"province"`
|
||||
City uint64 `gorm:"column:city;type:int;default:0;comment:所在市" json:"city"`
|
||||
District uint64 `gorm:"column:district;type:int;default:0;comment:所在区/县" json:"district"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
AccountStatus
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *TenantUser) TableName() string {
|
||||
return m.NewTableName("tenant_user")
|
||||
}
|
||||
|
||||
func (m *TenantUser) BeforeCreate(db *gorm.DB) error {
|
||||
m.NewPassword()
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.Status = AccountStatusForEnable
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TenantUser) NewPassword() {
|
||||
m.Salt = utils.GetRandomString(8)
|
||||
m.Password = utils.HashString([]byte(utils.Md5String(m.Password, m.Salt)))
|
||||
}
|
||||
|
||||
func NewTenantUser() *TenantUser {
|
||||
return &TenantUser{}
|
||||
}
|
42
app/common/model/user_instance.go
Normal file
42
app/common/model/user_instance.go
Normal file
@ -0,0 +1,42 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserInstance 账号信息
|
||||
type UserInstance struct {
|
||||
Model
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_tenant_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Mobile string `gorm:"column:mobile;index:idx_user_instance_mobile;type:varchar(15);default:null;comment:联系方式" json:"mobile"`
|
||||
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
||||
Password string `gorm:"column:password;type:varchar(100);default:null;comment:密码" json:"-"`
|
||||
Salt string `gorm:"column:salt;type:varchar(10);default:null;comment:盐值" json:"-"`
|
||||
AccountStatus
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *UserInstance) TableName() string {
|
||||
return "user_instance"
|
||||
}
|
||||
|
||||
func (m *UserInstance) BeforeCreate(db *gorm.DB) error {
|
||||
m.NewPassword()
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.Status = AccountStatusForEnable
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserInstance) NewPassword() {
|
||||
m.Salt = utils.GetRandomString(8)
|
||||
m.Password = utils.HashString([]byte(utils.Md5String(m.Password, m.Salt)))
|
||||
}
|
||||
|
||||
func NewUserInstance() *UserInstance {
|
||||
return &UserInstance{}
|
||||
}
|
51
app/common/model/user_tenant.go
Normal file
51
app/common/model/user_tenant.go
Normal file
@ -0,0 +1,51 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserTenant struct {
|
||||
Model
|
||||
ModelTenant
|
||||
UID uint64 `gorm:"column:uid;index:idx_tenant_user_uuid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_tenant_user_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||
Avatar string `gorm:"column:avatar;type:varchar(255);default:null;comment:头像" json:"avatar"`
|
||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||
Identity int `gorm:"column:identity;type:tinyint(3);default:0;comment:身份信息" json:"-"`
|
||||
Province uint64 `gorm:"column:province;type:int;default:0;comment:所在省" json:"province"`
|
||||
City uint64 `gorm:"column:city;type:int;default:0;comment:所在市" json:"city"`
|
||||
District uint64 `gorm:"column:district;type:int;default:0;comment:所在区/县" json:"district"`
|
||||
Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"`
|
||||
Selected UserTenantSelected `gorm:"column:selected;type:tinyint(1);default:0;comment:最后一次选中的身份状态,用于下次登陆展示" json:"-"`
|
||||
Other string `gorm:"column:other;type:varchar(255);default:null;comment:其他信息" json:"-"`
|
||||
Status int `gorm:"column:status;type:tinyint(0);default:0;comment:状态" json:"-"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
type UserTenantSelected int
|
||||
|
||||
const (
|
||||
// UserTenantSelectedForNo 未选中
|
||||
UserTenantSelectedForNo UserTenantSelected = iota
|
||||
// UserTenantSelectedForYes 以选中
|
||||
UserTenantSelectedForYes
|
||||
)
|
||||
|
||||
func (m *UserTenant) TableName() string {
|
||||
return m.NewTableName("user_tenant")
|
||||
}
|
||||
|
||||
func (m *UserTenant) BeforeCreate(db *gorm.DB) error {
|
||||
snowflake, _ := utils.NewSnowflake(1)
|
||||
m.UUID = uint64(snowflake.GetID())
|
||||
m.CreatedAt = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewUserTenant() *UserTenant {
|
||||
return &UserTenant{}
|
||||
}
|
Reference in New Issue
Block a user