更新在线好友搜索
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"
|
FriendSubTypeZan = "zan"
|
||||||
FriendSubTypeZanreceive = "zanreceive"
|
FriendSubTypeZanreceive = "zanreceive"
|
||||||
FriendSubTypeZanList = "zanlist"
|
FriendSubTypeZanList = "zanlist"
|
||||||
|
FriendSubTypeRandList = "randlist"
|
||||||
)
|
)
|
||||||
|
|
||||||
type apiComp struct {
|
type apiComp struct {
|
||||||
|
@ -3,6 +3,7 @@ package friend
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -16,6 +17,11 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendOnlineReq
|
|||||||
self *pb.DBFriend
|
self *pb.DBFriend
|
||||||
)
|
)
|
||||||
//在线玩家
|
//在线玩家
|
||||||
|
cu, err := this.moduleFriend.ModuleUser.UserOnlineList()
|
||||||
|
if err != nil {
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
self = this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
|
||||||
if self == nil {
|
if self == nil {
|
||||||
@ -23,11 +29,35 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendOnlineReq
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 好友列表
|
var userList []*pb.FriendBase
|
||||||
// self.FriendIds
|
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,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 已申请的好友
|
rsp := &pb.FriendOnlineResp{
|
||||||
// self.ApplyIds
|
List: userList,
|
||||||
|
}
|
||||||
|
if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeRandList, rsp); err != nil {
|
||||||
|
code = pb.ErrorCode_SystemError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user