package model import "time" // User 对应表 users,JSON 输出与现网接口 1:1(小写驼峰) type User struct { ID string `gorm:"column:id;primaryKey;size:50" json:"id"` OpenID *string `gorm:"column:open_id;size:100" json:"openId,omitempty"` SessionKey *string `gorm:"column:session_key;size:200" json:"-"` // 微信 session_key,不输出到 JSON Nickname *string `gorm:"column:nickname;size:100" json:"nickname,omitempty"` Avatar *string `gorm:"column:avatar;size:500" json:"avatar,omitempty"` Phone *string `gorm:"column:phone;size:20" json:"phone,omitempty"` WechatID *string `gorm:"column:wechat_id;size:100" json:"wechatId,omitempty"` ReferralCode *string `gorm:"column:referral_code;size:20" json:"referralCode,omitempty"` HasFullBook *bool `gorm:"column:has_full_book" json:"hasFullBook,omitempty"` PurchasedSections *string `gorm:"column:purchased_sections;type:json" json:"-"` // 内部字段,实际数据从 orders 表查 Earnings *float64 `gorm:"column:earnings;type:decimal(10,2)" json:"earnings,omitempty"` PendingEarnings *float64 `gorm:"column:pending_earnings;type:decimal(10,2)" json:"pendingEarnings,omitempty"` ReferralCount *int `gorm:"column:referral_count" json:"referralCount,omitempty"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` IsAdmin *bool `gorm:"column:is_admin" json:"isAdmin,omitempty"` WithdrawnEarnings *float64 `gorm:"column:withdrawn_earnings;type:decimal(10,2)" json:"withdrawnEarnings,omitempty"` Source *string `gorm:"column:source;size:50" json:"source,omitempty"` } func (User) TableName() string { return "users" }