From 053045854ddddb9db65a5acf07921edbc23c4f86 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Wed, 16 Oct 2024 15:32:12 +0800 Subject: [PATCH] by Robin at 20241016 --- app/mix/dao/mongo.go | 44 ++++++++++++++++++++++++++- app/mix/service/apiservice.go | 26 ---------------- app/mix/service/logic/notification.go | 1 - dbstruct/notification.go | 3 +- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 5fcac61f..7c7b57e6 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -6296,7 +6296,7 @@ func (m *Mongo) UpdateNotificationByIds(ctx *gin.Context, notification *dbstruct } // 通知广播版本号表 -func (m *Mongo) GetAndUpdateNotifBcstVersSeq(ctx *gin.Context, objType int64) (vers *dbstruct.NotifBcstVers, err error) { +func (m *Mongo) GetAndUpdateNotifBcstVers(ctx *gin.Context, objType int64) (vers *dbstruct.NotifBcstVers, err error) { col := m.getColNotifBcstVers() change := qmgo.Change{ @@ -6321,6 +6321,48 @@ func (m *Mongo) GetAndUpdateNotifBcstVersSeq(ctx *gin.Context, objType int64) (v return &versInstance, err } +// 通知广播接收版本号表 +func (m *Mongo) GetAndUpdateNotifBcstReceiveVers(ctx *gin.Context, mid int64, vers int64) (receiveVers *dbstruct.NotifBcstReceiveVers, err error) { + col := m.getColNotifBcstReceiveVers() + + change := qmgo.Change{ + Update: qmgo.M{"$set": qmgo.M{"vers": vers}}, + Upsert: true, + ReturnNew: false, + } + + receiveVersInstance := dbstruct.NotifBcstReceiveVers{} + if err = col.Find(ctx, qmgo.M{"_id": mid}).Apply(change, &receiveVersInstance); err != nil { + logger.Error("change error : %v", err) + return + } + + return &receiveVersInstance, err +} + +// 通知广播表 +func (m *Mongo) CreateNotifBcsts(ctx *gin.Context, notifBcsts []*dbstruct.NotifBcst) error { + col := m.getColNotifBcst() + _, err := col.InsertMany(ctx, notifBcsts) + return err +} + +func (m *Mongo) DeleteNotifBcsts(ctx *gin.Context, ids []int64) error { + col := m.getColNotifBcst() + update := qmgo.M{ + "$set": qmgo.M{ + "del_flag": 1, + }, + } + filter := qmgo.M{ + "_id": qmgo.M{ + "$in": ids, + }, + } + _, err := col.UpdateAll(ctx, filter, update) + return err +} + // 瑞文智商测试表相关 func (m *Mongo) CreateRavenIQTest(ctx *gin.Context, Raven_IQ_test *dbstruct.RavenIQTest) error { col := m.getColRavenIQTest() diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 186afe27..bca59bac 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -4270,29 +4270,3 @@ func (s *Service) ApiGetUnreadNotificationListByMid(ctx *gin.Context, req *notif } return } - -func (s *Service) ApiReadNotification(ctx *gin.Context, req *notificationproto.ApiReadReq) (ec errcode.ErrCode) { - ec = errcode.ErrCodeNotificationSrvOk - err := _DefaultNotification.OpUpdateByIds(ctx, &dbstruct.Notification{ - IsRead: goproto.Int64(consts.Notification_Read), - }, req.Ids) - if err == qmgo.ErrNoSuchDocuments { - ec = errcode.ErrCodeNotificationNotExist - err = nil - return - } - if err != nil { - logger.Error("ApiUpdate fail, req: %v, err: %v", util.ToJson(req), err) - ec = errcode.ErrCodeNotificationSrvFail - return - } - return -} - -func (s *Service) ApiGetUnreadNotificationCountByMid(ctx *gin.Context, req *notificationproto.ApiCountUnreadByMidReq) (unreadCount int64, ec errcode.ErrCode) { - ec = errcode.ErrCodeNotificationSrvOk - - unreadCount, _ = redis.GetRedisClient().GetInt64(logic.GetNotificationCountIdForRedis(req.BaseRequest.Mid)) - - return -} diff --git a/app/mix/service/logic/notification.go b/app/mix/service/logic/notification.go index 6dd3d184..3c07eb22 100644 --- a/app/mix/service/logic/notification.go +++ b/app/mix/service/logic/notification.go @@ -37,7 +37,6 @@ func (p *Notification) OpCreate(ctx *gin.Context, req *notificationproto.OpCreat req.Notification.Ct = goproto.Int64(time.Now().Unix()) req.Notification.Ut = goproto.Int64(time.Now().Unix()) req.Notification.DelFlag = goproto.Int64(consts.Exist) - req.Notification.IsRead = goproto.Int64(consts.Notification_NotRead) err = p.store.CreateNotification(ctx, req.Notification) if err != nil { logger.Error("CreateNotification fail, err: %v", err) diff --git a/dbstruct/notification.go b/dbstruct/notification.go index e1b9d8bc..a32fbe7d 100644 --- a/dbstruct/notification.go +++ b/dbstruct/notification.go @@ -32,8 +32,7 @@ type NotifBcstVers struct { } type NotifBcstReceiveVers struct { - Id int64 `json:"id" bson:"_id"` // 通知广播接收表id(mid) - Vers int64 `json:"vers" bson:"vers"` // 通知广播表版本号 + Vers int64 `json:"vers" bson:"vers"` // 通知广播接收表版本号 } type NotifReceive struct {