by Robin at 20241016
This commit is contained in:
parent
ae74496934
commit
053045854d
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue