From 1c556e3e21960b5054056dc589508b4a6e6e8486 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 21 Oct 2022 11:15:41 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E5=8A=A9=E6=88=98?= =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/protocol.go | 17 ++- cmd/v2/ui/views/friend_assistherolist.go | 38 +++++ modules/friend/api.go | 1 + modules/friend/api_cross_assisthero.go | 23 +-- modules/friend/api_cross_assistherolist.go | 39 ++++++ modules/friend/module.go | 24 +++- modules/linestory/api_dotask.go | 2 +- pb/friend_db.pb.go | 20 ++- pb/friend_msg.pb.go | 155 ++++++++++++++++++--- 9 files changed, 277 insertions(+), 42 deletions(-) create mode 100644 cmd/v2/ui/views/friend_assistherolist.go create mode 100644 modules/friend/api_cross_assistherolist.go diff --git a/cmd/v2/ui/protocol.go b/cmd/v2/ui/protocol.go index 05185d95e..2849da561 100644 --- a/cmd/v2/ui/protocol.go +++ b/cmd/v2/ui/protocol.go @@ -78,10 +78,11 @@ var ( ff(comm.ModuleFriend, friend.FriendSubTypeDelBlack): &formview.FriendDelblackView{}, ff(comm.ModuleFriend, friend.FriendSubTypeSearch): &formview.FriendSearchView{}, // ff(comm.ModuleFriend, friend.FriendSubTypeZanList): &formview.FriendZanView{}, - ff(comm.ModuleFriend, friend.FriendSubTypeRandList): &formview.FriendRandListView{}, - ff(comm.ModuleFriend, friend.FriendSubTypeGetreward): &formview.FriendGetrewardView{}, - ff(comm.ModuleFriend, friend.FriendSubTypeAssistlist): &formview.FriendAssistListView{}, - ff(comm.ModuleFriend, friend.FriendSubTypeAssistHero): &formview.FriendAssistHeroView{}, + ff(comm.ModuleFriend, friend.FriendSubTypeRandList): &formview.FriendRandListView{}, + ff(comm.ModuleFriend, friend.FriendSubTypeGetreward): &formview.FriendGetrewardView{}, + ff(comm.ModuleFriend, friend.FriendSubTypeAssistlist): &formview.FriendAssistListView{}, + ff(comm.ModuleFriend, friend.FriendSubTypeAssistHero): &formview.FriendAssistHeroView{}, + ff(comm.ModuleFriend, friend.FriendSubTypeAssistHeroList): &formview.FriendAssistHeroListView{}, // shop ff(comm.ModuleShop, "getlist"): &formview.ShopListView{}, @@ -180,6 +181,7 @@ var ( ff(comm.ModuleFriend, friend.FriendSubTypeGetreward), ff(comm.ModuleFriend, friend.FriendSubTypeAssistHero), ff(comm.ModuleFriend, friend.FriendSubTypeAssistlist), + ff(comm.ModuleFriend, friend.FriendSubTypeAssistHeroList), }, "shop": { ff(comm.ModuleShop, "getlist"), @@ -616,6 +618,13 @@ var ( SubType: friend.FriendSubTypeGetreward, Enabled: true, }, + ff(comm.ModuleFriend, friend.FriendSubTypeAssistHeroList): { + NavLabel: "助战英雄列表", + Desc: "我的好友助战英雄列表", + MainType: string(comm.ModuleFriend), + SubType: friend.FriendSubTypeAssistHeroList, + Enabled: true, + }, //shop string(comm.ModuleShop): { diff --git a/cmd/v2/ui/views/friend_assistherolist.go b/cmd/v2/ui/views/friend_assistherolist.go new file mode 100644 index 000000000..9b048d879 --- /dev/null +++ b/cmd/v2/ui/views/friend_assistherolist.go @@ -0,0 +1,38 @@ +package formview + +import ( + "go_dreamfactory/cmd/v2/model" + "go_dreamfactory/cmd/v2/service" + "go_dreamfactory/pb" + + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/theme" + "fyne.io/fyne/v2/widget" + "github.com/sirupsen/logrus" +) + +type FriendAssistHeroListView struct { + BaseformView + assistHeroList func() +} + +func (this *FriendAssistHeroListView) CreateView(t *model.TestCase) fyne.CanvasObject { + this.assistHeroList = func() { + if err := service.GetPttService().SendToClient(t.MainType, t.SubType, + &pb.FriendAssistHeroListReq{}); err != nil { + logrus.Error(err) + } + } + defer this.assistHeroList() + + refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() { + + this.assistHeroList() + }) + + buttonBar := container.NewHBox(refreshBtn) + + c := container.NewBorder(buttonBar, nil, nil, nil) + return c +} diff --git a/modules/friend/api.go b/modules/friend/api.go index 88a6e6f04..44b648231 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -24,6 +24,7 @@ const ( FriendSubTypeDel = "del" FriendSubTypeAssistlist = "assistlist" FriendSubTypeGetreward = "getreward" + FriendSubTypeAssistHeroList = "assistherolist" ) type apiComp struct { diff --git a/modules/friend/api_cross_assisthero.go b/modules/friend/api_cross_assisthero.go index 06c1bef78..ef8498f8c 100644 --- a/modules/friend/api_cross_assisthero.go +++ b/modules/friend/api_cross_assisthero.go @@ -65,17 +65,18 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth return } - //推送 - push := &pb.FriendAssistHeroListPush{} - for _, fId := range self.FriendIds { - d := this.moduleFriend.modelFriend.GetFriend(fId) - push.Friends = append(push.Friends, &pb.FriendBase{ - HeroObjId: d.AssistHeroId, - }) - } - if err := this.moduleFriend.SendMsgToUsers(string(this.moduleFriend.GetType()), "AssistHeroList", - &pb.FriendAssistHeroListPush{}, self.FriendIds...); err != nil { - this.moduleFriend.Errorf("push AssistHeroList err:", err) + // 有好友时再推送 + if len(self.FriendIds) > 0 { + //把设置的助战英雄推送给好友 + push := &pb.FriendAssistHeroListPush{ + Friend: &pb.FriendBase{ + HeroObjId: req.HeroObjId, + }, + } + + if err := this.moduleFriend.SendMsgToUsers(string(this.moduleFriend.GetType()), "assistherolist", push, self.FriendIds...); err != nil { + this.moduleFriend.Errorf("push AssistHeroList err:", err) + } } // 随机任务Rtype13 diff --git a/modules/friend/api_cross_assistherolist.go b/modules/friend/api_cross_assistherolist.go new file mode 100644 index 000000000..f21a653dc --- /dev/null +++ b/modules/friend/api_cross_assistherolist.go @@ -0,0 +1,39 @@ +package friend + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +// 好友助战英雄列表 + +func (this *apiComp) AssistHeroListCheck(session comm.IUserSession, req *pb.FriendAssistHeroListReq) (code pb.ErrorCode) { + return +} + +func (this *apiComp) AssistHeroList(session comm.IUserSession, req *pb.FriendAssistHeroListReq) (code pb.ErrorCode, data proto.Message) { + + //获取玩家自己好友数据 + self := this.moduleFriend.modelFriend.GetFriend(session.GetUserId()) + if self == nil { + code = pb.ErrorCode_FriendSelfNoData + return + } + + rsp := &pb.FriendAssistHeroListResp{} + for _, v := range self.FriendIds { + f := this.moduleFriend.modelFriend.GetFriend(v) + + rsp.Friends = append(rsp.Friends, &pb.FriendBase{ + HeroObjId: f.AssistHeroId, + }) + } + + if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeAssistHeroList, rsp); err != nil { + code = pb.ErrorCode_SystemError + } + + return +} diff --git a/modules/friend/module.go b/modules/friend/module.go index a1a761cf2..8bc8aaf1d 100644 --- a/modules/friend/module.go +++ b/modules/friend/module.go @@ -2,9 +2,11 @@ package friend import ( "context" + "errors" "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/utils" "time" "go_dreamfactory/lego/base" @@ -104,11 +106,26 @@ func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) { for _, fId := range friend.FriendIds { // 判断uid是否在指定玩家的好友列表中 if fId == uid { + //好友没有设置助战英雄 + if friend.AssistHeroId == "" { + break + } + //遍历助战记录 + for _, r := range friend.Record { + if r.AssistHeroId == friend.AssistHeroId { + if utils.IsToday(r.Zhuzhantime) { + log.Warnf("今日已助战 uid:%v friendId:%v heroId:%v", uid, friendId, r.AssistHeroId) + return nil, errors.New("今日已助战") + } + } + } //更新助战记录和助战分数 friend.ZhuzhanScore++ + // 设置助战记录 friend.Record = append(friend.Record, &pb.ZhuZhanRecord{ - Uid: uid, - Zhuzhantime: time.Now().Unix(), + Uid: uid, + AssistHeroId: friend.AssistHeroId, + Zhuzhantime: time.Now().Unix(), }) update := map[string]interface{}{ "zhuzhanScore": friend.ZhuzhanScore, @@ -117,5 +134,6 @@ func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) { return friend.Hero, this.modelFriend.Change(friendId, update) } } - return nil, nil + log.Errorf("[friendId:%v]不是你[uid:%v]的好友", uid, friendId) + return nil, errors.New("非好友") } diff --git a/modules/linestory/api_dotask.go b/modules/linestory/api_dotask.go index 2255ecc22..a6a93dd76 100644 --- a/modules/linestory/api_dotask.go +++ b/modules/linestory/api_dotask.go @@ -13,7 +13,7 @@ func (this *apiComp) DotaskCheck(session comm.IUserSession, req *pb.LinestoryDot if req.TaskId == 0 || req.SubtaskId == 0 { code = pb.ErrorCode_ReqParameterError } - return + return } func (this *apiComp) Dotask(session comm.IUserSession, req *pb.LinestoryDotaskReq) (code pb.ErrorCode, data proto.Message) { diff --git a/pb/friend_db.pb.go b/pb/friend_db.pb.go index bf7f69922..648de5c23 100644 --- a/pb/friend_db.pb.go +++ b/pb/friend_db.pb.go @@ -161,8 +161,9 @@ type ZhuZhanRecord struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //好友Id - Zhuzhantime int64 `protobuf:"varint,2,opt,name=zhuzhantime,proto3" json:"zhuzhantime" bson:"zhuzhanTime"` //上次助战时间 + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //好友Id + Zhuzhantime int64 `protobuf:"varint,2,opt,name=zhuzhantime,proto3" json:"zhuzhantime" bson:"zhuzhanTime"` //上次助战时间 + AssistHeroId string `protobuf:"bytes,3,opt,name=assistHeroId,proto3" json:"assistHeroId" bson:"assistHeroId"` //助战英雄 } func (x *ZhuZhanRecord) Reset() { @@ -211,6 +212,13 @@ func (x *ZhuZhanRecord) GetZhuzhantime() int64 { return 0 } +func (x *ZhuZhanRecord) GetAssistHeroId() string { + if x != nil { + return x.AssistHeroId + } + return "" +} + var File_friend_friend_db_proto protoreflect.FileDescriptor var file_friend_friend_db_proto_rawDesc = []byte{ @@ -240,12 +248,14 @@ var file_friend_friend_db_proto_rawDesc = []byte{ 0x75, 0x7a, 0x68, 0x61, 0x6e, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x5a, 0x68, 0x75, 0x5a, 0x68, 0x61, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, - 0x72, 0x64, 0x22, 0x43, 0x0a, 0x0d, 0x5a, 0x68, 0x75, 0x5a, 0x68, 0x61, 0x6e, 0x52, 0x65, 0x63, + 0x72, 0x64, 0x22, 0x67, 0x0a, 0x0d, 0x5a, 0x68, 0x75, 0x5a, 0x68, 0x61, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x7a, 0x68, 0x75, 0x7a, 0x68, 0x61, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x7a, 0x68, 0x75, 0x7a, - 0x68, 0x61, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x61, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x73, 0x73, 0x69, 0x73, + 0x74, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, + 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/friend_msg.pb.go b/pb/friend_msg.pb.go index 51bd3a031..2f88ce372 100644 --- a/pb/friend_msg.pb.go +++ b/pb/friend_msg.pb.go @@ -1866,13 +1866,13 @@ func (x *FriendGetrewardResp) GetReceived() int32 { return 0 } -// 助战英雄列表推送 +// 助战英雄更新推送 type FriendAssistHeroListPush struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Friends []*FriendBase `protobuf:"bytes,1,rep,name=friends,proto3" json:"friends"` //好友列表 + Friend *FriendBase `protobuf:"bytes,1,opt,name=friend,proto3" json:"friend"` //好友 } func (x *FriendAssistHeroListPush) Reset() { @@ -1907,7 +1907,93 @@ func (*FriendAssistHeroListPush) Descriptor() ([]byte, []int) { return file_friend_friend_msg_proto_rawDescGZIP(), []int{37} } -func (x *FriendAssistHeroListPush) GetFriends() []*FriendBase { +func (x *FriendAssistHeroListPush) GetFriend() *FriendBase { + if x != nil { + return x.Friend + } + return nil +} + +//好友助战英雄列表 +type FriendAssistHeroListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FriendAssistHeroListReq) Reset() { + *x = FriendAssistHeroListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_friend_msg_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAssistHeroListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAssistHeroListReq) ProtoMessage() {} + +func (x *FriendAssistHeroListReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_friend_msg_proto_msgTypes[38] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendAssistHeroListReq.ProtoReflect.Descriptor instead. +func (*FriendAssistHeroListReq) Descriptor() ([]byte, []int) { + return file_friend_friend_msg_proto_rawDescGZIP(), []int{38} +} + +type FriendAssistHeroListResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Friends []*FriendBase `protobuf:"bytes,1,rep,name=friends,proto3" json:"friends"` +} + +func (x *FriendAssistHeroListResp) Reset() { + *x = FriendAssistHeroListResp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_friend_msg_proto_msgTypes[39] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAssistHeroListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAssistHeroListResp) ProtoMessage() {} + +func (x *FriendAssistHeroListResp) ProtoReflect() protoreflect.Message { + mi := &file_friend_friend_msg_proto_msgTypes[39] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendAssistHeroListResp.ProtoReflect.Descriptor instead. +func (*FriendAssistHeroListResp) Descriptor() ([]byte, []int) { + return file_friend_friend_msg_proto_rawDescGZIP(), []int{39} +} + +func (x *FriendAssistHeroListResp) GetFriends() []*FriendBase { if x != nil { return x.Friends } @@ -2053,12 +2139,18 @@ var file_friend_friend_msg_proto_rawDesc = []byte{ 0x22, 0x31, 0x0a, 0x13, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x22, 0x41, 0x0a, 0x18, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, + 0x76, 0x65, 0x64, 0x22, 0x3f, 0x0a, 0x18, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x75, 0x73, 0x68, 0x12, - 0x25, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x23, 0x0a, 0x06, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x06, 0x66, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x22, 0x19, 0x0a, 0x17, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, + 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, + 0x41, 0x0a, 0x18, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, + 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -2073,7 +2165,7 @@ func file_friend_friend_msg_proto_rawDescGZIP() []byte { return file_friend_friend_msg_proto_rawDescData } -var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 38) +var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 40) var file_friend_friend_msg_proto_goTypes = []interface{}{ (*FriendBase)(nil), // 0: FriendBase (*FriendListReq)(nil), // 1: FriendListReq @@ -2113,7 +2205,9 @@ var file_friend_friend_msg_proto_goTypes = []interface{}{ (*FriendGetrewardReq)(nil), // 35: FriendGetrewardReq (*FriendGetrewardResp)(nil), // 36: FriendGetrewardResp (*FriendAssistHeroListPush)(nil), // 37: FriendAssistHeroListPush - (*ZhuZhanRecord)(nil), // 38: ZhuZhanRecord + (*FriendAssistHeroListReq)(nil), // 38: FriendAssistHeroListReq + (*FriendAssistHeroListResp)(nil), // 39: FriendAssistHeroListResp + (*ZhuZhanRecord)(nil), // 40: ZhuZhanRecord } var file_friend_friend_msg_proto_depIdxs = []int32{ 0, // 0: FriendListResp.list:type_name -> FriendBase @@ -2123,13 +2217,14 @@ var file_friend_friend_msg_proto_depIdxs = []int32{ 0, // 4: FriendBlackListResp.friends:type_name -> FriendBase 0, // 5: FriendZanlistResp.list:type_name -> FriendBase 0, // 6: FriendAssistlistResp.list:type_name -> FriendBase - 38, // 7: FriendAssistlistResp.record:type_name -> ZhuZhanRecord - 0, // 8: FriendAssistHeroListPush.friends:type_name -> FriendBase - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 40, // 7: FriendAssistlistResp.record:type_name -> ZhuZhanRecord + 0, // 8: FriendAssistHeroListPush.friend:type_name -> FriendBase + 0, // 9: FriendAssistHeroListResp.friends:type_name -> FriendBase + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_friend_friend_msg_proto_init() } @@ -2595,6 +2690,30 @@ func file_friend_friend_msg_proto_init() { return nil } } + file_friend_friend_msg_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAssistHeroListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_friend_msg_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAssistHeroListResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2602,7 +2721,7 @@ func file_friend_friend_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_friend_friend_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 38, + NumMessages: 40, NumExtensions: 0, NumServices: 0, }, From c9b1b99d64499bf84a3dd909776320bc015d5223 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 21 Oct 2022 17:34:08 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8A=A9=E6=88=98=E6=8E=92=E8=A1=8C?= =?UTF-8?q?=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_msgdistrib.json | 16 +- cmd/v2/FyneApp.toml | 4 +- cmd/v2/ui/views/hero_info.go | 6 +- modules/friend/api.go | 1 + modules/friend/api_cross_assisthero.go | 5 +- modules/friend/api_cross_assistherolist.go | 3 +- modules/friend/api_cross_assistlist.go | 20 ++- modules/friend/module.go | 16 +- modules/timer/module.go | 1 - modules/user/module.go | 3 +- pb/friend_db.pb.go | 94 ++++++------ pb/friend_msg.pb.go | 168 +++++++++++---------- 12 files changed, 185 insertions(+), 152 deletions(-) diff --git a/bin/json/game_msgdistrib.json b/bin/json/game_msgdistrib.json index cc36bbb68..14562d9cf 100644 --- a/bin/json/game_msgdistrib.json +++ b/bin/json/game_msgdistrib.json @@ -13,32 +13,32 @@ }, { "msgid": "chat", - "routrules": "~/worker", "open": true, + "routrules": "~/worker", "describe": "聊天系统" }, { "msgid": "chat.chanagechannel", - "routrules": "~/worker", "open": true, + "routrules": "~/worker", "describe": "聊天系统" }, { "msgid": "chat.crosschannel", - "routrules": "~/worker", "open": true, + "routrules": "~/worker", "describe": "聊天系统" }, { "msgid": "chat.getcrosslist", - "routrules": "~/worker", "open": true, + "routrules": "~/worker", "describe": "聊天系统" }, { "msgid": "chat.sendcross", - "routrules": "~/worker", "open": true, + "routrules": "~/worker", "describe": "聊天系统" }, { @@ -154,5 +154,11 @@ "open": true, "routrules": "~/worker", "describe": "好友推荐" + }, + { + "msgid": "friend.assistherolist", + "open": true, + "routrules": "~/worker", + "describe": "好友助战英雄列表" } ] \ No newline at end of file diff --git a/cmd/v2/FyneApp.toml b/cmd/v2/FyneApp.toml index 683a15be3..5e4358de2 100644 --- a/cmd/v2/FyneApp.toml +++ b/cmd/v2/FyneApp.toml @@ -4,5 +4,5 @@ Website = "http://legu.cc" Icon = "app.png" Name = "RobotGUI" ID = "cc.legu.app" - Version = "1.0.17" - Build = 20 + Version = "1.0.18" + Build = 21 diff --git a/cmd/v2/ui/views/hero_info.go b/cmd/v2/ui/views/hero_info.go index c75dd41ed..f62834e65 100644 --- a/cmd/v2/ui/views/hero_info.go +++ b/cmd/v2/ui/views/hero_info.go @@ -4,6 +4,7 @@ import ( "go_dreamfactory/cmd/v2/model" "go_dreamfactory/cmd/v2/service" "go_dreamfactory/pb" + "strings" "fyne.io/fyne/v2" "fyne.io/fyne/v2/widget" @@ -19,18 +20,19 @@ func (this *HeroInfoView) CreateView(t *model.TestCase) fyne.CanvasObject { uidEntry.PlaceHolder = "玩家ID" heroIdEntry := widget.NewEntry() - heroIdEntry.PlaceHolder = "英雄ObjID" + heroIdEntry.PlaceHolder = "英雄ObjID,多个用逗号分隔" this.form.AppendItem(widget.NewFormItem("UID", uidEntry)) this.form.AppendItem(widget.NewFormItem("HeroObjID", heroIdEntry)) + heroIds := strings.Split(heroIdEntry.Text, ",") this.form.OnSubmit = func() { if err := service.GetPttService().SendToClient( t.MainType, t.SubType, &pb.HeroInfoReq{ Uid: uidEntry.Text, - HeroId: heroIdEntry.Text, + HeroId: heroIds, }, ); err != nil { logrus.Error(err) diff --git a/modules/friend/api.go b/modules/friend/api.go index 44b648231..c8d484c14 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -40,6 +40,7 @@ func (this *apiComp) Init(service core.IService, module core.IModule, comp core. func (this *apiComp) setDefaultFriendUserBaseInfo(userId string) *pb.FriendBase { if user, err := this.moduleFriend.ModuleUser.GetRmoteUser(userId); err != nil { + this.moduleFriend.Errorf("GetRmoteUser err:%v", err) return nil } else { if user != nil { diff --git a/modules/friend/api_cross_assisthero.go b/modules/friend/api_cross_assisthero.go index ef8498f8c..ddbc5b04b 100644 --- a/modules/friend/api_cross_assisthero.go +++ b/modules/friend/api_cross_assisthero.go @@ -68,13 +68,14 @@ func (this *apiComp) Assisthero(session comm.IUserSession, req *pb.FriendAssisth // 有好友时再推送 if len(self.FriendIds) > 0 { //把设置的助战英雄推送给好友 - push := &pb.FriendAssistHeroListPush{ + push := &pb.FriendAssistHeroUpdatePush{ Friend: &pb.FriendBase{ + UserId: self.Uid, HeroObjId: req.HeroObjId, }, } - if err := this.moduleFriend.SendMsgToUsers(string(this.moduleFriend.GetType()), "assistherolist", push, self.FriendIds...); err != nil { + if err := this.moduleFriend.SendMsgToUsers(string(this.moduleFriend.GetType()), "assistheroupdate", push, self.FriendIds...); err != nil { this.moduleFriend.Errorf("push AssistHeroList err:", err) } } diff --git a/modules/friend/api_cross_assistherolist.go b/modules/friend/api_cross_assistherolist.go index f21a653dc..b12a270d3 100644 --- a/modules/friend/api_cross_assistherolist.go +++ b/modules/friend/api_cross_assistherolist.go @@ -27,6 +27,7 @@ func (this *apiComp) AssistHeroList(session comm.IUserSession, req *pb.FriendAss f := this.moduleFriend.modelFriend.GetFriend(v) rsp.Friends = append(rsp.Friends, &pb.FriendBase{ + UserId: v, HeroObjId: f.AssistHeroId, }) } @@ -34,6 +35,6 @@ func (this *apiComp) AssistHeroList(session comm.IUserSession, req *pb.FriendAss if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeAssistHeroList, rsp); err != nil { code = pb.ErrorCode_SystemError } - + return } diff --git a/modules/friend/api_cross_assistlist.go b/modules/friend/api_cross_assistlist.go index ee1228b6d..e04427f1f 100644 --- a/modules/friend/api_cross_assistlist.go +++ b/modules/friend/api_cross_assistlist.go @@ -3,6 +3,7 @@ package friend import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/utils" "sort" "google.golang.org/protobuf/proto" @@ -29,14 +30,20 @@ func (this *apiComp) Assistlist(session comm.IUserSession, req *pb.FriendAssistl if target == nil { continue } - base.HeroObjId = target.AssistHeroId - base.Score = target.ZhuzhanScore - list = append(list, base) + if target.AssistHeroId != "" { + base.HeroObjId = target.AssistHeroId + base.Score = target.AssistScore + base.UpdateTime = target.UpdateTime + list = append(list, base) + } } } //排序并取前三 sort.Slice(list, func(i, j int) bool { + if list[i].Score == list[j].Score { + return list[i].UpdateTime < list[j].UpdateTime + } return list[i].Score < list[j].Score }) @@ -47,8 +54,13 @@ func (this *apiComp) Assistlist(session comm.IUserSession, req *pb.FriendAssistl } } + //助战记录一周清空 + if utils.IsAfterWeek(self.UpdateTime) { + self.Record = []*pb.AssistRecord{} + } + rsp := &pb.FriendAssistlistResp{ - List: list, + List: firstThree, HeroObjId: self.AssistHeroId, Record: self.Record, } diff --git a/modules/friend/module.go b/modules/friend/module.go index 8bc8aaf1d..81f997be8 100644 --- a/modules/friend/module.go +++ b/modules/friend/module.go @@ -90,11 +90,12 @@ func (this *Friend) GetFriendList(uid string) (uids []string) { } func (this *Friend) RpcUseAssisHero(ctx context.Context, req *pb.RPCGeneralReqA2, reply *pb.DBHero) error { + this.Debug("Rpc_ModuleFriendUseAssitHero", log.Field{Key: "req", Value: req}) hero, err := this.UseAssistHero(req.Param1, req.Param2) if err != nil { return err } - reply = hero + *reply = *hero return nil } @@ -113,23 +114,24 @@ func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) { //遍历助战记录 for _, r := range friend.Record { if r.AssistHeroId == friend.AssistHeroId { - if utils.IsToday(r.Zhuzhantime) { + if utils.IsToday(r.AssistTime) { log.Warnf("今日已助战 uid:%v friendId:%v heroId:%v", uid, friendId, r.AssistHeroId) return nil, errors.New("今日已助战") } } } //更新助战记录和助战分数 - friend.ZhuzhanScore++ + friend.AssistScore++ // 设置助战记录 - friend.Record = append(friend.Record, &pb.ZhuZhanRecord{ + friend.Record = append(friend.Record, &pb.AssistRecord{ Uid: uid, AssistHeroId: friend.AssistHeroId, - Zhuzhantime: time.Now().Unix(), + AssistTime: time.Now().Unix(), }) update := map[string]interface{}{ - "zhuzhanScore": friend.ZhuzhanScore, - "record": friend.Record, + "assistScore": friend.AssistScore, + "record": friend.Record, + "updateTime": time.Now().Unix(), } return friend.Hero, this.modelFriend.Change(friendId, update) } diff --git a/modules/timer/module.go b/modules/timer/module.go index 771bf6486..304595f44 100644 --- a/modules/timer/module.go +++ b/modules/timer/module.go @@ -62,7 +62,6 @@ func (this *Timer) OnInstallComp() { this.rank3 = this.RegisterComp(new(HuntingRank)).(*HuntingRank) this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp) this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda) - } //日志 diff --git a/modules/user/module.go b/modules/user/module.go index 1848bb2e3..cdaa9fe7e 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -355,8 +355,7 @@ func (this *User) getUserFromRemoteDb(uid string, rsp *pb.DBUser) error { return errors.New("sid split error") } conn, err := db.ServerDBConn(sid) - if err != nil { - log.Errorf("cross db err: %v", err) + if err != nil { return err } model := db.NewDBModel(comm.TableUser, 0, conn) diff --git a/pb/friend_db.pb.go b/pb/friend_db.pb.go index 648de5c23..95e051d19 100644 --- a/pb/friend_db.pb.go +++ b/pb/friend_db.pb.go @@ -25,18 +25,18 @@ type DBFriend struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - FriendIds []string `protobuf:"bytes,2,rep,name=friendIds,proto3" json:"friendIds" bson:"friendIds"` //好友ID - ApplyIds []string `protobuf:"bytes,3,rep,name=applyIds,proto3" json:"applyIds" bson:"applyIds"` //申请用户ID - BlackIds []string `protobuf:"bytes,4,rep,name=blackIds,proto3" json:"blackIds" bson:"blackIds"` //黑名单ID - ZanIds []string `protobuf:"bytes,5,rep,name=zanIds,proto3" json:"zanIds" bson:"zanIds"` //点赞好友ID - GetZandIds []string `protobuf:"bytes,6,rep,name=getZandIds,proto3" json:"getZandIds" bson:"getZandIds"` //已接收赞好友ID - AssistHeroId string `protobuf:"bytes,7,opt,name=assistHeroId,proto3" json:"assistHeroId" bson:"assistHeroId"` //助战英雄ID - Received int32 `protobuf:"varint,8,opt,name=received,proto3" json:"received" bson:"received"` //领取奖励状态0未领1可领2已领 - UpdateTime int64 `protobuf:"varint,9,opt,name=updateTime,proto3" json:"updateTime" bson:"updateTime"` // 更新时间 - Hero *DBHero `protobuf:"bytes,10,opt,name=hero,proto3" json:"hero" bson:"hero"` //助战英雄副本 - ZhuzhanScore int32 `protobuf:"varint,11,opt,name=zhuzhanScore,proto3" json:"zhuzhanScore" bson:"zhuzhanScore"` //助战分数合计 - Record []*ZhuZhanRecord `protobuf:"bytes,12,rep,name=record,proto3" json:"record" bson:"record"` // 助战记录 + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + FriendIds []string `protobuf:"bytes,2,rep,name=friendIds,proto3" json:"friendIds" bson:"friendIds"` //好友ID + ApplyIds []string `protobuf:"bytes,3,rep,name=applyIds,proto3" json:"applyIds" bson:"applyIds"` //申请用户ID + BlackIds []string `protobuf:"bytes,4,rep,name=blackIds,proto3" json:"blackIds" bson:"blackIds"` //黑名单ID + ZanIds []string `protobuf:"bytes,5,rep,name=zanIds,proto3" json:"zanIds" bson:"zanIds"` //点赞好友ID + GetZandIds []string `protobuf:"bytes,6,rep,name=getZandIds,proto3" json:"getZandIds" bson:"getZandIds"` //已接收赞好友ID + AssistHeroId string `protobuf:"bytes,7,opt,name=assistHeroId,proto3" json:"assistHeroId" bson:"assistHeroId"` //助战英雄ID + Received int32 `protobuf:"varint,8,opt,name=received,proto3" json:"received" bson:"received"` //领取奖励状态0未领1可领2已领 + UpdateTime int64 `protobuf:"varint,9,opt,name=updateTime,proto3" json:"updateTime" bson:"updateTime"` // 更新时间 + Hero *DBHero `protobuf:"bytes,10,opt,name=hero,proto3" json:"hero" bson:"hero"` //助战英雄副本 + AssistScore int32 `protobuf:"varint,11,opt,name=assistScore,proto3" json:"assistScore" bson:"zhuzhanScore"` //助战分数合计 + Record []*AssistRecord `protobuf:"bytes,12,rep,name=record,proto3" json:"record" bson:"record"` // 助战记录 } func (x *DBFriend) Reset() { @@ -141,14 +141,14 @@ func (x *DBFriend) GetHero() *DBHero { return nil } -func (x *DBFriend) GetZhuzhanScore() int32 { +func (x *DBFriend) GetAssistScore() int32 { if x != nil { - return x.ZhuzhanScore + return x.AssistScore } return 0 } -func (x *DBFriend) GetRecord() []*ZhuZhanRecord { +func (x *DBFriend) GetRecord() []*AssistRecord { if x != nil { return x.Record } @@ -156,18 +156,18 @@ func (x *DBFriend) GetRecord() []*ZhuZhanRecord { } //助战记录 -type ZhuZhanRecord struct { +type AssistRecord struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //好友Id - Zhuzhantime int64 `protobuf:"varint,2,opt,name=zhuzhantime,proto3" json:"zhuzhantime" bson:"zhuzhanTime"` //上次助战时间 + AssistTime int64 `protobuf:"varint,2,opt,name=assistTime,proto3" json:"assistTime" bson:"zhuzhanTime"` //上次助战时间 AssistHeroId string `protobuf:"bytes,3,opt,name=assistHeroId,proto3" json:"assistHeroId" bson:"assistHeroId"` //助战英雄 } -func (x *ZhuZhanRecord) Reset() { - *x = ZhuZhanRecord{} +func (x *AssistRecord) Reset() { + *x = AssistRecord{} if protoimpl.UnsafeEnabled { mi := &file_friend_friend_db_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -175,13 +175,13 @@ func (x *ZhuZhanRecord) Reset() { } } -func (x *ZhuZhanRecord) String() string { +func (x *AssistRecord) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ZhuZhanRecord) ProtoMessage() {} +func (*AssistRecord) ProtoMessage() {} -func (x *ZhuZhanRecord) ProtoReflect() protoreflect.Message { +func (x *AssistRecord) ProtoReflect() protoreflect.Message { mi := &file_friend_friend_db_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -193,26 +193,26 @@ func (x *ZhuZhanRecord) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ZhuZhanRecord.ProtoReflect.Descriptor instead. -func (*ZhuZhanRecord) Descriptor() ([]byte, []int) { +// Deprecated: Use AssistRecord.ProtoReflect.Descriptor instead. +func (*AssistRecord) Descriptor() ([]byte, []int) { return file_friend_friend_db_proto_rawDescGZIP(), []int{1} } -func (x *ZhuZhanRecord) GetUid() string { +func (x *AssistRecord) GetUid() string { if x != nil { return x.Uid } return "" } -func (x *ZhuZhanRecord) GetZhuzhantime() int64 { +func (x *AssistRecord) GetAssistTime() int64 { if x != nil { - return x.Zhuzhantime + return x.AssistTime } return 0 } -func (x *ZhuZhanRecord) GetAssistHeroId() string { +func (x *AssistRecord) GetAssistHeroId() string { if x != nil { return x.AssistHeroId } @@ -224,7 +224,7 @@ var File_friend_friend_db_proto protoreflect.FileDescriptor var file_friend_friend_db_proto_rawDesc = []byte{ 0x0a, 0x16, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x68, 0x65, 0x72, 0x6f, 0x2f, 0x68, - 0x65, 0x72, 0x6f, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf3, 0x02, 0x0a, + 0x65, 0x72, 0x6f, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf0, 0x02, 0x0a, 0x08, 0x44, 0x42, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, @@ -243,19 +243,19 @@ var file_friend_friend_db_proto_rawDesc = []byte{ 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, - 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x12, 0x22, 0x0a, 0x0c, 0x7a, 0x68, 0x75, 0x7a, 0x68, 0x61, - 0x6e, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x7a, 0x68, - 0x75, 0x7a, 0x68, 0x61, 0x6e, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x72, 0x65, - 0x63, 0x6f, 0x72, 0x64, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x5a, 0x68, 0x75, - 0x5a, 0x68, 0x61, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, - 0x72, 0x64, 0x22, 0x67, 0x0a, 0x0d, 0x5a, 0x68, 0x75, 0x5a, 0x68, 0x61, 0x6e, 0x52, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x7a, 0x68, 0x75, 0x7a, 0x68, 0x61, 0x6e, - 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x7a, 0x68, 0x75, 0x7a, - 0x68, 0x61, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x73, 0x73, 0x69, 0x73, - 0x74, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, - 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, - 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, + 0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x61, 0x73, 0x73, + 0x69, 0x73, 0x74, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x73, 0x73, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x22, + 0x64, 0x0a, 0x0c, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, + 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, + 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x49, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, + 0x65, 0x72, 0x6f, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -272,13 +272,13 @@ func file_friend_friend_db_proto_rawDescGZIP() []byte { var file_friend_friend_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_friend_friend_db_proto_goTypes = []interface{}{ - (*DBFriend)(nil), // 0: DBFriend - (*ZhuZhanRecord)(nil), // 1: ZhuZhanRecord - (*DBHero)(nil), // 2: DBHero + (*DBFriend)(nil), // 0: DBFriend + (*AssistRecord)(nil), // 1: AssistRecord + (*DBHero)(nil), // 2: DBHero } var file_friend_friend_db_proto_depIdxs = []int32{ 2, // 0: DBFriend.hero:type_name -> DBHero - 1, // 1: DBFriend.record:type_name -> ZhuZhanRecord + 1, // 1: DBFriend.record:type_name -> AssistRecord 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -306,7 +306,7 @@ func file_friend_friend_db_proto_init() { } } file_friend_friend_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ZhuZhanRecord); i { + switch v := v.(*AssistRecord); i { case 0: return &v.state case 1: diff --git a/pb/friend_msg.pb.go b/pb/friend_msg.pb.go index 2f88ce372..d242e8104 100644 --- a/pb/friend_msg.pb.go +++ b/pb/friend_msg.pb.go @@ -37,6 +37,7 @@ type FriendBase struct { IsGetZaned bool `protobuf:"varint,10,opt,name=isGetZaned,proto3" json:"isGetZaned"` //是否已获赞 HeroObjId string `protobuf:"bytes,11,opt,name=heroObjId,proto3" json:"heroObjId"` //助战英雄ID Score int32 `protobuf:"varint,12,opt,name=score,proto3" json:"score"` //助战分数 + UpdateTime int64 `protobuf:"varint,13,opt,name=updateTime,proto3" json:"updateTime"` //更新时间 } func (x *FriendBase) Reset() { @@ -155,6 +156,13 @@ func (x *FriendBase) GetScore() int32 { return 0 } +func (x *FriendBase) GetUpdateTime() int64 { + if x != nil { + return x.UpdateTime + } + return 0 +} + //好友列表 type FriendListReq struct { state protoimpl.MessageState @@ -1722,9 +1730,9 @@ type FriendAssistlistResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - List []*FriendBase `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` //好友助战排行 - HeroObjId string `protobuf:"bytes,2,opt,name=heroObjId,proto3" json:"heroObjId"` //助战英雄 - Record []*ZhuZhanRecord `protobuf:"bytes,3,rep,name=record,proto3" json:"record"` //我的助战记录 + List []*FriendBase `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` //好友助战排行 + HeroObjId string `protobuf:"bytes,2,opt,name=heroObjId,proto3" json:"heroObjId"` //助战英雄 + Record []*AssistRecord `protobuf:"bytes,3,rep,name=record,proto3" json:"record"` //我的助战记录 } func (x *FriendAssistlistResp) Reset() { @@ -1773,7 +1781,7 @@ func (x *FriendAssistlistResp) GetHeroObjId() string { return "" } -func (x *FriendAssistlistResp) GetRecord() []*ZhuZhanRecord { +func (x *FriendAssistlistResp) GetRecord() []*AssistRecord { if x != nil { return x.Record } @@ -1867,7 +1875,7 @@ func (x *FriendGetrewardResp) GetReceived() int32 { } // 助战英雄更新推送 -type FriendAssistHeroListPush struct { +type FriendAssistHeroUpdatePush struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -1875,8 +1883,8 @@ type FriendAssistHeroListPush struct { Friend *FriendBase `protobuf:"bytes,1,opt,name=friend,proto3" json:"friend"` //好友 } -func (x *FriendAssistHeroListPush) Reset() { - *x = FriendAssistHeroListPush{} +func (x *FriendAssistHeroUpdatePush) Reset() { + *x = FriendAssistHeroUpdatePush{} if protoimpl.UnsafeEnabled { mi := &file_friend_friend_msg_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1884,13 +1892,13 @@ func (x *FriendAssistHeroListPush) Reset() { } } -func (x *FriendAssistHeroListPush) String() string { +func (x *FriendAssistHeroUpdatePush) String() string { return protoimpl.X.MessageStringOf(x) } -func (*FriendAssistHeroListPush) ProtoMessage() {} +func (*FriendAssistHeroUpdatePush) ProtoMessage() {} -func (x *FriendAssistHeroListPush) ProtoReflect() protoreflect.Message { +func (x *FriendAssistHeroUpdatePush) ProtoReflect() protoreflect.Message { mi := &file_friend_friend_msg_proto_msgTypes[37] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1902,12 +1910,12 @@ func (x *FriendAssistHeroListPush) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use FriendAssistHeroListPush.ProtoReflect.Descriptor instead. -func (*FriendAssistHeroListPush) Descriptor() ([]byte, []int) { +// Deprecated: Use FriendAssistHeroUpdatePush.ProtoReflect.Descriptor instead. +func (*FriendAssistHeroUpdatePush) Descriptor() ([]byte, []int) { return file_friend_friend_msg_proto_rawDescGZIP(), []int{37} } -func (x *FriendAssistHeroListPush) GetFriend() *FriendBase { +func (x *FriendAssistHeroUpdatePush) GetFriend() *FriendBase { if x != nil { return x.Friend } @@ -2006,7 +2014,7 @@ var file_friend_friend_msg_proto_rawDesc = []byte{ 0x0a, 0x17, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x22, 0xd4, 0x02, 0x0a, 0x0a, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, + 0x6f, 0x22, 0xf4, 0x02, 0x0a, 0x0a, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, @@ -2027,7 +2035,9 @@ var file_friend_friend_msg_proto_rawDesc = []byte{ 0x61, 0x6e, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, + 0x05, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x31, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, @@ -2126,31 +2136,31 @@ var file_friend_friend_msg_proto_rawDesc = []byte{ 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, - 0x73, 0x69, 0x73, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x7d, 0x0a, 0x14, 0x46, + 0x73, 0x69, 0x73, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x7c, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, - 0x49, 0x64, 0x12, 0x26, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x5a, 0x68, 0x75, 0x5a, 0x68, 0x61, 0x6e, 0x52, 0x65, 0x63, 0x6f, - 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, - 0x22, 0x31, 0x0a, 0x13, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x72, 0x65, 0x77, - 0x61, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x64, 0x22, 0x3f, 0x0a, 0x18, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, - 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x75, 0x73, 0x68, 0x12, - 0x23, 0x0a, 0x06, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x06, 0x66, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x22, 0x19, 0x0a, 0x17, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, - 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, - 0x41, 0x0a, 0x18, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, - 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, 0x66, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, - 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x49, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x22, + 0x31, 0x0a, 0x13, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x72, 0x65, 0x77, 0x61, + 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, + 0x65, 0x64, 0x22, 0x41, 0x0a, 0x1a, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, 0x69, + 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x75, 0x73, 0x68, + 0x12, 0x23, 0x0a, 0x06, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x06, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x22, 0x19, 0x0a, 0x17, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, + 0x73, 0x73, 0x69, 0x73, 0x74, 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, + 0x22, 0x41, 0x0a, 0x18, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x73, 0x73, 0x69, 0x73, 0x74, + 0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, + 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, + 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -2167,47 +2177,47 @@ func file_friend_friend_msg_proto_rawDescGZIP() []byte { var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 40) var file_friend_friend_msg_proto_goTypes = []interface{}{ - (*FriendBase)(nil), // 0: FriendBase - (*FriendListReq)(nil), // 1: FriendListReq - (*FriendListResp)(nil), // 2: FriendListResp - (*FriendRandlistReq)(nil), // 3: FriendRandlistReq - (*FriendRandlistResp)(nil), // 4: FriendRandlistResp - (*FriendApplyReq)(nil), // 5: FriendApplyReq - (*FriendApplyResp)(nil), // 6: FriendApplyResp - (*FriendDelReq)(nil), // 7: FriendDelReq - (*FriendDelResp)(nil), // 8: FriendDelResp - (*FriendAgreeReq)(nil), // 9: FriendAgreeReq - (*FriendAgreeResp)(nil), // 10: FriendAgreeResp - (*FriendRefuseReq)(nil), // 11: FriendRefuseReq - (*FriendRefuseResp)(nil), // 12: FriendRefuseResp - (*FriendApplyListReq)(nil), // 13: FriendApplyListReq - (*FriendApplyListResp)(nil), // 14: FriendApplyListResp - (*FriendSearchReq)(nil), // 15: FriendSearchReq - (*FriendSearchResp)(nil), // 16: FriendSearchResp - (*FriendBlackListReq)(nil), // 17: FriendBlackListReq - (*FriendBlackListResp)(nil), // 18: FriendBlackListResp - (*FriendAddBlackReq)(nil), // 19: FriendAddBlackReq - (*FriendAddBlackResp)(nil), // 20: FriendAddBlackResp - (*FriendDelBlackReq)(nil), // 21: FriendDelBlackReq - (*FriendDelBlackResp)(nil), // 22: FriendDelBlackResp - (*FriendTotalReq)(nil), // 23: FriendTotalReq - (*FriendTotalResp)(nil), // 24: FriendTotalResp - (*FriendZanlistReq)(nil), // 25: FriendZanlistReq - (*FriendZanlistResp)(nil), // 26: FriendZanlistResp - (*FriendZanReq)(nil), // 27: FriendZanReq - (*FriendZanResp)(nil), // 28: FriendZanResp - (*FriendZanreceiveReq)(nil), // 29: FriendZanreceiveReq - (*FriendZanreceiveResp)(nil), // 30: FriendZanreceiveResp - (*FriendAssistheroReq)(nil), // 31: FriendAssistheroReq - (*FriendAssistheroResp)(nil), // 32: FriendAssistheroResp - (*FriendAssistlistReq)(nil), // 33: FriendAssistlistReq - (*FriendAssistlistResp)(nil), // 34: FriendAssistlistResp - (*FriendGetrewardReq)(nil), // 35: FriendGetrewardReq - (*FriendGetrewardResp)(nil), // 36: FriendGetrewardResp - (*FriendAssistHeroListPush)(nil), // 37: FriendAssistHeroListPush - (*FriendAssistHeroListReq)(nil), // 38: FriendAssistHeroListReq - (*FriendAssistHeroListResp)(nil), // 39: FriendAssistHeroListResp - (*ZhuZhanRecord)(nil), // 40: ZhuZhanRecord + (*FriendBase)(nil), // 0: FriendBase + (*FriendListReq)(nil), // 1: FriendListReq + (*FriendListResp)(nil), // 2: FriendListResp + (*FriendRandlistReq)(nil), // 3: FriendRandlistReq + (*FriendRandlistResp)(nil), // 4: FriendRandlistResp + (*FriendApplyReq)(nil), // 5: FriendApplyReq + (*FriendApplyResp)(nil), // 6: FriendApplyResp + (*FriendDelReq)(nil), // 7: FriendDelReq + (*FriendDelResp)(nil), // 8: FriendDelResp + (*FriendAgreeReq)(nil), // 9: FriendAgreeReq + (*FriendAgreeResp)(nil), // 10: FriendAgreeResp + (*FriendRefuseReq)(nil), // 11: FriendRefuseReq + (*FriendRefuseResp)(nil), // 12: FriendRefuseResp + (*FriendApplyListReq)(nil), // 13: FriendApplyListReq + (*FriendApplyListResp)(nil), // 14: FriendApplyListResp + (*FriendSearchReq)(nil), // 15: FriendSearchReq + (*FriendSearchResp)(nil), // 16: FriendSearchResp + (*FriendBlackListReq)(nil), // 17: FriendBlackListReq + (*FriendBlackListResp)(nil), // 18: FriendBlackListResp + (*FriendAddBlackReq)(nil), // 19: FriendAddBlackReq + (*FriendAddBlackResp)(nil), // 20: FriendAddBlackResp + (*FriendDelBlackReq)(nil), // 21: FriendDelBlackReq + (*FriendDelBlackResp)(nil), // 22: FriendDelBlackResp + (*FriendTotalReq)(nil), // 23: FriendTotalReq + (*FriendTotalResp)(nil), // 24: FriendTotalResp + (*FriendZanlistReq)(nil), // 25: FriendZanlistReq + (*FriendZanlistResp)(nil), // 26: FriendZanlistResp + (*FriendZanReq)(nil), // 27: FriendZanReq + (*FriendZanResp)(nil), // 28: FriendZanResp + (*FriendZanreceiveReq)(nil), // 29: FriendZanreceiveReq + (*FriendZanreceiveResp)(nil), // 30: FriendZanreceiveResp + (*FriendAssistheroReq)(nil), // 31: FriendAssistheroReq + (*FriendAssistheroResp)(nil), // 32: FriendAssistheroResp + (*FriendAssistlistReq)(nil), // 33: FriendAssistlistReq + (*FriendAssistlistResp)(nil), // 34: FriendAssistlistResp + (*FriendGetrewardReq)(nil), // 35: FriendGetrewardReq + (*FriendGetrewardResp)(nil), // 36: FriendGetrewardResp + (*FriendAssistHeroUpdatePush)(nil), // 37: FriendAssistHeroUpdatePush + (*FriendAssistHeroListReq)(nil), // 38: FriendAssistHeroListReq + (*FriendAssistHeroListResp)(nil), // 39: FriendAssistHeroListResp + (*AssistRecord)(nil), // 40: AssistRecord } var file_friend_friend_msg_proto_depIdxs = []int32{ 0, // 0: FriendListResp.list:type_name -> FriendBase @@ -2217,8 +2227,8 @@ var file_friend_friend_msg_proto_depIdxs = []int32{ 0, // 4: FriendBlackListResp.friends:type_name -> FriendBase 0, // 5: FriendZanlistResp.list:type_name -> FriendBase 0, // 6: FriendAssistlistResp.list:type_name -> FriendBase - 40, // 7: FriendAssistlistResp.record:type_name -> ZhuZhanRecord - 0, // 8: FriendAssistHeroListPush.friend:type_name -> FriendBase + 40, // 7: FriendAssistlistResp.record:type_name -> AssistRecord + 0, // 8: FriendAssistHeroUpdatePush.friend:type_name -> FriendBase 0, // 9: FriendAssistHeroListResp.friends:type_name -> FriendBase 10, // [10:10] is the sub-list for method output_type 10, // [10:10] is the sub-list for method input_type @@ -2679,7 +2689,7 @@ func file_friend_friend_msg_proto_init() { } } file_friend_friend_msg_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FriendAssistHeroListPush); i { + switch v := v.(*FriendAssistHeroUpdatePush); i { case 0: return &v.state case 1: From 18e0f621cce5dba6958995aa2238d2cf18aafed4 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 21 Oct 2022 17:42:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B7=A8=E6=9C=8D=E6=97=B6=E5=80=99?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 2 + modules/pagoda/api_challengeover.go | 75 ++++++++++++++++++++++++++-- modules/pagoda/api_getlist.go | 4 +- modules/pagoda/model_rank.go | 6 ++- modules/pagoda/model_seasonpagoda.go | 26 ++++++++-- modules/timer/chat.go | 1 + modules/timer/pagodarank.go | 35 +++++++++++-- modules/timer/season.go | 69 ++++++++++++++++++++----- 8 files changed, 193 insertions(+), 25 deletions(-) diff --git a/comm/const.go b/comm/const.go index 2e0eaf3ec..42e5d5256 100644 --- a/comm/const.go +++ b/comm/const.go @@ -122,6 +122,8 @@ const ( TablePagodaRankList = "pagodaranklist" TableSeasonRankList = "seasonranklist" // 赛季塔列表 + + TableSeasonRecord = "seasonRecord" // 赛季塔记录 /// 美食馆 TableSmithy = "smithy" /// 赛季塔数据表 diff --git a/modules/pagoda/api_challengeover.go b/modules/pagoda/api_challengeover.go index 6ab7c20bc..f1b83378f 100644 --- a/modules/pagoda/api_challengeover.go +++ b/modules/pagoda/api_challengeover.go @@ -2,8 +2,11 @@ package pagoda import ( "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" + "go_dreamfactory/sys/db" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "google.golang.org/protobuf/proto" ) @@ -107,7 +110,23 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal } } } - this.module.modulerank.addPagodaList(session, pagoda, req.Report.Info.Redflist[0].Leadpos, sz, req.Report.Costtime) + if !this.module.IsCross() { + if conn, err := db.Cross(); err == nil { + userinfo := this.module.ModuleUser.GetUser(session.GetUserId()) + newData := &pb.DBPagodaRecord{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + PagodaId: pagoda.PagodaId, + Type: pagoda.Type, + Nickname: userinfo.Name, + Icon: "", // icon 暂无 + Lv: userinfo.Lv, + CostTime: req.Report.Costtime, + } + conn.Mgo.InsertOne(comm.TablePagodaRecord, newData) + } + } + //this.module.modulerank.addPagodaList(session, pagoda, req.Report.Info.Redflist[0].Leadpos, sz, req.Report.Costtime) } // 普通塔通关了 Nomalcfg := this.module.configure.GetPagodaConfigData(comm.PagodaType, pagoda.PagodaId+1) @@ -122,7 +141,13 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal seasonPagoda.Uid = session.GetUserId() seasonPagoda.PagodaId = 0 // 初始数据0层 - seasonPagoda.Type = 201 + + if conn, err := db.Cross(); err == nil { + rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}) + server := &pb.DBServerData{} + rst.Decode(server) + seasonPagoda.Type = server.SeasonType // 动态获取塔数据 + } this.module.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), seasonPagoda) // 推送新的 pagoda.PagodaId = seasonPagoda.PagodaId @@ -142,13 +167,57 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal } } } - this.module.modulerank.addPagodaRankList(session, seasonPagoda, req.Report.Info.Redflist[0].Leadpos, sz, req.Report.Costtime) + // 数据直接插入跨服数据库中 + userinfo := this.module.ModuleUser.GetUser(session.GetUserId()) + newData := &pb.DBPagodaRecord{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + PagodaId: seasonPagoda.PagodaId, + Type: seasonPagoda.Type, + Nickname: userinfo.Name, + Icon: "", // icon 暂无 + Lv: userinfo.Lv, + CostTime: req.Report.Costtime, + } + // 数据写到跨服中 + if !this.module.IsCross() { + if conn, err := db.Cross(); err == nil { + conn.Mgo.InsertOne(comm.TableSeasonRecord, newData) + } + } + //this.module.modulerank.addPagodaRankList(session, seasonPagoda, req.Report.Info.Redflist[0].Leadpos, sz, req.Report.Costtime) } // 挑战处理 seasonPagoda.PagodaId = conf.LayerNum mapData["pagodaId"] = conf.LayerNum + if !this.module.IsCross() { + if conn, err := db.Cross(); err == nil { + data := &comm.Autogenerated{ + ID: primitive.NewObjectID().Hex(), + UID: seasonPagoda.Uid, + Act: string(comm.LogHandleType_Update), + } + table := comm.TableSeasonRecord //, uid, , data) + data.D = append(data.D, table) // D[0] + data.D = append(data.D, bson.M{"uid": session.GetUserId()}) // D[1] + data.D = append(data.D, seasonPagoda) // D[2] + + _, err = conn.Mgo.InsertOne("model_log", data) + if err != nil { + log.Errorf("insert model db err %v", err) + } + } + } + code = this.module.ModifySeasonPagodaData(session.GetUserId(), mapData) + pagoda = &pb.DBPagoda{ + Id: seasonPagoda.Id, + Uid: seasonPagoda.Uid, + PagodaId: seasonPagoda.PagodaId, + Reward: seasonPagoda.Reward, + Type: seasonPagoda.Type, + } session.SendMsg(string(this.module.GetType()), PagodaChallengeOverResp, &pb.PagodaChallengeOverResp{Data: pagoda}) } diff --git a/modules/pagoda/api_getlist.go b/modules/pagoda/api_getlist.go index 6cb4cde4b..bc852f809 100644 --- a/modules/pagoda/api_getlist.go +++ b/modules/pagoda/api_getlist.go @@ -39,7 +39,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq } } else { season, _ := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId()) - if season.PagodaId == 0 { // 创建一条新的数据 + if season.Id == "" { season.Id = primitive.NewObjectID().Hex() season.Uid = session.GetUserId() season.PagodaId = 0 // 初始数据0层 @@ -51,6 +51,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq } this.module.modelSeasonPagoda.addNewSeasonPagoda(session.GetUserId(), season) } + list = &pb.DBPagoda{ Id: season.Id, Uid: season.Uid, @@ -59,7 +60,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq Type: season.Type, } } - session.SendMsg(string(this.module.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) return } diff --git a/modules/pagoda/model_rank.go b/modules/pagoda/model_rank.go index 84f30470d..19937b39e 100644 --- a/modules/pagoda/model_rank.go +++ b/modules/pagoda/model_rank.go @@ -8,6 +8,7 @@ import ( "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/db" "sort" "time" @@ -55,7 +56,10 @@ func (this *ModelRank) ChangeUserRank(uid string, value map[string]interface{}) func (this *ModelRank) GetRankData() (data []*pb.DBPagodaRecord, err error) { data = make([]*pb.DBPagodaRecord, 0) - err = this.Redis.LRange(comm.TablePagodaRankList, 0, -1, &data) + if conn, err := db.Cross(); err == nil { + err = conn.Redis.LRange(comm.TableSeasonRankList, 0, -1, &data) + } + //err = this.Redis.LRange(comm.TablePagodaRankList, 0, -1, &data) return } diff --git a/modules/pagoda/model_seasonpagoda.go b/modules/pagoda/model_seasonpagoda.go index d57d0095b..460c2d7ad 100644 --- a/modules/pagoda/model_seasonpagoda.go +++ b/modules/pagoda/model_seasonpagoda.go @@ -4,11 +4,12 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" - "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/db" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" ) @@ -34,9 +35,7 @@ func (this *ModelSeasonPagoda) Init(service core.IService, module core.IModule, func (this *ModelSeasonPagoda) getSeasonPagodaList(uid string) (result *pb.DBSeasonPagoda, err error) { result = &pb.DBSeasonPagoda{} if err = this.Get(uid, result); err != nil { - if redis.RedisNil != err { - result = nil - } + return } err = nil @@ -55,6 +54,25 @@ func (this *ModelSeasonPagoda) addNewSeasonPagoda(uId string, data *pb.DBSeasonP this.module.Errorf("err:%v", err) return } + + if !this.module.IsCross() { + if conn, err := db.Cross(); err == nil { + data1 := &comm.Autogenerated{ + ID: primitive.NewObjectID().Hex(), + UID: uId, + Act: string(comm.LogHandleType_Update), + } + table := comm.TableSeasonRecord //, uid, , data) + data1.D = append(data1.D, table) // D[0] + data1.D = append(data1.D, bson.M{"uid": uId}) // D[1] + data1.D = append(data1.D, data) // D[2] + + _, err = conn.Mgo.InsertOne("model_log", data1) + if err != nil { + log.Errorf("insert model db err %v", err) + } + } + } return nil } diff --git a/modules/timer/chat.go b/modules/timer/chat.go index fcdcde899..bf8a1bf3f 100644 --- a/modules/timer/chat.go +++ b/modules/timer/chat.go @@ -66,6 +66,7 @@ func (this *ChatComp) Start() (err error) { } else { weekStr = "*" } + cronStr := fmt.Sprintf("0 %d %d ? * %s", v1.TimeM, v1.TimeH, weekStr) this.module.Debug("注册Chat广播公告消息", log.Field{Key: "cronStr", Value: cronStr}, log.Field{Key: "text", Value: v1.Text}) if id, err = cron.AddFunc(cronStr, this.chatNoticen(v1.Text)); err != nil { diff --git a/modules/timer/pagodarank.go b/modules/timer/pagodarank.go index 482a85963..5c5d56eb8 100644 --- a/modules/timer/pagodarank.go +++ b/modules/timer/pagodarank.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/log" @@ -15,8 +16,10 @@ import ( ) type PagodaRank struct { + cbase.ModuleBase modules.MCompModel service core.IService + module *Timer } //组件初始化接口 @@ -24,20 +27,25 @@ func (this *PagodaRank) Init(service core.IService, module core.IModule, comp co this.TableName = comm.TablePagodaRecord this.MCompModel.Init(service, module, comp, options) + this.module = module.(*Timer) this.service = service return } func (this *PagodaRank) Start() (err error) { err = this.MCompModel.Start() - cron.AddFunc("*/60 * * * * ?", this.Timer) //每60s执行一次 + + cron.AddFunc("*/60 * * * * ?", this.TimerPagoda) //每60s执行一次 + + cron.AddFunc("*/60 * * * * ?", this.TimerSeason) //每60s执行一次 + return } // 处理排行榜排序 -func (this *PagodaRank) Timer() { +func (this *PagodaRank) TimerPagoda() { data := make([]interface{}, 0) // options.Find().SetLimit(comm.MaxRankList) - if _data, err := this.DB.Find(comm.TableSeasonPagoda, bson.M{}, options.Find().SetSort(bson.M{"pagodaId": -1}).SetLimit(comm.MaxRankList)); err == nil { + if _data, err := this.DB.Find(comm.TablePagoda, bson.M{}, options.Find().SetSort(bson.M{"pagodaId": -1}).SetLimit(comm.MaxRankList)); err == nil { for _data.Next(context.TODO()) { temp := &pb.DBPagodaRecord{} if err = _data.Decode(temp); err == nil { @@ -55,3 +63,24 @@ func (this *PagodaRank) Timer() { } } } + +func (this *PagodaRank) TimerSeason() { + data := make([]interface{}, 0) // options.Find().SetLimit(comm.MaxRankList) + if _data, err := this.DB.Find(comm.TableSeasonPagoda, bson.M{}, options.Find().SetSort(bson.M{"pagodaId": -1}).SetLimit(comm.MaxRankList)); err == nil { + for _data.Next(context.TODO()) { + temp := &pb.DBPagodaRecord{} + if err = _data.Decode(temp); err == nil { + data = append(data, temp) + } + } + } + if len(data) > 0 { + err := this.Redis.RPush(comm.TableSeasonRankList, data...) + if err == nil { + err = this.Redis.Ltrim(comm.TableSeasonRankList, -1*len(data), -1) //对一个列表进行修剪 + if err != nil { + log.Errorf("delete failed") + } + } + } +} diff --git a/modules/timer/season.go b/modules/timer/season.go index c9c44e585..bfdaab0d6 100644 --- a/modules/timer/season.go +++ b/modules/timer/season.go @@ -49,20 +49,19 @@ func (this *SeasonPagoda) Start() (err error) { cron.AddFunc("0 0 23 L * ?", this.TimerSeasonOver) //每月最后一天23点执行一次 cron.AddFunc("0 0 5 /* * ?", this.TimerSeasonStar) //每月第一天5点执行一次 - // _data := this.GetSeasonLoop(2) - // this.module.Debugf("%v", _data) - // for i := 0; i < 10000; i++ { - // this.CreatTestData(i) - // } + newData := &pb.DBPagoda{ + Id: primitive.NewObjectID().Hex(), + Uid: "sdsd", + PagodaId: 2, + Reward: map[int32]bool{}, + Type: 101, + } + if conn, err := db.Cross(); err == nil { + rst, _ := conn.Mgo.InsertOne(comm.TableSeasonPagoda, newData) - // if conn, err := db.Cross(); err == nil { - // rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}) - // server := &pb.DBServerData{} - // rst.Decode(server) - // fmt.Printf("%v", server) - // } + fmt.Printf("%v", rst) + } - this.TimerSeasonOver() return } func (this *SeasonPagoda) CreatTestData(index int) { @@ -135,3 +134,49 @@ func (this *SeasonPagoda) TimerSeasonOver() { func (this *SeasonPagoda) TimerSeasonStar() { this.module.Debugf("TimerSeasonStar:%d", time.Now().Unix()) } + +// 测试用 后面删 +func (this *SeasonPagoda) TestFunc() { + // newData1 := &pb.DBSeasonPagoda{ + // Id: primitive.NewObjectID().Hex(), + // Uid: "sdsdassd", + // PagodaId: 1, + // Reward: map[int32]bool{}, + // Type: 201, + // } + // if conn, err := db.Cross(); err == nil { + // rst, err := conn.Mgo.InsertOne(comm.TableSeasonPagoda, newData) + + // fmt.Printf("%v,%v", rst, err) + // } + // _data := this.GetSeasonLoop(2) + // this.module.Debugf("%v", _data) + // for i := 0; i < 10000; i++ { + // this.CreatTestData(i) + // } + + // if conn, err := db.Cross(); err == nil { + // rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}) + // server := &pb.DBServerData{} + // rst.Decode(server) + // fmt.Printf("%v", server) + // } + + // newData := &pb.DBPagodaRecord{ + // Id: primitive.NewObjectID().Hex(), + // Uid: "sdsd", + // PagodaId: 1, + // Type: 2, + // Nickname: "userinfo.Name", + // Icon: "", // icon 暂无 + // Lv: 12, + // CostTime: 12000, + // } + // // 数据写到跨服中 + // if !db.IsCross() { + // if conn, err := db.Cross(); err == nil { + // conn.Mgo.InsertOne(comm.TableSeasonRecord, newData) + // } + // } + //this.TimerSeasonOver() +} From 574178dfc6b770c04a7aa2e2a88251860bf428c9 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 24 Oct 2022 10:26:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=BC=80=E6=9C=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/timer/season.go | 13 ------------- services/worker/main.go | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/modules/timer/season.go b/modules/timer/season.go index bfdaab0d6..81f1a606f 100644 --- a/modules/timer/season.go +++ b/modules/timer/season.go @@ -49,19 +49,6 @@ func (this *SeasonPagoda) Start() (err error) { cron.AddFunc("0 0 23 L * ?", this.TimerSeasonOver) //每月最后一天23点执行一次 cron.AddFunc("0 0 5 /* * ?", this.TimerSeasonStar) //每月第一天5点执行一次 - newData := &pb.DBPagoda{ - Id: primitive.NewObjectID().Hex(), - Uid: "sdsd", - PagodaId: 2, - Reward: map[int32]bool{}, - Type: 101, - } - if conn, err := db.Cross(); err == nil { - rst, _ := conn.Mgo.InsertOne(comm.TableSeasonPagoda, newData) - - fmt.Printf("%v", rst) - } - return } func (this *SeasonPagoda) CreatTestData(index int) { diff --git a/services/worker/main.go b/services/worker/main.go index f5eec88e5..f8f125255 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -129,7 +129,7 @@ func (this *Service) InitSys() { // } _len, err1 := model.DB.CountDocuments(comm.TableServerData, bson.M{}) - if err1 != nil && _len > 0 { + if err1 == nil && _len == 0 { fmt.Printf("%v,%v", _len, err1) server := &pb.DBServerData{ Id: primitive.NewObjectID().Hex(),