54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package pagoda
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/redis"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
type ModelRank struct {
|
|
modules.MCompModel
|
|
moduleUser *Pagoda
|
|
}
|
|
|
|
func (this *ModelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.TableName = comm.TablePagodaRank
|
|
err = this.MCompModel.Init(service, module, comp, options)
|
|
this.moduleUser = module.(*Pagoda)
|
|
return
|
|
}
|
|
|
|
func (this *ModelRank) AddRank(uId string, data *pb.DBPagodaRank) (err error) {
|
|
if err = this.Add(uId, data); err != nil {
|
|
//this.Errorf("err:%v", err)
|
|
return
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//获取用户通过扩展表
|
|
func (this *ModelRank) GetUserRandData(uid string) (result *pb.DBPagodaRank, err error) {
|
|
result = &pb.DBPagodaRank{}
|
|
if err = this.Get(uid, result); err != nil && redis.RedisNil != err {
|
|
return
|
|
}
|
|
err = nil
|
|
return result, err
|
|
}
|
|
|
|
func (this *ModelRank) ChangeUserRank(uid string, value map[string]interface{}) (err error) {
|
|
if len(value) == 0 {
|
|
return nil
|
|
}
|
|
return this.Change(uid, value)
|
|
}
|
|
|
|
func (this *ModelRank) GetRankData() (data []*pb.DBPagodaRank, err error) {
|
|
data = make([]*pb.DBPagodaRank, 0)
|
|
err = this.Redis.LRange(comm.TablePagodaRank, 0, -1, &data)
|
|
|
|
return
|
|
}
|