作者 linmadan

修复消息读取数目bug

... ... @@ -65,6 +65,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
if count, err := tx.Model(sentNotificationModel).Relation("Notification").
Where(`sent_notification.receiver @> '{"uid":?}'`, uid).
Where("notification.notification_type = ?", domain.NOTIFICATION_TYPE_SYSTEM).
Where("sent_notification.is_read = ?", false).
Count(); err != nil {
return nil, err
} else {
... ... @@ -73,6 +74,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
if count, err := tx.Model(sentNotificationModel).Relation("Notification").
Where(`sent_notification.receiver @> '{"uid":?}'`, uid).
Where("notification.notification_type = ?", domain.NOTIFICATION_TYPE_INTERACTION).
Where("sent_notification.is_read = ?", false).
Count(); err != nil {
return nil, err
} else {
... ...
... ... @@ -15,7 +15,7 @@ func (dao *NotificationDao) ReadAllUnReadSentNotification(receiverId int64) (int
tx := dao.transactionContext.PgTx
result, err := tx.Query(
pg.Scan(),
`UPDATE sent_notifications SET is_read=?, read_time=? WHERE receiver @> '{"uid":?}'`,
`UPDATE sent_notifications SET is_read=?, read_time=? WHERE receiver @> '{"uid":?}' AND is_read=false`,
true, time.Now(), receiverId)
if err != nil {
return 0, err
... ...