用户会话接口
This commit is contained in:
parent
30dadce861
commit
b5b3b11691
@ -51,7 +51,10 @@ type (
|
||||
|
||||
//玩家
|
||||
IUser interface {
|
||||
//获取用户数据
|
||||
GetUser(uid string) *pb.DBUser
|
||||
//获取用户回话
|
||||
GetUserSession(uid string) *pb.CacheUser
|
||||
//查询用户属性值 例如 金币 经验
|
||||
QueryAttributeValue(uid string, attr string) (value int32)
|
||||
//添加/减少属性值
|
||||
|
@ -2,7 +2,9 @@ package user
|
||||
|
||||
import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
type ModelSession struct {
|
||||
@ -14,3 +16,13 @@ func (this *ModelSession) Init(service core.IService, module core.IModule, comp
|
||||
this.TableName = "session"
|
||||
return
|
||||
}
|
||||
|
||||
//获取用户
|
||||
func (this *ModelSession) getUserSession(uid string) *pb.CacheUser {
|
||||
cacheUser := &pb.CacheUser{}
|
||||
if err := this.Get(uid, cacheUser); err != nil {
|
||||
log.Errorf("GetUserSession err:%v", err)
|
||||
return nil
|
||||
}
|
||||
return cacheUser
|
||||
}
|
||||
|
@ -36,14 +36,19 @@ func (this *User) OnInstallComp() {
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser)
|
||||
this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession)
|
||||
|
||||
|
||||
}
|
||||
|
||||
//获取英雄列表
|
||||
//获取用户数据
|
||||
func (this *User) GetUser(uid string) *pb.DBUser {
|
||||
return this.modelUser.GetUser(uid)
|
||||
}
|
||||
|
||||
//获取用户会话
|
||||
func (this *User) GetUserSession(uid string) *pb.CacheUser {
|
||||
return this.modelSession.getUserSession(uid)
|
||||
}
|
||||
|
||||
//查询用户属性值 例如 金币 经验
|
||||
func (this *User) QueryAttributeValue(uid string, attr string) (value int32) {
|
||||
user := this.modelUser.GetUser(uid)
|
||||
|
Loading…
Reference in New Issue
Block a user