Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
34bc631c9c
@ -63,6 +63,7 @@ var (
|
|||||||
ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack): &formview.FriendDelblackView{},
|
ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack): &formview.FriendDelblackView{},
|
||||||
ff(comm.ModuleFriend, friend.FriendSubTypeSearch): &formview.FriendSearchView{},
|
ff(comm.ModuleFriend, friend.FriendSubTypeSearch): &formview.FriendSearchView{},
|
||||||
ff(comm.ModuleFriend, friend.FriendSubTypeZanList): &formview.FriendZanView{},
|
ff(comm.ModuleFriend, friend.FriendSubTypeZanList): &formview.FriendZanView{},
|
||||||
|
ff(comm.ModuleFriend, friend.FriendSubTypeRandList): &formview.FriendRandListView{},
|
||||||
// shop
|
// shop
|
||||||
ff(comm.ModuleShop, "getlist"): &formview.ShopListView{},
|
ff(comm.ModuleShop, "getlist"): &formview.ShopListView{},
|
||||||
ff(comm.ModuleShop, "buy"): &formview.ShopBuyView{},
|
ff(comm.ModuleShop, "buy"): &formview.ShopBuyView{},
|
||||||
@ -132,6 +133,7 @@ var (
|
|||||||
ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack),
|
ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack),
|
||||||
ff(comm.ModuleFriend, friend.FriendSubTypeSearch),
|
ff(comm.ModuleFriend, friend.FriendSubTypeSearch),
|
||||||
ff(comm.ModuleFriend, friend.FriendSubTypeZanList),
|
ff(comm.ModuleFriend, friend.FriendSubTypeZanList),
|
||||||
|
ff(comm.ModuleFriend, friend.FriendSubTypeRandList),
|
||||||
},
|
},
|
||||||
"shop": {
|
"shop": {
|
||||||
ff(comm.ModuleShop, "getlist"),
|
ff(comm.ModuleShop, "getlist"),
|
||||||
@ -365,6 +367,13 @@ var (
|
|||||||
MainType: string(comm.ModuleFriend),
|
MainType: string(comm.ModuleFriend),
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
|
ff(comm.ModuleFriend, friend.FriendSubTypeRandList): {
|
||||||
|
NavLabel: "在线玩家",
|
||||||
|
Desc: "在线玩家列表",
|
||||||
|
MainType: string(comm.ModuleFriend),
|
||||||
|
SubType: friend.FriendSubTypeRandList,
|
||||||
|
Enabled: true,
|
||||||
|
},
|
||||||
ff(comm.ModuleFriend, friend.FriendSubTypeList): {
|
ff(comm.ModuleFriend, friend.FriendSubTypeList): {
|
||||||
NavLabel: "好友列表",
|
NavLabel: "好友列表",
|
||||||
Desc: "好友列表",
|
Desc: "好友列表",
|
||||||
|
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
|
||||||
|
}
|
@ -20,6 +20,10 @@ const (
|
|||||||
Service_Mainte = "mainte"
|
Service_Mainte = "mainte"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
RDS_SESSION = "online"
|
||||||
|
)
|
||||||
|
|
||||||
//ERR
|
//ERR
|
||||||
const (
|
const (
|
||||||
MainTypeNotify = "notify" //通知
|
MainTypeNotify = "notify" //通知
|
||||||
|
@ -74,6 +74,8 @@ type (
|
|||||||
GetUserExpand(uid string) (result *pb.DBUserExpand, err error)
|
GetUserExpand(uid string) (result *pb.DBUserExpand, err error)
|
||||||
//更新用户expand
|
//更新用户expand
|
||||||
ChangeUserExpand(uid string, value map[string]interface{}) error
|
ChangeUserExpand(uid string, value map[string]interface{}) error
|
||||||
|
// 本服在线玩家列表
|
||||||
|
UserOnlineList() ([]*pb.CacheUser, error)
|
||||||
}
|
}
|
||||||
//武器模块
|
//武器模块
|
||||||
IEquipment interface {
|
IEquipment interface {
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
|||||||
}
|
}
|
||||||
|
|
||||||
//缓存user session
|
//缓存user session
|
||||||
err = this.module.modelSession.AddList("online", user.Uid, map[string]interface{}{
|
err = this.module.modelSession.AddList(comm.RDS_SESSION, user.Uid, map[string]interface{}{
|
||||||
"uid": user.Uid,
|
"uid": user.Uid,
|
||||||
"sessionId": session.GetSessionId(),
|
"sessionId": session.GetSessionId(),
|
||||||
"serviceTag": session.GetServiecTag(),
|
"serviceTag": session.GetServiecTag(),
|
||||||
|
@ -3,6 +3,7 @@ package user
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
@ -20,18 +21,11 @@ func (this *ModelSession) Init(service core.IService, module core.IModule, comp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取用户
|
//获取用户
|
||||||
func (this *ModelSession) getUserSession(uid string) (cuser *pb.CacheUser) {
|
func (this *ModelSession) getUserSession(uid string) (user *pb.CacheUser) {
|
||||||
var sl []*pb.CacheUser
|
user = &pb.CacheUser{}
|
||||||
|
if err := this.GetListObj(comm.RDS_SESSION, uid, user); err != nil {
|
||||||
if err := this.GetList("online", sl); err != nil {
|
log.Errorf("getUserSession err:%v", err)
|
||||||
this.module.Errorf("GetUserSession err:%v", err)
|
return nil
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return user
|
||||||
for _, v := range sl {
|
|
||||||
if v.Uid == uid {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,12 @@ func (this *User) CleanSession(session comm.IUserSession) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 在线玩家列表
|
// 在线玩家列表
|
||||||
func (this *User) UserOnline() {
|
func (this *User) UserOnlineList() ([]*pb.CacheUser, error) {
|
||||||
|
var cache []*pb.CacheUser
|
||||||
|
if err := this.modelSession.GetList(comm.RDS_SESSION, &cache); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return cache, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询用户属性值 例如 金币 经验
|
//查询用户属性值 例如 金币 经验
|
||||||
|
Loading…
Reference in New Issue
Block a user