美食馆获取一些其他玩家信息

This commit is contained in:
meixiongfeng 2022-08-24 18:13:43 +08:00
parent 8da3d9e128
commit 43ff5abd83
4 changed files with 168 additions and 27 deletions

View File

@ -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
}

View File

@ -11,6 +11,7 @@ const (
SmithyDeskSkillLvResp = "deskskilllv"
SmithyStoveSkillLvResp = "stovekilllv"
SmithyGetRewardResp = "getreward"
SmithyGetRandUserResp = "getranduser"
)
type apiComp struct {

View File

@ -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
}

View File

@ -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,
},