改造获取玩家数据的方法

This commit is contained in:
wh_zcy 2022-11-24 16:35:44 +08:00
parent 85c174a498
commit c28ae84698
17 changed files with 125 additions and 121 deletions

View File

@ -575,3 +575,46 @@ const (
Yueka_1 string = "Activity_PrivilegeCardDailyReward_lv1" Yueka_1 string = "Activity_PrivilegeCardDailyReward_lv1"
Yueka_2 string = "Activity_PrivilegeCardDailyReward_lv2" Yueka_2 string = "Activity_PrivilegeCardDailyReward_lv2"
) )
// open funcName
const (
Hero = "hero"
Backpack = "backpack"
Shop = "shop"
Friend = "friend"
Mall = "mall"
Rdtask = "rdtask"
Currency = "currency"
Alliance = "alliance"
Task = "task"
Trials = "trials"
Moon = "moon"
Story = "story"
Kungfu = "kungfu"
Event = "event"
MistyIsland = "mistyIsland"
Vikingexpedition = "vikingexpedition"
Vikingexpedition2 = "vikingexpedition2"
Vikingexpedition3 = "vikingexpedition3"
HjeartDemonTower = "hjeart demon tower"
Catchsheep = "catchsheep"
Darkcuisine = "darkcuisine"
UndergroundArena = "underground Arena"
Crazycompetition = "crazycompetition"
Fiveheroeschallenge = "fiveheroeschallenge"
Library = "library"
Bonfiredance = "bonfiredance"
Caravan = "caravan"
Gourmetrestaurant = "gourmetrestaurant"
Goberblacksmithshop = "goberblacksmithshop"
Hunting = "hunting"
Channel_lock_icon = "channel_lock_icon"
Channel_lock_world = "channel_lock_world"
Channel_lock_guild = "channel_lock_guild"
Channel_lock_private = "channel_lock_private"
Channel_lock_public = "channel_lock_public"
Channel_lock_system = "channel_lock_system"
Guild = "guild"
Arena = "arena"
Sign = "sign"
)

View File

