更新在线好友搜索
This commit is contained in:
parent
85c0fc0b72
commit
51d0f01383
24
cmd/v2/ui/views/friend_randlist.go
Normal file
24
cmd/v2/ui/views/friend_randlist.go
Normal 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
|
||||
}
|
@ -18,6 +18,7 @@ const (
|
||||
FriendSubTypeZan = "zan"
|
||||
FriendSubTypeZanreceive = "zanreceive"
|
||||
FriendSubTypeZanList = "zanlist"
|
||||
FriendSubTypeRandList = "randlist"
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user