From 43ff5abd83cc26bef090d4f03777f4d9253aacd3 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 24 Aug 2022 18:13:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=8E=E9=A3=9F=E9=A6=86=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=85=B6=E4=BB=96=E7=8E=A9=E5=AE=B6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pagoda/api_getlist.go | 15 ---- modules/smithy/api.go | 1 + modules/smithy/api_getranduser.go | 40 +++++++++ pb/smithy_msg.pb.go | 139 +++++++++++++++++++++++++++--- 4 files changed, 168 insertions(+), 27 deletions(-) create mode 100644 modules/smithy/api_getranduser.go diff --git a/modules/pagoda/api_getlist.go b/modules/pagoda/api_getlist.go index 78ff70456..ab11f559e 100644 --- a/modules/pagoda/api_getlist.go +++ b/modules/pagoda/api_getlist.go @@ -44,20 +44,5 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.PagodaGetListReq list.PagodaId = season.PagodaId list.Type = season.Type } - - // cu, err := this.module.ModuleUser.UserOnlineList() - // if err != nil { - // code = pb.ErrorCode_DBError - // return - // } - // var randOnlineUsers []string - // if len(cu) > 5 { - // randArr := utils.Numbers(0, len(cu), 5) - // for _, v := range randArr { - // if cu[v] != nil { - // randOnlineUsers = append(randOnlineUsers, cu[v].Uid) - // } - // } - // } return } diff --git a/modules/smithy/api.go b/modules/smithy/api.go index 384255605..a633bd6de 100644 --- a/modules/smithy/api.go +++ b/modules/smithy/api.go @@ -11,6 +11,7 @@ const ( SmithyDeskSkillLvResp = "deskskilllv" SmithyStoveSkillLvResp = "stovekilllv" SmithyGetRewardResp = "getreward" + SmithyGetRandUserResp = "getranduser" ) type apiComp struct { diff --git a/modules/smithy/api_getranduser.go b/modules/smithy/api_getranduser.go new file mode 100644 index 000000000..7840b5947 --- /dev/null +++ b/modules/smithy/api_getranduser.go @@ -0,0 +1,40 @@ +package smithy + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "go_dreamfactory/utils" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) GetRandUserCheck(session comm.IUserSession, req *pb.SmithyGetRandUserReq) (code pb.ErrorCode) { + + return +} + +/// 获取一些玩家数据 +func (this *apiComp) GetRandUser(session comm.IUserSession, req *pb.SmithyGetRandUserReq) (code pb.ErrorCode, data proto.Message) { + + code = this.GetRandUserCheck(session, req) + if code != pb.ErrorCode_Success { + return // 参数校验失败直接返回 + } + cu, err := this.module.ModuleUser.UserOnlineList() + if err != nil { + code = pb.ErrorCode_DBError + return + } + var randOnlineUsers []string + if len(cu) > 5 { + randArr := utils.Numbers(0, len(cu), 5) + for _, v := range randArr { + if cu[v] != nil { + randOnlineUsers = append(randOnlineUsers, cu[v].Uid) + } + } + } + session.SendMsg(string(this.module.GetType()), SmithyGetRandUserResp, &pb.SmithyGetRandUserResp{User: randOnlineUsers}) + return +} diff --git a/pb/smithy_msg.pb.go b/pb/smithy_msg.pb.go index ad169dce4..668b38508 100644 --- a/pb/smithy_msg.pb.go +++ b/pb/smithy_msg.pb.go @@ -469,6 +469,91 @@ func (x *SmithyStoveSkillLvResp) GetData() *DBSmithy { return nil } +type SmithyGetRandUserReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *SmithyGetRandUserReq) Reset() { + *x = SmithyGetRandUserReq{} + if protoimpl.UnsafeEnabled { + mi := &file_smithy_smithy_msg_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SmithyGetRandUserReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SmithyGetRandUserReq) ProtoMessage() {} + +func (x *SmithyGetRandUserReq) ProtoReflect() protoreflect.Message { + mi := &file_smithy_smithy_msg_proto_msgTypes[10] + 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 SmithyGetRandUserReq.ProtoReflect.Descriptor instead. +func (*SmithyGetRandUserReq) Descriptor() ([]byte, []int) { + return file_smithy_smithy_msg_proto_rawDescGZIP(), []int{10} +} + +type SmithyGetRandUserResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + User []string `protobuf:"bytes,1,rep,name=user,proto3" json:"user"` +} + +func (x *SmithyGetRandUserResp) Reset() { + *x = SmithyGetRandUserResp{} + if protoimpl.UnsafeEnabled { + mi := &file_smithy_smithy_msg_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SmithyGetRandUserResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SmithyGetRandUserResp) ProtoMessage() {} + +func (x *SmithyGetRandUserResp) ProtoReflect() protoreflect.Message { + mi := &file_smithy_smithy_msg_proto_msgTypes[11] + 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 SmithyGetRandUserResp.ProtoReflect.Descriptor instead. +func (*SmithyGetRandUserResp) Descriptor() ([]byte, []int) { + return file_smithy_smithy_msg_proto_rawDescGZIP(), []int{11} +} + +func (x *SmithyGetRandUserResp) GetUser() []string { + if x != nil { + return x.User + } + return nil +} + var File_smithy_smithy_msg_proto protoreflect.FileDescriptor var file_smithy_smithy_msg_proto_rawDesc = []byte{ @@ -503,8 +588,12 @@ var file_smithy_smithy_msg_proto_rawDesc = []byte{ 0x16, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x53, 0x74, 0x6f, 0x76, 0x65, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x4c, 0x76, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x16, 0x0a, 0x14, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, + 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x22, 0x2b, + 0x0a, 0x15, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x47, 0x65, 0x74, 0x52, 0x61, 0x6e, 0x64, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -519,7 +608,7 @@ func file_smithy_smithy_msg_proto_rawDescGZIP() []byte { return file_smithy_smithy_msg_proto_rawDescData } -var file_smithy_smithy_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_smithy_smithy_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_smithy_smithy_msg_proto_goTypes = []interface{}{ (*SmithyGetListReq)(nil), // 0: SmithyGetListReq (*SmithyGetListResp)(nil), // 1: SmithyGetListResp @@ -531,16 +620,18 @@ var file_smithy_smithy_msg_proto_goTypes = []interface{}{ (*SmithyDeskSkillLvResp)(nil), // 7: SmithyDeskSkillLvResp (*SmithyStoveSkillLvReq)(nil), // 8: SmithyStoveSkillLvReq (*SmithyStoveSkillLvResp)(nil), // 9: SmithyStoveSkillLvResp - (*DBSmithy)(nil), // 10: DBSmithy - (*OrderClang)(nil), // 11: OrderClang + (*SmithyGetRandUserReq)(nil), // 10: SmithyGetRandUserReq + (*SmithyGetRandUserResp)(nil), // 11: SmithyGetRandUserResp + (*DBSmithy)(nil), // 12: DBSmithy + (*OrderClang)(nil), // 13: OrderClang } var file_smithy_smithy_msg_proto_depIdxs = []int32{ - 10, // 0: SmithyGetListResp.data:type_name -> DBSmithy - 11, // 1: SmithyCreateOrderReq.order:type_name -> OrderClang - 10, // 2: SmithyCreateOrderResp.data:type_name -> DBSmithy - 10, // 3: SmithyGetRewardResp.data:type_name -> DBSmithy - 10, // 4: SmithyDeskSkillLvResp.data:type_name -> DBSmithy - 10, // 5: SmithyStoveSkillLvResp.data:type_name -> DBSmithy + 12, // 0: SmithyGetListResp.data:type_name -> DBSmithy + 13, // 1: SmithyCreateOrderReq.order:type_name -> OrderClang + 12, // 2: SmithyCreateOrderResp.data:type_name -> DBSmithy + 12, // 3: SmithyGetRewardResp.data:type_name -> DBSmithy + 12, // 4: SmithyDeskSkillLvResp.data:type_name -> DBSmithy + 12, // 5: SmithyStoveSkillLvResp.data:type_name -> DBSmithy 6, // [6:6] is the sub-list for method output_type 6, // [6:6] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name @@ -675,6 +766,30 @@ func file_smithy_smithy_msg_proto_init() { return nil } } + file_smithy_smithy_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SmithyGetRandUserReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_smithy_smithy_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SmithyGetRandUserResp); 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{ @@ -682,7 +797,7 @@ func file_smithy_smithy_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_smithy_smithy_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 12, NumExtensions: 0, NumServices: 0, },