更新在线好友搜索

This commit is contained in:
wh_zcy 2022-08-18 11:30:38 +08:00
parent 85c0fc0b72
commit 51d0f01383
3 changed files with 59 additions and 4 deletions

View File

@ -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
}

View File

@ -18,6 +18,7 @@ const (
FriendSubTypeZan = "zan"
FriendSubTypeZanreceive = "zanreceive"
FriendSubTypeZanList = "zanlist"
FriendSubTypeRandList = "randlist"
)
type apiComp struct {

View File

@ -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
}