@ -16,7 +16,7 @@ type (
type ( type (
ISys interface { ISys interface {
IsAccess(funcName string, userLv int32) bool IsAccess(funcName string, uid string) bool
} }
//邮件业务模块对外接口定义 提供给其他模块使用的 //邮件业务模块对外接口定义 提供给其他模块使用的
@ -90,8 +90,6 @@ type (
IUser interface { IUser interface {
//获取本服用户数据 //获取本服用户数据
GetUser(uid string) *pb.DBUser GetUser(uid string) *pb.DBUser
// 获取跨服用户数据
GetCrossUser(uid string) (*pb.DBUser, error)
//获取用户回话 //获取用户回话
GetUserSession(uid string) *pb.CacheUser GetUserSession(uid string) *pb.CacheUser
//查询用户属性值 例如 金币 经验 //查询用户属性值 例如 金币 经验
@ -114,14 +112,9 @@ type (
CrossUserSession(uid string) *pb.CacheUser CrossUserSession(uid string) *pb.CacheUser
// 跨服搜索玩家 // 跨服搜索玩家
CrossSearchUser(nickname string) ([]*pb.DBUser, error) CrossSearchUser(nickname string) ([]*pb.DBUser, error)
// 获取远程用户
GetRemoteUser(uid string) (*pb.DBUser, error)
// 搜索远程用户 // 搜索远程用户
SearchRmoteUser(nickname string) ([]*pb.DBUser, error) SearchRmoteUser(nickname string) ([]*pb.DBUser, error)
// 获取远程用户expand
GetRemoteUserExpand(uid string) (result *pb.DBUserExpand, err error)
// 更新远程用户expand
ChangeRemoteUserExpand(uid string, value map[string]interface{}) error
} }
//武器模块 //武器模块
IEquipment interface { IEquipment interface {

View File

@ -2,7 +2,6 @@ package friend
import ( import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
@ -41,19 +40,15 @@ func (this *apiComp) Init(service core.IService, module core.IModule, comp core.
} }
func (this *apiComp) setDefaultFriendUserBaseInfo(userId string) *pb.FriendBase { func (this *apiComp) setDefaultFriendUserBaseInfo(userId string) *pb.FriendBase {
if user, err := this.moduleFriend.ModuleUser.GetRemoteUser(userId); err != nil { user := this.moduleFriend.ModuleUser.GetUser(userId)
this.moduleFriend.Error("GetRmoteUser", log.Fields{"err": err.Error()}) if user != nil {
return nil return &pb.FriendBase{
} else { ServerId: user.Sid,
if user != nil { UserId: userId,
return &pb.FriendBase{ NickName: user.Name,
ServerId: user.Sid, Level: user.Lv,
UserId: userId, Avatar: user.Avatar,
NickName: user.Name, OfflineTime: user.Offlinetime,
Level: user.Lv,
Avatar: user.Avatar,
OfflineTime: user.Offlinetime,
}
} }
} }

View File

@ -42,11 +42,8 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.FriendAgreeReq) (c
agreeIds := []string{} agreeIds := []string{}
for _, friendId := range req.FriendIds { for _, friendId := range req.FriendIds {
// 验证friendId是否有效 // 验证friendId是否有效
user, err := this.moduleFriend.ModuleUser.GetRemoteUser(friendId) user := this.moduleFriend.ModuleUser.GetUser(friendId)
if err != nil { if user == nil {
continue
}
if user.Uid == "" {
continue continue
} }
if _, ok := utils.Find(self.FriendIds, friendId); !ok { if _, ok := utils.Find(self.FriendIds, friendId); !ok {

View File

@ -85,7 +85,7 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.GourmetGetRa
} }
} }
for k := range mapUser { for k := range mapUser {
if user, err := this.module.ModuleUser.GetRemoteUser(k); err == nil && user.Uid != "" { if user := this.module.ModuleUser.GetUser(k); user != nil {
szDbUser = append(szDbUser, user) // 转成user对象 szDbUser = append(szDbUser, user) // 转成user对象
} else { } else {
this.module.Errorf("%v", err) this.module.Errorf("%v", err)

View File

@ -85,7 +85,7 @@ func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.SmithyGetRan
} }
} }
for k := range mapUser { for k := range mapUser {
if user, err := this.module.ModuleUser.GetRemoteUser(k); err == nil && user.Uid != "" { if user := this.module.ModuleUser.GetUser(k); user != nil {
szDbUser = append(szDbUser, user) // 转成user对象 szDbUser = append(szDbUser, user) // 转成user对象
} else { } else {
this.module.Errorf("%v", err) this.module.Errorf("%v", err)

View File

@ -35,7 +35,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
} }
// userex // userex
userEx, err := this.module.ModuleUser.GetRemoteUserExpand(uid) userEx, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil { if err != nil {
this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err.Error()}) this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err.Error()})
code = pb.ErrorCode_UserSessionNobeing code = pb.ErrorCode_UserSessionNobeing
@ -53,12 +53,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (
return return
} }
user, err := this.module.ModuleUser.GetRemoteUser(uid) user := this.module.ModuleUser.GetUser(uid)
if err != nil {
code = pb.ErrorCode_DBError
return
}
if user == nil { if user == nil {
code = pb.ErrorCode_UserSessionNobeing code = pb.ErrorCode_UserSessionNobeing
return return

View File

@ -29,20 +29,14 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
} }
uid := session.GetUserId() uid := session.GetUserId()
user := this.module.ModuleUser.GetUser(uid)
user, err := this.module.ModuleUser.GetRemoteUser(uid) if user == nil{
if err != nil {
code = pb.ErrorCode_DBError
return
}
if user.Uid == "" {
this.module.Error("GetRmoteUser not found", log.Fields{"uid": uid}) this.module.Error("GetRmoteUser not found", log.Fields{"uid": uid})
code = pb.ErrorCode_UserSessionNobeing code = pb.ErrorCode_UserSessionNobeing
return return
} }
userExpand, err := this.module.ModuleUser.GetRemoteUserExpand(uid) userExpand, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return
@ -111,7 +105,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
"sociatyId": sociaty.Id, "sociatyId": sociaty.Id,
} }
if err = this.module.ModuleUser.ChangeRemoteUserExpand(user.Uid, update); err != nil { if err = this.module.ModuleUser.ChangeUserExpand(user.Uid, update); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()}) this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
return return

View File

@ -62,7 +62,7 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar
"sociatyId": "", //公会ID置空 "sociatyId": "", //公会ID置空
} }
if err := this.module.ModuleUser.ChangeRemoteUserExpand(req.TargetId, update); err != nil { if err := this.module.ModuleUser.ChangeUserExpand(req.TargetId, update); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "被踢人": req.TargetId, "err": err.Error()}) this.module.Error("更新玩家公会ID", log.Fields{"uid": uid, "被踢人": req.TargetId, "err": err.Error()})
return return

View File

@ -18,6 +18,7 @@ func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.SociatyListReq
} }
func (this *apiComp) List(session comm.IUserSession, req *pb.SociatyListReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) List(session comm.IUserSession, req *pb.SociatyListReq) (code pb.ErrorCode, data proto.Message) {
// this.module.ModuleSys.IsAccess(comm.Guild, userLv int32)
if code = this.ListCheck(session, req); code != pb.ErrorCode_Success { if code = this.ListCheck(session, req); code != pb.ErrorCode_Success {
return return
} }

View File

@ -17,7 +17,7 @@ func (this *apiComp) MineCheck(session comm.IUserSession, req *pb.SociatyMineReq
func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (code pb.ErrorCode, data proto.Message) {
uid := session.GetUserId() uid := session.GetUserId()
userEx, err := this.module.ModuleUser.GetRemoteUserExpand(uid) userEx, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil { if err != nil {
this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err}) this.module.Error("GetRemoteUserExpand", log.Fields{"uid": uid, "err": err})
code = pb.ErrorCode_UserSessionNobeing code = pb.ErrorCode_UserSessionNobeing

View File

@ -44,7 +44,7 @@ func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (co
"sociatyCd": utils.AddHour(int(this.module.globalConf.GuildRejoinCd)).Unix(), "sociatyCd": utils.AddHour(int(this.module.globalConf.GuildRejoinCd)).Unix(),
} }
if err := this.module.ModuleUser.ChangeRemoteUserExpand(uid, update); err != nil { if err := this.module.ModuleUser.ChangeUserExpand(uid, update); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Error("退出公会,更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()}) this.module.Error("退出公会,更新玩家公会ID", log.Fields{"uid": uid, "sociatyId": sociaty.Id, "err": err.Error()})
return return

View File

@ -90,10 +90,10 @@ func (this *ModelSociaty) isNameExist(name string) error {
// 公会列表 // 公会列表
func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []*pb.DBSociaty) { func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []*pb.DBSociaty) {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(uid) user := this.moduleSociaty.ModuleUser.GetUser(uid)
if err != nil { // if err != nil {
return // return
} // }
if user == nil { if user == nil {
return return
} }
@ -196,7 +196,7 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
err error err error
) )
if this.moduleSociaty.IsCross() { if this.moduleSociaty.IsCross() {
userEx, err = this.moduleSociaty.ModuleUser.GetRemoteUserExpand(uid) userEx, err = this.moduleSociaty.ModuleUser.GetUserExpand(uid)
if err != nil { if err != nil {
return return
} }
@ -232,7 +232,7 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
} }
// 申请公会 // 申请公会
func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool,err error) { func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool, err error) {
// 判断公会审批设置 // 判断公会审批设置
if sociaty.IsApplyCheck { //需要审核 if sociaty.IsApplyCheck { //需要审核
isCheck = true isCheck = true
@ -246,12 +246,12 @@ func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) (isCheck bool
err = this.updateSociaty(sociaty.Id, update) err = this.updateSociaty(sociaty.Id, update)
} else { //无需审核直接入会 } else { //无需审核直接入会
if err := this.addMember(uid, sociaty); err != nil { if err := this.addMember(uid, sociaty); err != nil {
return isCheck,err return isCheck, err
} }
//初始玩家公会任务 //初始玩家公会任务
this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id) this.moduleSociaty.modelSociatyTask.initSociatyTask(uid, sociaty.Id)
} }
return return
} }
// 设置公会 // 设置公会
@ -283,8 +283,8 @@ func (this *ModelSociaty) isApplied(uid string, sociaty *pb.DBSociaty) bool {
// 申请列表 // 申请列表
func (this *ModelSociaty) applyList(sociaty *pb.DBSociaty) (list []*pb.SociatyMemberInfo) { func (this *ModelSociaty) applyList(sociaty *pb.DBSociaty) (list []*pb.SociatyMemberInfo) {
for _, r := range sociaty.ApplyRecord { for _, r := range sociaty.ApplyRecord {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(r.Uid) user := this.moduleSociaty.ModuleUser.GetUser(r.Uid)
if err != nil || user.Uid == "" { if user == nil {
continue continue
} }
@ -399,7 +399,7 @@ func (this *ModelSociaty) addMember(uid string, sociaty *pb.DBSociaty) error {
updateEx := map[string]interface{}{ updateEx := map[string]interface{}{
"sociatyId": sociaty.Id, "sociatyId": sociaty.Id,
} }
if err := this.moduleSociaty.ModuleUser.ChangeRemoteUserExpand(uid, updateEx); err != nil { if err := this.moduleSociaty.ModuleUser.ChangeUserExpand(uid, updateEx); err != nil {
return err return err
} }
@ -424,8 +424,8 @@ func (this *ModelSociaty) sendMail(confId string, params []string, receiver []st
// 成员列表 // 成员列表
func (this *ModelSociaty) members(sociaty *pb.DBSociaty) (list []*pb.SociatyMemberInfo) { func (this *ModelSociaty) members(sociaty *pb.DBSociaty) (list []*pb.SociatyMemberInfo) {
for _, m := range sociaty.Members { for _, m := range sociaty.Members {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(m.Uid) user := this.moduleSociaty.ModuleUser.GetUser(m.Uid)
if err != nil || user.Uid == "" { if user == nil {
continue continue
} }
list = append(list, &pb.SociatyMemberInfo{ list = append(list, &pb.SociatyMemberInfo{
@ -534,8 +534,8 @@ func (this *ModelSociaty) settingJob(targetId string, job pb.SociatyJob, sociaty
func (this *ModelSociaty) getMasterInfo(sociaty *pb.DBSociaty) *pb.SociatyMemberInfo { func (this *ModelSociaty) getMasterInfo(sociaty *pb.DBSociaty) *pb.SociatyMemberInfo {
for _, m := range sociaty.Members { for _, m := range sociaty.Members {
if m.Job == pb.SociatyJob_PRESIDENT { if m.Job == pb.SociatyJob_PRESIDENT {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(m.Uid) user := this.moduleSociaty.ModuleUser.GetUser(m.Uid)
if err != nil || user.Uid == "" { if user == nil {
continue continue
} }
return &pb.SociatyMemberInfo{ return &pb.SociatyMemberInfo{
@ -557,9 +557,9 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error {
return comm.NewCustomError(pb.ErrorCode_SociatyNoMaster) return comm.NewCustomError(pb.ErrorCode_SociatyNoMaster)
} }
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(master.Uid) user := this.moduleSociaty.ModuleUser.GetUser(master.Uid)
if err != nil { if user == nil {
return err return comm.NewCustomError(pb.ErrorCode_UserSessionNobeing)
} }
globalCnf := this.moduleSociaty.globalConf globalCnf := this.moduleSociaty.globalConf
@ -913,7 +913,7 @@ func (this *ModelSociaty) memberClear(sociaty *pb.DBSociaty) error {
update := map[string]interface{}{ update := map[string]interface{}{
"sociatyId": "", //公会ID置空 "sociatyId": "", //公会ID置空
} }
if err := this.moduleSociaty.ModuleUser.ChangeRemoteUserExpand(m.Uid, update); err != nil { if err := this.moduleSociaty.ModuleUser.ChangeUserExpand(m.Uid, update); err != nil {
log.Errorf("更新玩家公会ID err:%v", err) log.Errorf("更新玩家公会ID err:%v", err)
} }

View File

@ -40,8 +40,8 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string)
return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) return comm.NewCustomError(pb.ErrorCode_SociatyLogParams)
} }
for i := 0; i < len(params); i++ { for i := 0; i < len(params); i++ {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(params[i]) user := this.moduleSociaty.ModuleUser.GetUser(params[i])
if err == nil && user.Uid != "" { if user != nil {
content = strings.Replace(content, "%s", user.Name, 1) content = strings.Replace(content, "%s", user.Name, 1)
} }
} }
@ -52,8 +52,8 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string)
return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) return comm.NewCustomError(pb.ErrorCode_SociatyLogParams)
} }
for i := 0; i < len(params); i++ { for i := 0; i < len(params); i++ {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(params[i]) user := this.moduleSociaty.ModuleUser.GetUser(params[i])
if err == nil && user.Uid != "" { if user != nil {
content = strings.Replace(content, "%s", user.Name, 1) content = strings.Replace(content, "%s", user.Name, 1)
} }
} }
@ -78,8 +78,8 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string)
} }
content = strings.Replace(content, "%s", job, 1) content = strings.Replace(content, "%s", job, 1)
} else { } else {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(params[i]) user := this.moduleSociaty.ModuleUser.GetUser(params[i])
if err == nil && user.Uid != "" { if user != nil {
content = strings.Replace(content, "%s", user.Name, 1) content = strings.Replace(content, "%s", user.Name, 1)
} }
} }
@ -91,8 +91,8 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string)
return comm.NewCustomError(pb.ErrorCode_SociatyLogParams) return comm.NewCustomError(pb.ErrorCode_SociatyLogParams)
} }
for i := 0; i < len(params); i++ { for i := 0; i < len(params); i++ {
user, err := this.moduleSociaty.ModuleUser.GetRemoteUser(params[i]) user := this.moduleSociaty.ModuleUser.GetUser(params[i])
if err == nil && user.Uid != "" { if user != nil {
content = strings.Replace(content, "%s", params[i], 1) content = strings.Replace(content, "%s", params[i], 1)
} }
} }

View File

@ -21,10 +21,14 @@ func (this *ModelSys) Init(service core.IService, module core.IModule, comp core
} }
// 是否允许访问功能,条件:玩家等级 // 是否允许访问功能,条件:玩家等级
func (this *ModelSys) IsAccess(funName string, userLv int32) bool { func (this *ModelSys) IsAccess(funName string, uid string) bool {
conf := this.moduleSys.configure.getFuncCfg(funName) user := this.moduleSys.ModuleUser.GetUser(uid)
if conf != nil { if user != nil {
return userLv >= conf.Main conf := this.moduleSys.configure.getFuncCfg(funName)
if conf != nil {
return user.Lv >= conf.Main
}
} }
return false return false
} }

View File

@ -31,6 +31,6 @@ func (this *ModuleSys) GetType() core.M_Modules {
return comm.ModuleSys return comm.ModuleSys
} }
func (this *ModuleSys) IsAccess(funcName string, userLv int32) bool { func (this *ModuleSys) IsAccess(funcName string, userId string) bool {
return this.modelSys.IsAccess(funcName, userLv) return this.modelSys.IsAccess(funcName, userId)
} }

View File

@ -92,8 +92,17 @@ func (this *User) OnInstallComp() {
} }
//获取用户数据 //获取用户数据
func (this *User) GetUser(uid string) *pb.DBUser { func (this *User) GetUser(uid string) (user *pb.DBUser) {
user := this.modelUser.GetUser(uid) var err error
if this.IsCross() {
user, err = this.getRemoteUser(uid)
if err != nil {
return nil
}
} else {
user = this.modelUser.GetUser(uid)
}
if user.Id == "" { if user.Id == "" {
return nil return nil
} }
@ -108,8 +117,8 @@ func (this *User) GetCrossUser(uid string) (*pb.DBUser, error) {
return reply, err return reply, err
} }
// 获取远程用户数据sss // 获取远程用户数据
func (this *User) GetRemoteUser(uid string) (*pb.DBUser, error) { func (this *User) getRemoteUser(uid string) (*pb.DBUser, error) {
reply := &pb.DBUser{} reply := &pb.DBUser{}
if err := this.getUserFromRemoteDb(uid, reply); err != nil { if err := this.getUserFromRemoteDb(uid, reply); err != nil {
return nil, err return nil, err
@ -117,20 +126,6 @@ func (this *User) GetRemoteUser(uid string) (*pb.DBUser, error) {
return reply, nil return reply, nil
} }
// 获取远程用户expand
func (this *User) GetRemoteUserExpand(uid string) (result *pb.DBUserExpand, err error) {
reply := &pb.DBUserExpand{}
if err := this.getUserExpandFromRemoteDb(uid, reply); err != nil {
return nil, err
}
return reply, nil
}
// 更新远程用户expand
func (this *User) ChangeRemoteUserExpand(uid string, value map[string]interface{}) error {
return this.changeUserExpandFromRemoteDb(uid, value)
}
//获取用户会话 //获取用户会话
func (this *User) GetUserSession(uid string) *pb.CacheUser { func (this *User) GetUserSession(uid string) *pb.CacheUser {
return this.modelSession.getUserSession(uid) return this.modelSession.getUserSession(uid)
@ -212,7 +207,7 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int64) {
err error err error
) )
if this.IsCross() { if this.IsCross() {
user, err = this.GetRemoteUser(uid) user, err = this.getRemoteUser(uid)
if err != nil { if err != nil {
return return
} }
@ -251,25 +246,12 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
userEx *pb.DBUserExpand userEx *pb.DBUserExpand
err error err error
) )
if this.IsCross() {
user, err = this.GetRemoteUser(uid) user = this.GetUser(uid)
if err != nil { userEx, err = this.GetUserExpand(uid)
code = pb.ErrorCode_UserSessionNobeing if err != nil {
return code = pb.ErrorCode_UserExpandNull
} return
userEx, err = this.GetRemoteUserExpand(uid)
if err != nil {
code = pb.ErrorCode_UserExpandNull
return
}
} else {
user = this.GetUser(uid)
userEx, err = this.GetUserExpand(uid)
if err != nil {
code = pb.ErrorCode_UserExpandNull
return
}
} }
if user == nil { if user == nil {