34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// PrivacyLevel 隐私级别
|
|
type PrivacyLevel int
|
|
|
|
const (
|
|
PrivacyPublic PrivacyLevel = 1 // 公开
|
|
PrivacyFriendsOnly PrivacyLevel = 2 // 仅好友可见
|
|
PrivacyPrivate PrivacyLevel = 3 // 仅自己可见
|
|
)
|
|
|
|
// User 用户模型
|
|
type User struct {
|
|
ID string `gorm:"primaryKey;type:varchar(32)" json:"id"`
|
|
Phone *string `gorm:"uniqueIndex;type:varchar(20)" json:"phone,omitempty"`
|
|
Nickname *string `gorm:"type:varchar(50)" json:"nickname,omitempty"`
|
|
Avatar *string `gorm:"type:varchar(255)" json:"avatar,omitempty"`
|
|
Bio *string `gorm:"type:varchar(100)" json:"bio,omitempty"`
|
|
Motto *string `gorm:"type:varchar(50)" json:"motto,omitempty"`
|
|
Privacy PrivacyLevel `gorm:"default:2" json:"privacy"`
|
|
Points int `gorm:"default:0" json:"points"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
|
|
|
// 关联
|
|
CheckInItems []CheckInItem `gorm:"foreignKey:UserID" json:"-"`
|
|
Records []CheckInRecord `gorm:"foreignKey:UserID" json:"-"`
|
|
Posts []Post `gorm:"foreignKey:UserID" json:"-"`
|
|
}
|
|
|
|
func (User) TableName() string { return "users" }
|