From 747cc25edbe82ae6de895970e3688abaa6bcc2c1 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Fri, 8 Nov 2024 11:17:47 +0800 Subject: [PATCH] by Robin at 20241108 --- app/mix/service/utilservice.go | 6 +++--- dbstruct/frontend_route.go | 6 +++--- dbstruct/notification.go | 4 ++-- library/middleware/notif_sender.go | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 5b265826..ed4dd088 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -2126,7 +2126,7 @@ func (s *Service) utilWriteNotifCancel(ctx *gin.Context, nidAccessor interfaces. notifBuilders = append(notifBuilders, &dbstruct.NotifBuilder{ TemplateId: consts.SysNotifTemp_CancelNotif, - NidGetter: nidAccessor.GetNid, + GetNid: nidAccessor.GetNid, }) ctx.Set("notif_builders", notifBuilders) } @@ -2189,9 +2189,9 @@ func (s *Service) utilWriteNotifInfoByMap(ctx *gin.Context, notifTempId int64, o notifBuilder.PushTime = pushTimeObj.(int64) } - nidSaveFuncObj, ok := mp["nid_save_func"] + setNidObj, ok := mp["nid_save_func"] if ok { - notifBuilder.NidSaveFunc = nidSaveFuncObj.(func(ctx *gin.Context, nid int64) error) + notifBuilder.SetNid = setNidObj.(func(ctx *gin.Context, nid int64) error) } notifBuilders = append(notifBuilders, notifBuilder) diff --git a/dbstruct/frontend_route.go b/dbstruct/frontend_route.go index 97f1a010..08583f43 100644 --- a/dbstruct/frontend_route.go +++ b/dbstruct/frontend_route.go @@ -3,7 +3,7 @@ package dbstruct type FrontendRoute struct { Id *int64 `json:"id" bson:"_id"` // 前端页面路由表id RoutePath *string `json:"route_path" bson:"route_path"` // 前端页面路由地址 - Action *int64 `json:"action" bson:"action"` // 跳转类型 + Action *string `json:"action" bson:"action"` // 跳转类型 Desc *string `json:"desc" bson:"desc"` // 前端页面描述 Ct *int64 `json:"ct" bson:"ct"` // 创建时间 Ut *int64 `json:"ut" bson:"ut"` // 更新时间 @@ -24,9 +24,9 @@ func (p *FrontendRoute) GetRoutePath() string { return *p.RoutePath } -func (p *FrontendRoute) GetAction() int64 { +func (p *FrontendRoute) GetAction() string { if p == nil || p.Action == nil { - return 0 + return "" } return *p.Action } diff --git a/dbstruct/notification.go b/dbstruct/notification.go index 971a2516..80da4928 100644 --- a/dbstruct/notification.go +++ b/dbstruct/notification.go @@ -108,6 +108,6 @@ type NotifBuilder struct { Action string // 行为 Params string // 行为参数 PushTime int64 // 推送时间 - NidSaveFunc func(ctx *gin.Context, nid int64) error // nid存储函数,一般用于取消推送 - NidGetter func() int64 // nid访问器 + SetNid func(ctx *gin.Context, nid int64) error // nid存储函数,一般用于取消推送 + GetNid func() int64 // nid访问器 } diff --git a/library/middleware/notif_sender.go b/library/middleware/notif_sender.go index f9c48f41..f31f1d33 100644 --- a/library/middleware/notif_sender.go +++ b/library/middleware/notif_sender.go @@ -37,7 +37,7 @@ func InitNotifSender(_DefaultNotification *logic.Notification, _DefaultNotifBcst if notifBuilder.TemplateId == consts.SysNotifTemp_CancelNotif { err := _DefaultNotification.OpUpdate(ctx, ¬ificationproto.OpUpdateReq{ Notification: &dbstruct.Notification{ - Id: goproto.Int64(notifBuilder.NidGetter()), + Id: goproto.Int64(notifBuilder.GetNid()), Status: goproto.Int64(consts.Notification_Cancelled), }, }) @@ -97,8 +97,8 @@ func InitNotifSender(_DefaultNotification *logic.Notification, _DefaultNotifBcst } // 将通知id暂存,若暂存失败,则不广播该条通知,因业务无法再控制其停止 - if notifBuilder.NidSaveFunc != nil { - err = notifBuilder.NidSaveFunc(ctx, notification.GetId()) + if notifBuilder.SetNid != nil { + err = notifBuilder.SetNid(ctx, notification.GetId()) if err != nil { logger.Error("通知id暂存失败:%v", err) continue