From 959775f19c58e948636470fa96190ed25aaedec4 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 18 Aug 2023 10:41:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=9B=B4=E6=96=B0=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 2 ++ modules/activity/module.go | 13 +++++++-- modules/web/api_activitynotify.go | 45 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 modules/web/api_activitynotify.go diff --git a/comm/const.go b/comm/const.go index 28c2a7c73..e8a691da0 100644 --- a/comm/const.go +++ b/comm/const.go @@ -427,6 +427,8 @@ const ( //Rpc // 石阵秘境结算 Rpc_ModuleStoneBossSettlement core.Rpc_Key = "Rpc_ModuleStoneBossSettlement" + + Rpc_Activity core.Rpc_Key = "Rpc_Activity" ) // 事件类型定义处 diff --git a/modules/activity/module.go b/modules/activity/module.go index 6c82c1bc9..c96eaf30b 100644 --- a/modules/activity/module.go +++ b/modules/activity/module.go @@ -1,8 +1,10 @@ package activity import ( + "context" "fmt" "go_dreamfactory/comm" + "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/event" "go_dreamfactory/modules" @@ -18,7 +20,7 @@ type Activity struct { api *apiComp configure *configureComp - service core.IService + service base.IRPCXService modelhdList *modelHdList modelhdData *modelhdData @@ -40,7 +42,7 @@ func (this *Activity) GetType() core.M_Modules { func (this *Activity) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) - this.service = service + this.service = service.(base.IRPCXService) // ticker := time.NewTicker(time.Second * 10) // go func() { @@ -56,6 +58,8 @@ func (this *Activity) Init(service core.IService, module core.IModule, options c } func (this *Activity) Start() (err error) { err = this.ModuleBase.Start() + + this.service.RegisterFunctionName(string(comm.Rpc_Activity), this.Rpc_Activity) var module core.IModule if module, err = this.service.GetModule(comm.ModuleMail); err != nil { return @@ -427,3 +431,8 @@ func (this *Activity) GetHdData(session comm.IUserSession, oids []string) (resul } return } + +func (this *Activity) Rpc_Activity(ctx context.Context, args string) (err error) { + this.modelhdList.LoadActivityData() + return +} diff --git a/modules/web/api_activitynotify.go b/modules/web/api_activitynotify.go new file mode 100644 index 000000000..23ac744e2 --- /dev/null +++ b/modules/web/api_activitynotify.go @@ -0,0 +1,45 @@ +package web + +import ( + "context" + "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/gin/engine" + "go_dreamfactory/pb" + "net/http" +) + +// 活动通知 +type ActivityNotifyReq struct { + Id string `json:"_id"` // oid +} + +//创建邮件 +func (this *Api_Comp) ActivityNotify(c *engine.Context) { + + req := &ActivityNotifyReq{} + err := c.BindJSON(&req) + this.module.Debugf("ActivityNotify:%+v err:%v", req, err) + var ( + errdata *pb.ErrorData + data interface{} + ) + + defer c.JSON(http.StatusOK, &Respond{Code: errdata.Code, Message: errdata.Message, Data: data}) + + if _, err = this.module.service.RpcGo( + context.Background(), + comm.Service_Worker, + string(comm.Rpc_Activity), + req.Id, nil); err != nil { + this.module.Errorln(err) + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_RpcFuncExecutionError, + Title: pb.ErrorCode_RpcFuncExecutionError.ToString(), + } + return + } + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_Success, + Title: pb.ErrorCode_Success.ToString(), + } +}