条件开启新增好友数量条件

This commit is contained in:
meixiongfeng 2023-06-30 11:47:33 +08:00
parent dde670cbab
commit 32701a664c
5 changed files with 135 additions and 15 deletions

View File

@ -334,6 +334,7 @@ const ( //Rpc
Rpc_ModuleCaravanSettlement core.Rpc_Key = "Rpc_ModuleCaravanSettlement" //商队比赛结算信息
Rpc_ModuleBuriedTrigger core.Rpc_Key = "Rpc_ModuleBuriedTrigger" //埋点跨服触发通知
Rpc_OpendCond core.Rpc_Key = "Rpc_OpendCond"
)
// 事件类型定义处
@ -350,7 +351,7 @@ const (
EventOpenCond core.Event_Key = "event_open_cond" //功能开放事件
EventBuriedComplete core.Event_Key = "event_buried_complete" //埋点系统条件完成事件批处理接口 接口样例 func(uid string,conids []int32)
EventFriendChange core.Event_Key = "event_friend_change" //加好友
EventFriendChange core.Event_Key = "event_friend_change" //加好友
)
const (

View File

@ -35,6 +35,8 @@ type (
CheckLvUpCond(session IUserSession, lv int32)
CheckTaskCond(session IUserSession, id int32)
CheckMlineCond(session IUserSession, id int32)
CheckFriendCond(session IUserSession, id int32)
// 查询opencond 配置
CheckOpenCondCfgById(uid string, id string) (bOpen bool, errdata *pb.ErrorData)
}

View File

@ -18,10 +18,11 @@ type configureComp struct {
modules.MCompConfigure
module *ModuleSys
hlock sync.RWMutex
maplv map[int32][]string // 监听等级大于1 的配置
maptask map[int32][]string
mapmline map[int32][]string
hlock sync.RWMutex
maplv map[int32][]string // 监听等级大于1 的配置
maptask map[int32][]string
mapmline map[int32][]string
mapfriend map[int32][]string // 好友数量
}
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
@ -41,6 +42,7 @@ func (this *configureComp) LoadCondConfig() {
this.maplv = make(map[int32][]string, 0)
this.maptask = make(map[int32][]string, 0)
this.mapmline = make(map[int32][]string, 0)
this.mapfriend = make(map[int32][]string, 0)
defer this.hlock.Unlock()
for _, v := range data.GetDataList() {
for _, v1 := range v.Main {
@ -54,6 +56,9 @@ func (this *configureComp) LoadCondConfig() {
if v1.Key == 2 && v1.Param > 1 {
this.mapmline[v1.Param] = append(this.mapmline[v1.Param], v.Id)
}
if v1.Key == 4 && v1.Param > 1 {
this.mapfriend[v1.Param] = append(this.mapfriend[v1.Param], v.Id)
}
}
}
}
@ -72,6 +77,10 @@ func (this *configureComp) getOpencondMline(id int32) []string {
func (this *configureComp) getOpencondTask(id int32) []string {
return this.maptask[id]
}
func (this *configureComp) getFriendTask(id int32) []string {
return this.mapfriend[id]
}
func (this *configureComp) getOpencondCfg() (data *cfg.GameOpencond, err error) {
var (
v interface{}

View File

@ -1,11 +1,14 @@
package sys
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"time"
)
var _ comm.ISys = (*ModuleSys)(nil)
@ -14,8 +17,8 @@ type ModuleSys struct {
modules.ModuleBase
api *apiComp
configure *configureComp
modelSys *ModelSys
service base.IRPCXService
modelSys *ModelSys
}
func NewModule() core.IModule {
@ -29,8 +32,16 @@ func (this *ModuleSys) OnInstallComp() {
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
}
//模块初始化
func (this *ModuleSys) 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
}
func (this *ModuleSys) Start() (err error) {
err = this.ModuleBase.Start()
this.service.RegisterFunctionName(string(comm.Rpc_OpendCond), this.OpenCond)
return
}
@ -51,13 +62,32 @@ func (this *ModuleSys) CheckLvUpCond(session comm.IUserSession, lv int32) {
this.AutoActivate(session, cond)
}
}
func (this *ModuleSys) CheckMlineCond(session comm.IUserSession, id int32) {
if cond := this.configure.getOpencondMline(id); len(cond) > 0 {
this.AutoActivate(session, cond)
}
}
func (this *ModuleSys) CheckTaskCond(session comm.IUserSession, id int32) {
if cond := this.configure.getOpencondTask(id); len(cond) > 0 {
func (this *ModuleSys) CheckFriendCond(session comm.IUserSession, id int32) {
if cond := this.configure.getFriendTask(id); len(cond) > 0 {
this.AutoActivate(session, cond)
}
}
func (this *ModuleSys) CheckTaskCond(session comm.IUserSession, num int32) {
if cond := this.configure.getOpencondTask(num); len(cond) > 0 {
// 通知本服
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
_, err := this.service.RpcGo(
ctx,
comm.Service_Worker,
string(comm.Rpc_OpendCond),
&pb.RPCFriendNumReq{Uid: session.GetUserId(), Cond: cond},
nil)
if err != nil {
this.Errorln(err)
return
}
this.AutoActivate(session, cond)
}
}
@ -113,3 +143,10 @@ func (this *ModuleSys) CheckOpenCondCfgById(uid string, id string) (bOpen bool,
}
return
}
func (this *ModuleSys) OpenCond(ctx context.Context, req *pb.RPCFriendNumReq, resp interface{}) (err error) {
if session, ok := this.GetUserSession(req.Uid); ok {
this.AutoActivate(session, req.Cond)
}
return
}

View File

@ -2459,6 +2459,61 @@ func (x *FriendQiecuonotifyPush) GetNotifyType() int32 {
return 0
}
type RPCFriendNumReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"`
Cond []string `protobuf:"bytes,2,rep,name=cond,proto3" json:"cond"`
}
func (x *RPCFriendNumReq) Reset() {
*x = RPCFriendNumReq{}
if protoimpl.UnsafeEnabled {
mi := &file_friend_friend_msg_proto_msgTypes[49]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RPCFriendNumReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RPCFriendNumReq) ProtoMessage() {}
func (x *RPCFriendNumReq) ProtoReflect() protoreflect.Message {
mi := &file_friend_friend_msg_proto_msgTypes[49]
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 RPCFriendNumReq.ProtoReflect.Descriptor instead.
func (*RPCFriendNumReq) Descriptor() ([]byte, []int) {
return file_friend_friend_msg_proto_rawDescGZIP(), []int{49}
}
func (x *RPCFriendNumReq) GetUid() string {
if x != nil {
return x.Uid
}
return ""
}
func (x *RPCFriendNumReq) GetCond() []string {
if x != nil {
return x.Cond
}
return nil
}
var File_friend_friend_msg_proto protoreflect.FileDescriptor
var file_friend_friend_msg_proto_rawDesc = []byte{
@ -2640,8 +2695,11 @@ var file_friend_friend_msg_proto_rawDesc = []byte{
0x79, 0x50, 0x75, 0x73, 0x68, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x6e, 0x6f, 0x74, 0x69, 0x66,
0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6e, 0x6f, 0x74,
0x69, 0x66, 0x79, 0x54, 0x79, 0x70, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x69, 0x66, 0x79, 0x54, 0x79, 0x70, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x46, 0x72,
0x69, 0x65, 0x6e, 0x64, 0x4e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04,
0x63, 0x6f, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x6e, 0x64,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -2656,7 +2714,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, 49)
var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 50)
var file_friend_friend_msg_proto_goTypes = []interface{}{
(*FriendBase)(nil), // 0: FriendBase
(*FriendListReq)(nil), // 1: FriendListReq
@ -2707,7 +2765,8 @@ var file_friend_friend_msg_proto_goTypes = []interface{}{
(*FriendStopReq)(nil), // 46: FriendStopReq
(*FriendStopResp)(nil), // 47: FriendStopResp
(*FriendQiecuonotifyPush)(nil), // 48: FriendQiecuonotifyPush
(*AssistRecord)(nil), // 49: AssistRecord
(*RPCFriendNumReq)(nil), // 49: RPCFriendNumReq
(*AssistRecord)(nil), // 50: AssistRecord
}
var file_friend_friend_msg_proto_depIdxs = []int32{
0, // 0: FriendListResp.list:type_name -> FriendBase
@ -2717,7 +2776,7 @@ 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
49, // 7: FriendAssistlistResp.record:type_name -> AssistRecord
50, // 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
@ -3322,6 +3381,18 @@ func file_friend_friend_msg_proto_init() {
return nil
}
}
file_friend_friend_msg_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RPCFriendNumReq); 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{
@ -3329,7 +3400,7 @@ func file_friend_friend_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_friend_friend_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 49,
NumMessages: 50,
NumExtensions: 0,
NumServices: 0,
},