From bd079a0040a93d60d464947e24908782dd1dfaab Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Thu, 25 May 2023 16:49:05 +0800 Subject: [PATCH] update Notification --- internal/repo/notification/notification_repo.go | 4 ++++ internal/schema/notification_schema.go | 6 +++--- internal/service/notification/notification_service.go | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/repo/notification/notification_repo.go b/internal/repo/notification/notification_repo.go index 994113fc..21b7bcff 100644 --- a/internal/repo/notification/notification_repo.go +++ b/internal/repo/notification/notification_repo.go @@ -96,10 +96,14 @@ func (nr *notificationRepo) GetNotificationPage(ctx context.Context, searchCond session := nr.data.DB.NewSession() session = session.Desc("updated_at") + cond := &entity.Notification{ UserID: searchCond.UserID, Type: searchCond.Type, } + if searchCond.InboxType > 0 { + cond.MsgType = searchCond.InboxType + } total, err = pager.Help(searchCond.Page, searchCond.PageSize, ¬ificationList, cond, session) if err != nil { err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() diff --git a/internal/schema/notification_schema.go b/internal/schema/notification_schema.go index fd9569ca..4e617efd 100644 --- a/internal/schema/notification_schema.go +++ b/internal/schema/notification_schema.go @@ -7,10 +7,10 @@ const ( NotificationRead = 2 NotificationStatusNormal = 1 NotificationStatusDelete = 10 - NotificationInboxTypeAll = 1 - NotificationInboxTypePosts = 2 + NotificationInboxTypeAll = 0 + NotificationInboxTypePosts = 1 + NotificationInboxTypeVotes = 2 NotificationInboxTypeInvites = 3 - NotificationInboxTypeVotes = 4 ) var NotificationType = map[string]int{ diff --git a/internal/service/notification/notification_service.go b/internal/service/notification/notification_service.go index 6402f395..6e7d09d6 100644 --- a/internal/service/notification/notification_service.go +++ b/internal/service/notification/notification_service.go @@ -125,9 +125,9 @@ func (ns *NotificationService) GetNotificationPage(ctx context.Context, searchCo } searchInboxType := schema.NotificationInboxTypeAll if searchType == schema.NotificationTypeInbox { - searchInboxType, ok = schema.NotificationInboxType[searchCond.InboxTypeStr] - if !ok { - return pager.NewPageModel(0, resp), nil + _, ok = schema.NotificationInboxType[searchCond.InboxTypeStr] + if ok { + searchInboxType = schema.NotificationInboxType[searchCond.InboxTypeStr] } } searchCond.Type = searchType