feat:增加用户资产和会员状态

This commit is contained in:
henry
2021-12-10 11:34:19 +08:00
parent 626f30a2bd
commit 2ee564d540
13 changed files with 188 additions and 31 deletions

View File

@ -15,9 +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
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:"-"`
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:"-"`
AccountStatus
ModelDeleted
ModelAt
@ -33,6 +35,16 @@ const (
UserInstanceSourceForWechat
)
// UserInstanceVip 用户会员状态
type UserInstanceVip int
const (
// UserInstanceVipForNot 不是会员
UserInstanceVipForNot UserInstanceVip = iota
// UserInstanceVipForYes 是会员
UserInstanceVipForYes
)
func (m *UserInstance) TableName() string {
return "user_instance"
}
@ -62,6 +74,10 @@ func (m *UserInstance) SetPasswordAttribute() {
m.Password = utils.HashString([]byte(utils.Md5String(m.Password, m.Salt)))
}
func (m *UserInstance) VipStatus() bool {
return m.IsVip == UserInstanceVipForYes && m.VipDeadline.After(time.Now())
}
func NewUserInstance() *UserInstance {
return &UserInstance{}
}