diff --git a/comm/const.go b/comm/const.go index 737f4c4fb..1f793be15 100644 --- a/comm/const.go +++ b/comm/const.go @@ -103,6 +103,8 @@ const ( TableGourmet = "gourmet" // 随机任务 TableRtask = "rtask" + ///爬塔排行 + TablePagodaRank = "pagodarank" ) //RPC服务接口定义处 diff --git a/modules/pagoda/api_challenge.go b/modules/pagoda/api_challenge.go index 00bf7c239..f0ac2ea03 100644 --- a/modules/pagoda/api_challenge.go +++ b/modules/pagoda/api_challenge.go @@ -28,7 +28,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.PagodaChalleng code = pb.ErrorCode_PagodaNotFound return } - cfg := this.module.configure.GetPagodaconfig(req.LevelID) + cfg := this.module.configure.GetPagodaConfigData(req.PagodaType, req.LevelID) if cfg == nil { code = pb.ErrorCode_PagodaNotFound return diff --git a/modules/pagoda/model_rank.go b/modules/pagoda/model_rank.go new file mode 100644 index 000000000..c40130d1d --- /dev/null +++ b/modules/pagoda/model_rank.go @@ -0,0 +1,48 @@ +package pagoda + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" + "go_dreamfactory/pb" +) + +type ModelRank struct { + modules.MCompModel + moduleUser *Pagoda +} + +func (this *ModelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.TableName = comm.TablePagodaRank + err = this.MCompModel.Init(service, module, comp, options) + this.moduleUser = module.(*Pagoda) + return +} + +//获取用户 +func (this *ModelRank) getUserSession(uid string) (cuser *pb.CacheUser) { + cuser = &pb.CacheUser{} + if err := this.Get(uid, cuser); err != nil { + this.moduleUser.Errorf("GetUserSession err:%v", err) + return + } + return +} + +//获取用户通过扩展表 +// func (this *ModelRank) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) { +// result = &pb.DBUserExpand{} +// if err = this.moduleUser.modelExpand.Get(uid, result); err != nil && redis.RedisNil != err { +// return +// } +// err = nil +// return result, err +// } + +// func (this *ModelRank) ChangeUserExpand(uid string, value map[string]interface{}) (err error) { +// if len(value) == 0 { +// return nil +// } +// return this.moduleUser.modelExpand.Change(uid, value) + +// } diff --git a/pb/pagoda_db.pb.go b/pb/pagoda_db.pb.go index 51a3f6fbf..703d2fa4c 100644 --- a/pb/pagoda_db.pb.go +++ b/pb/pagoda_db.pb.go @@ -29,6 +29,7 @@ type DBPagoda struct { Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID PagodaId int32 `protobuf:"varint,3,opt,name=pagodaId,proto3" json:"pagodaId" bson:"pagodaId"` //塔层 Reward map[int32]bool `protobuf:"bytes,4,rep,name=reward,proto3" json:"reward" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 是否领奖 + Type int32 `protobuf:"varint,5,opt,name=type,proto3" json:"type"` } func (x *DBPagoda) Reset() { @@ -91,11 +92,105 @@ func (x *DBPagoda) GetReward() map[int32]bool { return nil } +func (x *DBPagoda) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +type DBPagodaRank struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + PagodaId int32 `protobuf:"varint,3,opt,name=pagodaId,proto3" json:"pagodaId" bson:"pagodaId"` //塔层 + Type int32 `protobuf:"varint,4,opt,name=type,proto3" json:"type"` // 塔类型 + Nickname string `protobuf:"bytes,5,opt,name=nickname,proto3" json:"nickname"` // 昵称 + Icon string `protobuf:"bytes,6,opt,name=icon,proto3" json:"icon"` // 头像 +} + +func (x *DBPagodaRank) Reset() { + *x = DBPagodaRank{} + if protoimpl.UnsafeEnabled { + mi := &file_pagoda_pagoda_db_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBPagodaRank) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBPagodaRank) ProtoMessage() {} + +func (x *DBPagodaRank) ProtoReflect() protoreflect.Message { + mi := &file_pagoda_pagoda_db_proto_msgTypes[1] + 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 DBPagodaRank.ProtoReflect.Descriptor instead. +func (*DBPagodaRank) Descriptor() ([]byte, []int) { + return file_pagoda_pagoda_db_proto_rawDescGZIP(), []int{1} +} + +func (x *DBPagodaRank) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBPagodaRank) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *DBPagodaRank) GetPagodaId() int32 { + if x != nil { + return x.PagodaId + } + return 0 +} + +func (x *DBPagodaRank) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *DBPagodaRank) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +func (x *DBPagodaRank) GetIcon() string { + if x != nil { + return x.Icon + } + return "" +} + var File_pagoda_pagoda_db_proto protoreflect.FileDescriptor var file_pagoda_pagoda_db_proto_rawDesc = []byte{ 0x0a, 0x16, 0x70, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x2f, 0x70, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x5f, - 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x01, 0x0a, 0x08, 0x44, 0x42, 0x50, + 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc6, 0x01, 0x0a, 0x08, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x6f, 0x64, @@ -103,11 +198,22 @@ var file_pagoda_pagoda_db_proto_rawDesc = []byte{ 0x61, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x06, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x2e, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x77, 0x61, - 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x90, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, + 0x6e, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x49, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x49, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x69, 0x63, 0x6f, 0x6e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -122,13 +228,14 @@ func file_pagoda_pagoda_db_proto_rawDescGZIP() []byte { return file_pagoda_pagoda_db_proto_rawDescData } -var file_pagoda_pagoda_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_pagoda_pagoda_db_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_pagoda_pagoda_db_proto_goTypes = []interface{}{ - (*DBPagoda)(nil), // 0: DBPagoda - nil, // 1: DBPagoda.RewardEntry + (*DBPagoda)(nil), // 0: DBPagoda + (*DBPagodaRank)(nil), // 1: DBPagodaRank + nil, // 2: DBPagoda.RewardEntry } var file_pagoda_pagoda_db_proto_depIdxs = []int32{ - 1, // 0: DBPagoda.reward:type_name -> DBPagoda.RewardEntry + 2, // 0: DBPagoda.reward:type_name -> DBPagoda.RewardEntry 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -154,6 +261,18 @@ func file_pagoda_pagoda_db_proto_init() { return nil } } + file_pagoda_pagoda_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBPagodaRank); 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{ @@ -161,7 +280,7 @@ func file_pagoda_pagoda_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pagoda_pagoda_db_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/pagoda_msg.pb.go b/pb/pagoda_msg.pb.go index 08be8fbe6..babbfe6a5 100644 --- a/pb/pagoda_msg.pb.go +++ b/pb/pagoda_msg.pb.go @@ -305,6 +305,92 @@ func (x *PagodaChallengeResp) GetData() *DBPagoda { return nil } +// 排行榜 +type PagodaRankListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PagodaRankListReq) Reset() { + *x = PagodaRankListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_pagoda_pagoda_msg_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PagodaRankListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PagodaRankListReq) ProtoMessage() {} + +func (x *PagodaRankListReq) ProtoReflect() protoreflect.Message { + mi := &file_pagoda_pagoda_msg_proto_msgTypes[6] + 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 PagodaRankListReq.ProtoReflect.Descriptor instead. +func (*PagodaRankListReq) Descriptor() ([]byte, []int) { + return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{6} +} + +type PagodaRankListResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ranks []*DBPagodaRank `protobuf:"bytes,1,rep,name=ranks,proto3" json:"ranks"` +} + +func (x *PagodaRankListResp) Reset() { + *x = PagodaRankListResp{} + if protoimpl.UnsafeEnabled { + mi := &file_pagoda_pagoda_msg_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PagodaRankListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PagodaRankListResp) ProtoMessage() {} + +func (x *PagodaRankListResp) ProtoReflect() protoreflect.Message { + mi := &file_pagoda_pagoda_msg_proto_msgTypes[7] + 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 PagodaRankListResp.ProtoReflect.Descriptor instead. +func (*PagodaRankListResp) Descriptor() ([]byte, []int) { + return file_pagoda_pagoda_msg_proto_rawDescGZIP(), []int{7} +} + +func (x *PagodaRankListResp) GetRanks() []*DBPagodaRank { + if x != nil { + return x.Ranks + } + return nil +} + var File_pagoda_pagoda_msg_proto protoreflect.FileDescriptor var file_pagoda_pagoda_msg_proto_rawDesc = []byte{ @@ -329,7 +415,12 @@ var file_pagoda_pagoda_msg_proto_rawDesc = []byte{ 0x61, 0x54, 0x79, 0x70, 0x65, 0x22, 0x34, 0x0a, 0x13, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x44, 0x42, 0x50, - 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x13, 0x0a, 0x11, 0x50, + 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, + 0x22, 0x39, 0x0a, 0x12, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, 0x52, 0x61, 0x6e, 0x6b, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x67, 0x6f, 0x64, 0x61, + 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -345,7 +436,7 @@ func file_pagoda_pagoda_msg_proto_rawDescGZIP() []byte { return file_pagoda_pagoda_msg_proto_rawDescData } -var file_pagoda_pagoda_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_pagoda_pagoda_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{ (*PagodaGetListReq)(nil), // 0: PagodaGetListReq (*PagodaGetListResp)(nil), // 1: PagodaGetListResp @@ -353,17 +444,21 @@ var file_pagoda_pagoda_msg_proto_goTypes = []interface{}{ (*PagodaGetRewardResp)(nil), // 3: PagodaGetRewardResp (*PagodaChallengeReq)(nil), // 4: PagodaChallengeReq (*PagodaChallengeResp)(nil), // 5: PagodaChallengeResp - (*DBPagoda)(nil), // 6: DBPagoda + (*PagodaRankListReq)(nil), // 6: PagodaRankListReq + (*PagodaRankListResp)(nil), // 7: PagodaRankListResp + (*DBPagoda)(nil), // 8: DBPagoda + (*DBPagodaRank)(nil), // 9: DBPagodaRank } var file_pagoda_pagoda_msg_proto_depIdxs = []int32{ - 6, // 0: PagodaGetListResp.data:type_name -> DBPagoda - 6, // 1: PagodaGetRewardResp.data:type_name -> DBPagoda - 6, // 2: PagodaChallengeResp.data:type_name -> DBPagoda - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 8, // 0: PagodaGetListResp.data:type_name -> DBPagoda + 8, // 1: PagodaGetRewardResp.data:type_name -> DBPagoda + 8, // 2: PagodaChallengeResp.data:type_name -> DBPagoda + 9, // 3: PagodaRankListResp.ranks:type_name -> DBPagodaRank + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_pagoda_pagoda_msg_proto_init() } @@ -445,6 +540,30 @@ func file_pagoda_pagoda_msg_proto_init() { return nil } } + file_pagoda_pagoda_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PagodaRankListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pagoda_pagoda_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PagodaRankListResp); 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{ @@ -452,7 +571,7 @@ func file_pagoda_pagoda_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pagoda_pagoda_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 0, },