From 357ee2a3be8e4a6a979ceed8a405f3e9ac8c454a Mon Sep 17 00:00:00 2001 From: Leufolium Date: Mon, 14 Oct 2024 13:39:19 +0800 Subject: [PATCH] 1 --- api/consts/option.go | 7 +++++++ .../notification/proto/not_null_def_op.go | 20 +++++++++++++++++++ .../notification/proto/notification_op.go | 2 ++ app/mix/service/service.go | 8 -------- 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 api/proto/notification/proto/not_null_def_op.go diff --git a/api/consts/option.go b/api/consts/option.go index c70abb54..c2d8a88f 100644 --- a/api/consts/option.go +++ b/api/consts/option.go @@ -98,3 +98,10 @@ const ( StreamerAuthApproval_OneOffVersion = 0 StreamerAuthApproval_SeparateVersion = 1 ) + +const ( + Notification_ObjType_AllStreamer = 0 + Notification_ObjType_AllUser = 1 + Notification_ObjType_AllStreamerAndUser = 2 + Notification_ObjType_Customized = 3 +) diff --git a/api/proto/notification/proto/not_null_def_op.go b/api/proto/notification/proto/not_null_def_op.go new file mode 100644 index 00000000..1ff5930a --- /dev/null +++ b/api/proto/notification/proto/not_null_def_op.go @@ -0,0 +1,20 @@ +package proto + +import ( + "service/api/consts" + "service/bizcommon/util" + "service/library/validator" +) + +func (p *OpCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) { + params = make([]*validator.JsonParam, 0) + + params = append(params, validator.NewInt64PtrParam("请确认通知接收人类型!", p.ObjType)) + if util.DerefInt64(p.ObjType) == consts.Notification_ObjType_Customized { + params = append(params, validator.NewInt64SliceParam("请确认通知接收人mids!", p.ObjMids)) + } + params = append(params, validator.NewInt64PtrParam("请确认消息类型!", p.NType)) + params = append(params, validator.NewStringPtrParam("请确认消息内容!", p.Message)) + + return +} diff --git a/api/proto/notification/proto/notification_op.go b/api/proto/notification/proto/notification_op.go index 4bcca8d0..01d3a98b 100644 --- a/api/proto/notification/proto/notification_op.go +++ b/api/proto/notification/proto/notification_op.go @@ -9,6 +9,8 @@ import ( type OpCreateReq struct { base.BaseRequest *dbstruct.Notification + ObjType *int64 `json:"obj_type"` // 通知接收人类型 + ObjMids []int64 `json:"obj_mids"` // 通知接收人mids } type OpCreateData struct { diff --git a/app/mix/service/service.go b/app/mix/service/service.go index deaac834..f28f5b2b 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -5021,14 +5021,6 @@ func (s *Service) OpCreateNotification(ctx *gin.Context, req *notificationproto. return } - // 加载进redis - _, err = redis.GetRedisClient().Incr(logic.GetNotificationCountIdForRedis(req.Notification.GetObjMid())) - if err != nil { - logger.Error("Redis Incr fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeNotificationCountRedisCacheInvalid - return - } - return }