diff --git a/api/consts/notif_template.go b/api/consts/notif_template.go index eb244df3..ed680387 100644 --- a/api/consts/notif_template.go +++ b/api/consts/notif_template.go @@ -14,7 +14,7 @@ const ( SysNotifTemp_StreamerPunishmentEnds = 3 // 主播封禁结束 SysNotifTemp_PswdChanged = 4 // 修改密码 SysNotifTemp_AcctCancellationApplied = 5 // 申请注销账号 - SysNotifTemp_AcctCancelled = 6 // 账号已注销 + SysNotifTemp_AcctCancelled = 6 // 账号已注销(todo) SysNotifTemp_StreamerAuthApprovalPassed = 7 // 申请入驻、完善资料均通过 SysNotifTemp_ZoneCreated = 8 // 空间开通时 SysNotifTemp_ZoneVasUpdated = 9 // 设置空间付费信息 diff --git a/app/mix/cmd/main.go b/app/mix/cmd/main.go index d6202ae2..554f7603 100644 --- a/app/mix/cmd/main.go +++ b/app/mix/cmd/main.go @@ -110,6 +110,7 @@ func main() { port := cfg.App.Port router := httpengine.NewRouter() middleware.InitJwtAuthenticator(service.DefaultService.OpVerifyToken) + service.DefaultService.ConnectToNotifCenter(middleware.InitNotifSender) validator.InitDefaultNotNullValidator() controller.Init(router) srv := &http.Server{ diff --git a/app/mix/cmd_offline/main.go b/app/mix/cmd_offline/main.go index 8e6c9ff4..8851f1ef 100644 --- a/app/mix/cmd_offline/main.go +++ b/app/mix/cmd_offline/main.go @@ -116,6 +116,7 @@ func main() { // 初始化http server router := httpengine.NewRouter() middleware.InitJwtAuthenticator(service.DefaultService.OpVerifyToken) + service.DefaultService.ConnectToNotifCenter(middleware.InitNotifSender) validator.InitDefaultNotNullValidator() controller.InitOffline(router) srv := &http.Server{ diff --git a/app/mix/controller/account_api.go b/app/mix/controller/account_api.go index 5e3478c4..a74ea6f1 100644 --- a/app/mix/controller/account_api.go +++ b/app/mix/controller/account_api.go @@ -195,6 +195,7 @@ func ApiCancelAccount(ctx *gin.Context) { } ReplyOk(ctx, nil) + ctx.Next() } func ApiAbortAccountCancellation(ctx *gin.Context) { diff --git a/app/mix/controller/accountpunishment_op.go b/app/mix/controller/accountpunishment_op.go index b8ceccb1..f346a1c2 100644 --- a/app/mix/controller/accountpunishment_op.go +++ b/app/mix/controller/accountpunishment_op.go @@ -22,6 +22,8 @@ func OpCreateAccountPunishment(ctx *gin.Context) { } ReplyOk(ctx, nil) + + ctx.Next() } func OpGetAccountPunishmentList(ctx *gin.Context) { @@ -63,6 +65,7 @@ func OpUnblockAccountPunishment(ctx *gin.Context) { } ReplyOk(ctx, nil) + ctx.Next() } func OpGetTerminatedAccountPunishmentList(ctx *gin.Context) { diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 7e90a179..fd47ff70 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -82,11 +82,11 @@ func Init(r *gin.Engine) { // 登录 apiLoginGroup := r.Group("/api/login", PrepareToC()) apiLoginGroup.POST("login_by_pswd", middleware.JSONParamValidator(loginproto.ApiLoginByPswdReq{}), middleware.RequestDecryptor(), ApiLoginByPswd) - apiLoginGroup.POST("login_by_veri_code", middleware.JSONParamValidator(loginproto.ApiLoginByVeriCodeReq{}), middleware.RequestDecryptor(), ApiLoginByVeriCode) + apiLoginGroup.POST("login_by_veri_code", middleware.JSONParamValidator(loginproto.ApiLoginByVeriCodeReq{}), middleware.RequestDecryptor(), ApiLoginByVeriCode, middleware.NotifSender()) apiLoginGroup.POST("logout", middleware.JSONParamValidator(loginproto.ApiLogoutReq{}), middleware.JwtAuthenticator(), ApiLogout) apiLoginGroup.POST("set_password", middleware.JSONParamValidator(loginproto.ApiSetPswdReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiSetPassword) apiLoginGroup.POST("reset_password", middleware.JSONParamValidator(loginproto.ApiResetPswdReq{}), middleware.RequestDecryptor(), ApiResetPassword) - apiLoginGroup.POST("update_password", middleware.JSONParamValidator(loginproto.ApiUpdatePswdReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiUpdatePassword) + apiLoginGroup.POST("update_password", middleware.JSONParamValidator(loginproto.ApiUpdatePswdReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiUpdatePassword, middleware.NotifSender()) apiLoginGroup.POST("validate", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), ApiValidate) // 账号,用户端支持改、查自己、查别人、经验增长,不支持增删 @@ -98,7 +98,7 @@ func Init(r *gin.Engine) { apiAccountGroup.POST("list_others_by_mids", middleware.JSONParamValidator(accountproto.ApiListOthersByMidsReq{}), middleware.JwtAuthenticator(), ApiGetAccountListForOthersByMids) apiAccountGroup.POST("list_others_by_user_id", middleware.JSONParamValidator(accountproto.ApiListOthersByUserIdReq{}), middleware.JwtAuthenticator(), ApiGetAccountListForOthersByUserId) apiAccountGroup.POST("exp_inc", middleware.JSONParamValidator(accountproto.ApiExpIncReq{}), middleware.JwtAuthenticator(), ApiAccountExpInc) - apiAccountGroup.POST("cancel", middleware.JSONParamValidator(accountproto.ApiCancelReq{}), middleware.JwtAuthenticator(), ApiCancelAccount) + apiAccountGroup.POST("cancel", middleware.JSONParamValidator(accountproto.ApiCancelReq{}), middleware.JwtAuthenticator(), ApiCancelAccount, middleware.NotifSender()) apiAccountGroup.POST("abort_cancellation", middleware.JSONParamValidator(accountproto.ApiAbortCancellationReq{}), middleware.JwtAuthenticator(), ApiAbortAccountCancellation) // GET通过token获取手机号 r.GET("api/account/get_mobile_phone", middleware.FORMParamValidator(accountproto.ApiGetMobilePhoneReq{}), ApiGetMobilePhone) @@ -240,8 +240,8 @@ func Init(r *gin.Engine) { // 空间 apiZoneGroup := r.Group("/api/zone", PrepareToC()) - apiZoneGroup.POST("create", middleware.JSONParamValidator(zoneproto.ApiCreateReq{}), middleware.JwtAuthenticator(), ApiCreateZone) - apiZoneGroup.POST("update", middleware.JSONParamValidator(zoneproto.ApiUpdateReq{}), middleware.JwtAuthenticator(), ApiUpdateZone) + apiZoneGroup.POST("create", middleware.JSONParamValidator(zoneproto.ApiCreateReq{}), middleware.JwtAuthenticator(), ApiCreateZone, middleware.NotifSender()) + apiZoneGroup.POST("update", middleware.JSONParamValidator(zoneproto.ApiUpdateReq{}), middleware.JwtAuthenticator(), ApiUpdateZone, middleware.NotifSender()) apiZoneGroup.POST("delete", middleware.JSONParamValidator(zoneproto.ApiDeleteReq{}), middleware.JwtAuthenticator(), ApiDeleteZone) apiZoneGroup.POST("list", middleware.JSONParamValidator(zoneproto.ApiListReq{}), middleware.JwtAuthenticator(), ApiGetZoneList) apiZoneGroup.POST("list_by_mid", middleware.JSONParamValidator(zoneproto.ApiListByMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneListByMid) @@ -273,7 +273,7 @@ func Init(r *gin.Engine) { // 空间代运营表 apiZoneThirdPartnerGroup := r.Group("/api/zone_third_partner", PrepareToC()) - apiZoneThirdPartnerGroup.POST("create", middleware.JSONParamValidator(zone_third_partner_proto.ApiCreateReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiCreateZoneThirdPartner) + apiZoneThirdPartnerGroup.POST("create", middleware.JSONParamValidator(zone_third_partner_proto.ApiCreateReq{}), middleware.JwtAuthenticator(), middleware.RequestDecryptor(), ApiCreateZoneThirdPartner, middleware.NotifSender()) //apiZoneThirdPartnerGroup.POST("update", middleware.JSONParamValidator(zone_third_partner_proto.ApiUpdateReq{}), middleware.JwtAuthenticator(), ApiUpdateZoneThirdPartner) //apiZoneThirdPartnerGroup.POST("delete", middleware.JSONParamValidator(zone_third_partner_proto.ApiDeleteReq{}), middleware.JwtAuthenticator(), ApiDeleteZoneThirdPartner) apiZoneThirdPartnerGroup.POST("list", middleware.JSONParamValidator(zone_third_partner_proto.ApiListReq{}), middleware.JwtAuthenticator(), ApiGetZoneThirdPartnerList) @@ -431,7 +431,7 @@ func Init(r *gin.Engine) { opStreamerAuthApprovalGroup.POST("list_basic", middleware.JSONParamValidator(streamerauthapprovalbasicproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetStreamerAuthApprovalBasicList) opStreamerAuthApprovalGroup.POST("approve_basic", middleware.JSONParamValidator(streamerauthapprovalbasicproto.OpApproveReq{}), middleware.JwtAuthenticator(), OpApproveStreamerAuthApprovalBasic) opStreamerAuthApprovalGroup.POST("list_details", middleware.JSONParamValidator(streamerauthapprovaldetailsproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetStreamerAuthApprovalDetailsList) - opStreamerAuthApprovalGroup.POST("approve_details", middleware.JSONParamValidator(streamerauthapprovaldetailsproto.OpApproveReq{}), middleware.JwtAuthenticator(), OpApproveStreamerAuthApprovalDetails) + opStreamerAuthApprovalGroup.POST("approve_details", middleware.JSONParamValidator(streamerauthapprovaldetailsproto.OpApproveReq{}), middleware.JwtAuthenticator(), OpApproveStreamerAuthApprovalDetails, middleware.NotifSender()) // 主播认证审批历史表 opStreamerAuthApprovalHisGroup := r.Group("/op/streamer_auth_approval_his", PrepareOp()) @@ -558,9 +558,9 @@ func Init(r *gin.Engine) { // 账号处罚 opAccountPunishmentGroup := r.Group("/op/account_punishment", PrepareOp()) - opAccountPunishmentGroup.POST("create", middleware.JSONParamValidator(accountpunishmentproto.OpCreateReq{}), middleware.JwtAuthenticator(), OpCreateAccountPunishment) + opAccountPunishmentGroup.POST("create", middleware.JSONParamValidator(accountpunishmentproto.OpCreateReq{}), middleware.JwtAuthenticator(), OpCreateAccountPunishment, middleware.NotifSender()) opAccountPunishmentGroup.POST("list", middleware.JSONParamValidator(accountpunishmentproto.OpListReq{}), middleware.JwtAuthenticator(), OpGetAccountPunishmentList) - opAccountPunishmentGroup.POST("unblock", middleware.JSONParamValidator(accountpunishmentproto.OpUnblockReq{}), middleware.JwtAuthenticator(), OpUnblockAccountPunishment) + opAccountPunishmentGroup.POST("unblock", middleware.JSONParamValidator(accountpunishmentproto.OpUnblockReq{}), middleware.JwtAuthenticator(), OpUnblockAccountPunishment, middleware.NotifSender()) opAccountPunishmentGroup.POST("list_terminated", middleware.JSONParamValidator(accountpunishmentproto.OpListTerminatedReq{}), middleware.JwtAuthenticator(), OpGetTerminatedAccountPunishmentList) // 账户注销 diff --git a/app/mix/controller/login_api.go b/app/mix/controller/login_api.go index e5ca5581..4158693d 100644 --- a/app/mix/controller/login_api.go +++ b/app/mix/controller/login_api.go @@ -71,6 +71,7 @@ func ApiUpdatePassword(ctx *gin.Context) { ReplyOk(ctx, &loginproto.ApiUpdatePswdData{ ApiResult: true, }) + ctx.Next() } func ApiLoginByVeriCode(ctx *gin.Context) { @@ -90,6 +91,8 @@ func ApiLoginByVeriCode(ctx *gin.Context) { Token: token, AccountVO: accountVO, }) + + ctx.Next() } func ApiLogout(ctx *gin.Context) { diff --git a/app/mix/controller/streamerauthapproval_details_op.go b/app/mix/controller/streamerauthapproval_details_op.go index af6a5407..390c3ea3 100644 --- a/app/mix/controller/streamerauthapproval_details_op.go +++ b/app/mix/controller/streamerauthapproval_details_op.go @@ -57,4 +57,5 @@ func OpApproveStreamerAuthApprovalDetails(ctx *gin.Context) { } ReplyOk(ctx, nil) + ctx.Next() } diff --git a/app/mix/controller/zone_api.go b/app/mix/controller/zone_api.go index c4481833..09a4e97a 100644 --- a/app/mix/controller/zone_api.go +++ b/app/mix/controller/zone_api.go @@ -22,6 +22,7 @@ func ApiCreateZone(ctx *gin.Context) { } ReplyOk(ctx, nil) + ctx.Next() } func ApiUpdateZone(ctx *gin.Context) { @@ -34,6 +35,7 @@ func ApiUpdateZone(ctx *gin.Context) { } ReplyOk(ctx, nil) + ctx.Next() } func ApiDeleteZone(ctx *gin.Context) { diff --git a/app/mix/controller/zone_third_partner_api.go b/app/mix/controller/zone_third_partner_api.go index 96da98f8..e11b8982 100644 --- a/app/mix/controller/zone_third_partner_api.go +++ b/app/mix/controller/zone_third_partner_api.go @@ -21,6 +21,7 @@ func ApiCreateZoneThirdPartner(ctx *gin.Context) { } ReplyOk(ctx, nil) + ctx.Next() } // func ApiUpdateZoneThirdPartner(ctx *gin.Context) { diff --git a/app/mix/service/service.go b/app/mix/service/service.go index fbf34b6d..997217af 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -328,6 +328,11 @@ func (s *Service) ConnectToStreamerRecommService(r *StreamerRecommService) { }) } +// 通知推送接口 +func (s *Service) ConnectToNotifCenter(connFunc func(*logic.Notification, *NotifBcstCenter)) { + connFunc(_DefaultNotification, DefaultNotifBcstCenter) +} + // Product func (s *Service) OpCreateProduct(ctx *gin.Context, req *productproto.OpCreateReq) (ec errcode.ErrCode) { ec = errcode.ErrCodeProductSrvOk diff --git a/library/middleware/notif_sender.go b/library/middleware/notif_sender.go index 888d476f..8e3232fa 100644 --- a/library/middleware/notif_sender.go +++ b/library/middleware/notif_sender.go @@ -21,7 +21,7 @@ var ( DefaultNotifSender gin.HandlerFunc ) -func InitNotifSender(_DefaultNotification *logic.Notification, _DefaultNotifBcstCenter service.NotifBcstCenter) { +func InitNotifSender(_DefaultNotification *logic.Notification, _DefaultNotifBcstCenter *service.NotifBcstCenter) { DefaultNotifSender = func(ctx *gin.Context) { // 获取通知builder