feat:优化信息
This commit is contained in:
@ -20,7 +20,8 @@ type (
|
||||
InstanceLoginParams struct {
|
||||
UID uint64
|
||||
Avatar, Name, Mobile string
|
||||
Vip bool
|
||||
Vip model.UserInstanceVipKind
|
||||
VipStatus bool
|
||||
VipDeadline time.Time
|
||||
Currency float64
|
||||
Identity, SelectIdentity int
|
||||
@ -43,7 +44,8 @@ func (c *Instance) Login() InstanceLoginCallback {
|
||||
_session.Avatar = params.Avatar
|
||||
_session.Name = params.Name
|
||||
_session.Mobile = params.Mobile
|
||||
_session.Vip = params.Vip
|
||||
_session.Vip = int(params.Vip)
|
||||
_session.VipStatus = params.VipStatus
|
||||
_session.VipDeadline = params.VipDeadline
|
||||
_session.Currency = params.Currency
|
||||
_session.Identity = params.Identity
|
||||
|
@ -100,8 +100,8 @@ RETURNS:
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SettingInfo.Domain), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Vip: mUserInstance.VipStatus(), VipDeadline: mUserInstance.VipDeadline, Currency: mUserAssets.Currency,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Vip: mUserInstance.Vip, VipStatus: mUserInstance.VipStatus(), VipDeadline: mUserInstance.VipDeadline,
|
||||
Currency: mUserAssets.Currency, Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
}
|
||||
@ -140,8 +140,8 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
|
||||
return &InstanceLoginParams{
|
||||
UID: mUserInstance.UUID,
|
||||
Avatar: mUserInstance.GetAvatarAttribute(config.SettingInfo.Domain), Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||
Vip: mUserInstance.VipStatus(), VipDeadline: mUserInstance.VipDeadline, Currency: mUserAssets.Currency,
|
||||
Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Vip: mUserInstance.Vip, VipStatus: mUserInstance.VipStatus(), VipDeadline: mUserInstance.VipDeadline,
|
||||
Currency: mUserAssets.Currency, Identity: mUserInstance.Identity, SelectIdentity: mUserIdentity.Identity,
|
||||
Status: mUserInstance.Status,
|
||||
}, nil
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ type (
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Name string `json:"name"` // 名称
|
||||
Currency float64 `json:"currency"` // 创新币
|
||||
Vip bool `json:"vip"` // Vip状态
|
||||
Vip int `json:"vip"` // Vip
|
||||
VipDays int `json:"vip_days"` // Vip剩余天数
|
||||
Identity int `json:"identity"` // 具体身份
|
||||
SelectIdentity int `json:"select_identity"` // 最后一次选中的身份信息
|
||||
@ -38,11 +38,11 @@ type (
|
||||
func (c *Instance) Info() *InstanceInfo {
|
||||
out := &InstanceInfo{Avatar: c.Avatar, Name: c.Name,
|
||||
Currency: c.Currency,
|
||||
Vip: c.VipStatus(),
|
||||
Identity: c.Identity,
|
||||
SelectIdentity: c.SelectIdentity}
|
||||
|
||||
if out.Vip {
|
||||
if c.IsVip() {
|
||||
out.Vip = c.Vip
|
||||
out.VipDays = utils.DiffTimeDays(time.Now(), c.VipDeadline)
|
||||
}
|
||||
return out
|
||||
|
@ -15,11 +15,11 @@ type UserInstance struct {
|
||||
Name string `gorm:"column:name;type:varchar(20);default:'';comment:真实姓名" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;index:idx_user_instance_mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"`
|
||||
Gender
|
||||
IsVip UserInstanceVip `gorm:"column:is_vip;type:tinyint(1);default:0;comment:是否会员" json:"is_vip"`
|
||||
VipDeadline time.Time `gorm:"column:vip_deadline;type:datetime;default:null;comment:会员过期时间" json:"vip_deadline"`
|
||||
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
||||
Password string `gorm:"column:password;type:varchar(100);default:'';comment:密码" json:"-"`
|
||||
Salt string `gorm:"column:salt;type:varchar(10);default:'';comment:盐值" json:"-"`
|
||||
Vip UserInstanceVipKind `gorm:"column:vip;type:tinyint(1);default:0;comment:会员状态/类型" json:"vip"`
|
||||
VipDeadline time.Time `gorm:"column:vip_deadline;type:datetime;default:null;comment:会员过期时间" json:"vip_deadline"`
|
||||
Identity int `gorm:"column:identity;type:int(8);default:0;comment:身份信息" json:"-"`
|
||||
Password string `gorm:"column:password;type:varchar(100);default:'';comment:密码" json:"-"`
|
||||
Salt string `gorm:"column:salt;type:varchar(10);default:'';comment:盐值" json:"-"`
|
||||
AccountStatus
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
@ -35,14 +35,14 @@ const (
|
||||
UserInstanceSourceForWechat
|
||||
)
|
||||
|
||||
// UserInstanceVip 用户会员状态
|
||||
type UserInstanceVip int
|
||||
// UserInstanceVipKind 用户会员类型
|
||||
type UserInstanceVipKind int
|
||||
|
||||
const (
|
||||
// UserInstanceVipForNot 不是会员
|
||||
UserInstanceVipForNot UserInstanceVip = iota
|
||||
// UserInstanceVipForYes 是会员
|
||||
UserInstanceVipForYes
|
||||
// UserInstanceVipForOrdinary 普通VIP
|
||||
UserInstanceVipForOrdinary UserInstanceVipKind = iota + 1
|
||||
// UserInstanceVipForSenior 高级VIP
|
||||
UserInstanceVipForSenior
|
||||
)
|
||||
|
||||
func (m *UserInstance) TableName() string {
|
||||
@ -75,7 +75,7 @@ func (m *UserInstance) SetPasswordAttribute() {
|
||||
}
|
||||
|
||||
func (m *UserInstance) VipStatus() bool {
|
||||
return m.IsVip == UserInstanceVipForYes && m.VipDeadline.After(time.Now())
|
||||
return m.Vip != 0 && m.VipDeadline.After(time.Now())
|
||||
}
|
||||
|
||||
func NewUserInstance() *UserInstance {
|
||||
|
@ -14,7 +14,8 @@ type Enterprise struct {
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Name string `json:"name"` // 名称
|
||||
Mobile string `json:"mobile"` // 手机号码
|
||||
Vip bool `json:"vip"` // VIP状态
|
||||
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"` // 总身份信息
|
||||
@ -33,8 +34,8 @@ func (this *Enterprise) UIDToString() string {
|
||||
return utils.UintToString(this.UID)
|
||||
}
|
||||
|
||||
func (this *Enterprise) VipStatus() bool {
|
||||
return this.Vip && this.VipDeadline.After(time.Now())
|
||||
func (this *Enterprise) IsVip() bool {
|
||||
return this.VipStatus && this.VipDeadline.After(time.Now())
|
||||
}
|
||||
|
||||
func (this *Enterprise) MarshalBinary() ([]byte, error) {
|
||||
|
Reference in New Issue
Block a user