package session import ( "SciencesServer/utils" "encoding/json" "fmt" "time" ) // Enterprise 企业用户 type Enterprise struct { Token string `json:"token"` // token UID uint64 `json:"uid"` // 唯一标识ID IdentityUID uint64 `json:"identity_uid"` // 用户身份唯一ID Avatar string `json:"avatar"` // 头像 Name string `json:"name"` // 名称 Mobile string `json:"mobile"` // 手机号码 Vip int `json:"vip"` // VIP VipStatus bool `json:"vip_status"` // VIP状态 VipDeadline time.Time `json:"vip_deadline"` // VIP过期时间 Currency float64 `json:"currency"` // 货币-创新币 Identity int `json:"identity"` // 身份合集信息 SelectIdentity int `json:"select_identity"` // 选中身份信息 } func (this *Enterprise) SetToken(token string) { this.Token = token } func (this *Enterprise) GetToken() string { return this.Token } func (this *Enterprise) GetUID() uint64 { return this.UID } func (this *Enterprise) GetStringUID() string { return fmt.Sprintf("%d", this.UID) } func (this *Enterprise) IsVip() bool { return this.VipStatus && this.VipDeadline.After(time.Now()) } func (this *Enterprise) MarshalBinary() ([]byte, error) { return json.Marshal(this) } func (this *Enterprise) UnmarshalBinary(data []byte) error { return utils.FromJSONBytes(data, this) } func NewEnterprise() *Enterprise { return &Enterprise{} }