50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package user
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitlab.com/go-course-project/go17/vblog/utils"
|
|
)
|
|
|
|
type User struct {
|
|
// 存放到数据里的对象的远数据信息
|
|
utils.ResourceMeta
|
|
// 具体参数
|
|
RegistryRequest
|
|
}
|
|
|
|
type RegistryRequest struct {
|
|
// 用户名
|
|
Username string `json:"username" gorm:"column:username;unique;index"`
|
|
// 密码
|
|
Password string `json:"password" gorm:"column:username;type:varchar(255)"`
|
|
// Profile 信息
|
|
Profile
|
|
// 用户状态
|
|
Status
|
|
}
|
|
|
|
type Profile struct {
|
|
// 头像
|
|
Avatar string `json:"avatar" gorm:"column:avatar;type:varchar(255)"`
|
|
// 用户昵称
|
|
NickName string `json:"nic_name" gorm:"column:nic_name;type:varchar(100)"`
|
|
// 用户邮箱, 验证用户有效性
|
|
Email string `json:"email" gorm:"column:email;type:varchar(100)"`
|
|
}
|
|
|
|
type Status struct {
|
|
// 冻结时间
|
|
BlockAt *time.Time `json:"block_at" gorm:"column:block_at"`
|
|
// 冻结原因
|
|
BlockReason string `json:"block_reason" gorm:"column:block_reason;type:text"`
|
|
}
|
|
|
|
func (s *Status) IsBlocked() bool {
|
|
return s.BlockAt != nil
|
|
}
|
|
|
|
func (u *User) TableName() string {
|
|
return "users"
|
|
}
|