From 3b8d6601e9f56038df3284719b1563539182e256 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 17 Oct 2022 14:28:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=85=B6=E5=AE=83=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/user/api_battlerecord.go | 22 ++++-- modules/user/model_cross_session.go | 2 + modules/user/module.go | 3 + pb/user_msg.pb.go | 105 +++++++++++++++++----------- 4 files changed, 87 insertions(+), 45 deletions(-) create mode 100644 modules/user/model_cross_session.go diff --git a/modules/user/api_battlerecord.go b/modules/user/api_battlerecord.go index 9228d2534..5e4687d39 100644 --- a/modules/user/api_battlerecord.go +++ b/modules/user/api_battlerecord.go @@ -13,9 +13,23 @@ func (this *apiComp) BattlerecordCheck(session comm.IUserSession, req *pb.UserBa } func (this *apiComp) Battlerecord(session comm.IUserSession, req *pb.UserBattlerecordReq) (code pb.ErrorCode, data proto.Message) { + var uid string + if req.Uid == "" { + uid = session.GetUserId() + } else { + uid = req.Uid + } + + user := this.module.GetUser(uid) + userEx, err := this.module.GetUserExpand(uid) + if err != nil { + code = pb.ErrorCode_UserExpandNull + return + } rsp := &pb.UserBattlerecordResp{ - Uid: session.GetUserId(), + Data: user, + Ex: userEx, } // 心魔塔 @@ -26,7 +40,7 @@ func (this *apiComp) Battlerecord(session comm.IUserSession, req *pb.UserBattler } if b, y := iPagoda.(comm.IPagoda); y { - dr := b.CheckUserBasePagodaInfo(session.GetUserId()) + dr := b.CheckUserBasePagodaInfo(uid) if dr != nil { rsp.PagodaRecord = dr } @@ -40,7 +54,7 @@ func (this *apiComp) Battlerecord(session comm.IUserSession, req *pb.UserBattler } if b, y := ihunting.(comm.IHunting); y { - if dr := b.CheckUserBaseHuntingInfo(session.GetUserId()); dr != nil { + if dr := b.CheckUserBaseHuntingInfo(uid); dr != nil { rsp.HuntingRecord = dr } } @@ -53,7 +67,7 @@ func (this *apiComp) Battlerecord(session comm.IUserSession, req *pb.UserBattler } if b, y := iviking.(comm.IViking); y { - if dr := b.CheckUserBaseVikingInfo(session.GetUserId()); dr != nil { + if dr := b.CheckUserBaseVikingInfo(uid); dr != nil { rsp.VikingRecord = dr } } diff --git a/modules/user/model_cross_session.go b/modules/user/model_cross_session.go new file mode 100644 index 000000000..cb301e23e --- /dev/null +++ b/modules/user/model_cross_session.go @@ -0,0 +1,2 @@ +package user + diff --git a/modules/user/module.go b/modules/user/module.go index 7facee8ff..514ca63b4 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/sys/db" + "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/log" @@ -29,6 +30,7 @@ type User struct { modelSetting *ModelSetting modelExpand *ModelExpand configure *modules.MCompConfigure + service base.IRPCXService } func (this *User) GetType() core.M_Modules { @@ -37,6 +39,7 @@ func (this *User) GetType() core.M_Modules { func (this *User) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) + this.service = service.(base.IRPCXService) return } diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index 1bda7c1be..10081ed9f 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -1667,6 +1667,8 @@ type UserBattlerecordReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` } func (x *UserBattlerecordReq) Reset() { @@ -1701,15 +1703,23 @@ func (*UserBattlerecordReq) Descriptor() ([]byte, []int) { return file_user_user_msg_proto_rawDescGZIP(), []int{33} } +func (x *UserBattlerecordReq) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + type UserBattlerecordResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` - PagodaRecord *DBPagodaRecord `protobuf:"bytes,2,opt,name=pagodaRecord,proto3" json:"pagodaRecord"` //爬塔战斗记录 - HuntingRecord []*DBHuntingRank `protobuf:"bytes,3,rep,name=huntingRecord,proto3" json:"huntingRecord"` //狩猎战斗记录 - VikingRecord []*DBVikingRank `protobuf:"bytes,4,rep,name=vikingRecord,proto3" json:"vikingRecord"` //维京远征战斗记录 + Data *DBUser `protobuf:"bytes,1,opt,name=data,proto3" json:"data"` + Ex *DBUserExpand `protobuf:"bytes,2,opt,name=ex,proto3" json:"ex"` //用户扩展 + PagodaRecord *DBPagodaRecord `protobuf:"bytes,3,opt,name=pagodaRecord,proto3" json:"pagodaRecord"` //爬塔战斗记录 + HuntingRecord []*DBHuntingRank `protobuf:"bytes,4,rep,name=huntingRecord,proto3" json:"huntingRecord"` //狩猎战斗记录 + VikingRecord []*DBVikingRank `protobuf:"bytes,5,rep,name=vikingRecord,proto3" json:"vikingRecord"` //维京远征战斗记录 } func (x *UserBattlerecordResp) Reset() { @@ -1744,11 +1754,18 @@ func (*UserBattlerecordResp) Descriptor() ([]byte, []int) { return file_user_user_msg_proto_rawDescGZIP(), []int{34} } -func (x *UserBattlerecordResp) GetUid() string { +func (x *UserBattlerecordResp) GetData() *DBUser { if x != nil { - return x.Uid + return x.Data } - return "" + return nil +} + +func (x *UserBattlerecordResp) GetEx() *DBUserExpand { + if x != nil { + return x.Ex + } + return nil } func (x *UserBattlerecordResp) GetPagodaRecord() *DBPagodaRecord { @@ -2071,32 +2088,36 @@ var file_user_user_msg_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x69, 0x67, 0x6e, 0x22, 0x26, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x73, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x69, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x42, 0x61, 0x74, 0x74, - 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x22, 0xc6, 0x01, 0x0a, 0x14, - 0x55, 0x73, 0x65, 0x72, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, - 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x33, 0x0a, 0x0c, 0x70, 0x61, 0x67, 0x6f, 0x64, 0x61, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, - 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x0c, 0x70, - 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x34, 0x0a, 0x0d, 0x68, - 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x61, - 0x6e, 0x6b, 0x52, 0x0d, 0x68, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x12, 0x31, 0x0a, 0x0c, 0x76, 0x69, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x56, 0x69, 0x6b, 0x69, - 0x6e, 0x67, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x0c, 0x76, 0x69, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x63, 0x6f, 0x72, 0x64, 0x22, 0x34, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x74, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x65, - 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, - 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x73, 0x22, 0x27, 0x0a, 0x13, 0x55, 0x73, - 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x74, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, - 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x75, 0x69, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x77, 0x74, - 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x22, 0x32, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, - 0x6f, 0x77, 0x74, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x65, - 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, - 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x03, 0x75, 0x69, 0x64, 0x22, 0x27, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x42, 0x61, 0x74, 0x74, + 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 0xf0, 0x01, + 0x0a, 0x14, 0x55, 0x73, 0x65, 0x72, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x72, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x02, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0d, 0x2e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x52, 0x02, + 0x65, 0x78, 0x12, 0x33, 0x0a, 0x0c, 0x70, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, + 0x6f, 0x64, 0x61, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x0c, 0x70, 0x61, 0x67, 0x6f, 0x64, + 0x61, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x34, 0x0a, 0x0d, 0x68, 0x75, 0x6e, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, + 0x2e, 0x44, 0x42, 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x0d, + 0x68, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x31, 0x0a, + 0x0c, 0x76, 0x69, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x56, 0x69, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x61, + 0x6e, 0x6b, 0x52, 0x0c, 0x76, 0x69, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x22, 0x34, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x74, + 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, + 0x6a, 0x49, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x68, 0x65, 0x72, 0x6f, + 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x73, 0x22, 0x27, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x74, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, + 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, + 0x11, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x77, 0x74, 0x65, 0x61, 0x6d, 0x52, + 0x65, 0x71, 0x22, 0x32, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x77, 0x74, 0x65, + 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, + 0x6a, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x68, 0x65, 0x72, 0x6f, + 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2170,14 +2191,16 @@ var file_user_user_msg_proto_depIdxs = []int32{ 42, // 5: UserLoadResp.data:type_name -> CacheUser 43, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting 43, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting - 44, // 8: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord - 45, // 9: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank - 46, // 10: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 39, // 8: UserBattlerecordResp.data:type_name -> DBUser + 40, // 9: UserBattlerecordResp.ex:type_name -> DBUserExpand + 44, // 10: UserBattlerecordResp.pagodaRecord:type_name -> DBPagodaRecord + 45, // 11: UserBattlerecordResp.huntingRecord:type_name -> DBHuntingRank + 46, // 12: UserBattlerecordResp.vikingRecord:type_name -> DBVikingRank + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_user_user_msg_proto_init() }