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.
62 lines
2.8 KiB
62 lines
2.8 KiB
package model
|
|
|
|
import (
|
|
"database/sql/driver"
|
|
"encoding/json"
|
|
)
|
|
|
|
/*
|
|
用户模块
|
|
*/
|
|
|
|
const (
|
|
USER_ROLE_ADMIN = "0" // 管理员
|
|
USER_ROLE_AGENT = "1" // 代理
|
|
USER_ROLE_MEMBER = "2" // 用户
|
|
)
|
|
|
|
type User struct {
|
|
Uid int64 `gorm:"primary_key;column:uid" json:"uid"` // 用户ID
|
|
Role ArryString `gorm:"column:role" json:"role"` // 角色类型 [0,1,2,3] - [管理员,代理,用户]
|
|
Account string `gorm:"column:account" json:"account"` // 登录账号
|
|
Email string `gorm:"column:email" json:"email"` // 绑定邮箱
|
|
Mobile string `gorm:"column:mobile" json:"mobile"` // 手机号 - 格式:+86 1234
|
|
Status string `gorm:"column:status" json:"status"` // 状态 0-正常 1-拉黑
|
|
Invite string `gorm:"column:invite" json:"invite"` // 邀请码
|
|
MerchantId int64 `gorm:"column:merchant_id" json:"merchantId"` // 商户ID
|
|
Merchant Merchant `gorm:"-" json:"merchant,omitempty"` // 商户结构
|
|
RoleIds Arry `gorm:"-" json:"-"` // 拥有的角色权限
|
|
Detail UserDetail `gorm:"column:detail" json:"detail"` // 详细信息
|
|
}
|
|
|
|
func (User) TableName() string {
|
|
return "user"
|
|
}
|
|
|
|
type UserDetail struct {
|
|
Nickname string `json:"nickName"` // 用户名称
|
|
Avatar int64 `json:"avatar"` // 用户头像
|
|
Gender string `json:"gender"` // 0-男 1-女 2-未知
|
|
Token string `json:"token"` // 登陆token
|
|
PassWord string `json:"passWord"` // 登录密码
|
|
PayPassWord string `json:"payPassWord"` // 资金密码(支付密码)
|
|
PowerOver ArryString `json:"powerOver"` // 不能操作的权限
|
|
Memo string `json:"memo"` // 备注
|
|
RegisterIp string `json:"registerIp"` // 注册ip地址
|
|
RegisterIpAddress string `json:"registerIpAddress,omitempty"` // 注册ip地址
|
|
LoginErrorTime int64 `json:"loginErrorTime,omitempty"` // 登录错误时间
|
|
LoginErrorCount int64 `json:"loginErrorCount,omitempty"` // 登录错误次数
|
|
LoginTime int64 `json:"loginTime"` // 登陆时间
|
|
LoginIp string `json:"loginIp"` // 登陆ip
|
|
LoginIpAddress string `json:"loginIpAddress,omitempty"` // 登陆ip
|
|
CreateTime int64 `json:"createTime"` // 创建时间
|
|
}
|
|
|
|
func (j *UserDetail) Scan(value interface{}) error {
|
|
return json.Unmarshal(value.([]byte), &j)
|
|
}
|
|
|
|
func (j UserDetail) Value() (driver.Value, error) {
|
|
return json.Marshal(j)
|
|
}
|