diff --git a/cmd/v2/ui/views/friend_randlist.go b/cmd/v2/ui/views/friend_randlist.go new file mode 100644 index 000000000..0a73b0570 --- /dev/null +++ b/cmd/v2/ui/views/friend_randlist.go @@ -0,0 +1,24 @@ +package formview + +import ( + "go_dreamfactory/cmd/v2/model" + "go_dreamfactory/cmd/v2/service" + "go_dreamfactory/pb" + + "fyne.io/fyne/v2" + "github.com/sirupsen/logrus" +) + +type FriendRandListView struct { + BaseformView +} + +func (this *FriendRandListView) CreateView(t *model.TestCase) fyne.CanvasObject { + this.form.OnSubmit = func() { + if err := service.GetPttService().SendToClient(t.MainType, t.SubType, + &pb.FriendOnlineReq{}); err != nil { + logrus.Error(err) + } + } + return this.form +} diff --git a/modules/friend/api.go b/modules/friend/api.go index 5e8135c47..a68d31d00 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -18,6 +18,7 @@ const ( FriendSubTypeZan = "zan" FriendSubTypeZanreceive = "zanreceive" FriendSubTypeZanList = "zanlist" + FriendSubTypeRandList = "randlist" ) type apiComp struct { diff --git a/modules/friend/api_randlist.go b/modules/friend/api_randlist.go index 0a65574cc..8bd9140be 100644 --- a/modules/friend/api_randlist.go +++ b/modules/friend/api_randlist.go @@ -3,6 +3,7 @@ package friend import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/utils" "google.golang.org/protobuf/proto" ) @@ -16,6 +17,11 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendOnlineReq self *pb.DBFriend ) //在线玩家 + cu, err := this.moduleFriend.ModuleUser.UserOnlineList() + if err != nil { + code = pb.ErrorCode_DBError + return + } self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId()) if self == nil { @@ -23,11 +29,35 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendOnlineReq return } - // 好友列表 - // self.FriendIds + var userList []*pb.FriendBase + for _, v := range cu { + if v.Uid == session.GetUserId() { + continue + } + if _, ok := utils.Findx(self.FriendIds, v.Uid); ok { + continue + } + if _, ok := utils.Findx(self.ApplyIds, v.Uid); ok { + continue + } + user := this.moduleFriend.ModuleUser.GetUser(v.Uid) + if user == nil { + continue + } + userList = append(userList, &pb.FriendBase{ + UserId: user.Uid, + NickName: user.Name, + Level: user.Lv, + }) + } - // 已申请的好友 - // self.ApplyIds + rsp := &pb.FriendOnlineResp{ + List: userList, + } + if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeRandList, rsp); err != nil { + code = pb.ErrorCode_SystemError + return + } return }