好友搜索

This commit is contained in:
wh_zcy 2022-08-18 09:28:37 +08:00
parent 4bb8715e7f
commit 6c258e903b
6 changed files with 51 additions and 3 deletions

View File

@ -45,6 +45,8 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.FriendApplyLis
list = append(list, &pb.FriendBase{
UserId: userId,
NickName: user.Name,
Level: user.Lv,
Avatar: user.Avatar,
})
}

View File

@ -44,6 +44,8 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (cod
list = append(list, &pb.FriendBase{
UserId: userId,
NickName: user.Name,
Level: user.Lv,
Avatar: user.Avatar,
})
}

View File

@ -0,0 +1,33 @@
package friend
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
func (this *apiComp) RandlistCheck(session comm.IUserSession, req *pb.FriendOnlineReq) (code pb.ErrorCode) {
return
}
func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendOnlineReq) (code pb.ErrorCode, data proto.Message) {
var (
self *pb.DBFriend
)
//在线玩家
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
if self == nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
// 好友列表
// self.FriendIds
// 已申请的好友
// self.ApplyIds
return
}

View File

@ -80,7 +80,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
}
//缓存user session
err = this.module.modelSession.Change(user.Uid, map[string]interface{}{
err = this.module.modelSession.ChangeList("online", user.Uid, map[string]interface{}{
"uid": user.Uid,
"sessionId": session.GetSessionId(),
"serviceTag": session.GetServiecTag(),

View File

@ -21,10 +21,17 @@ func (this *ModelSession) Init(service core.IService, module core.IModule, comp
//获取用户
func (this *ModelSession) getUserSession(uid string) (cuser *pb.CacheUser) {
cuser = &pb.CacheUser{}
if err := this.Get(uid, cuser); err != nil {
var sl []*pb.CacheUser
if err := this.GetList("online", sl); err != nil {
this.module.Errorf("GetUserSession err:%v", err)
return
}
for _, v := range sl {
if v.Uid == uid {
return v
}
}
return
}

View File

@ -75,6 +75,10 @@ func (this *User) CleanSession(session comm.IUserSession) {
this.modelSetting.Del(session.GetUserId(), db.SetDBMgoLog(false))
}
// 在线玩家列表
func (this *User) UserOnline() {
}
//查询用户属性值 例如 金币 经验
func (this *User) QueryAttributeValue(uid string, attr string) (value int32) {
user := this.modelUser.GetUser(uid)