diff --git a/internal/dao/jinzhu/messages.go b/internal/dao/jinzhu/messages.go index ea9976fd..105618e9 100644 --- a/internal/dao/jinzhu/messages.go +++ b/internal/dao/jinzhu/messages.go @@ -48,7 +48,7 @@ func (s *messageSrv) ReadMessage(message *ms.Message) error { } func (s *messageSrv) ReadAllMessage(userId int64) error { - return s.db.Table(_message_).Where("receiver_user_id=?", userId).Update("is_read", 1).Error + return s.db.Table(_message_).Where("receiver_user_id=? AND is_del=0", userId).Update("is_read", 1).Error } func (s *messageSrv) GetMessages(userId int64, style cs.MessageStyle, limit int, offset int) (res []*ms.MessageFormated, total int64, err error) { diff --git a/internal/dao/jinzhu/tweets.go b/internal/dao/jinzhu/tweets.go index 4efce1f9..8139b1c1 100644 --- a/internal/dao/jinzhu/tweets.go +++ b/internal/dao/jinzhu/tweets.go @@ -393,7 +393,7 @@ func (s *tweetSrv) GetPosts(conditions ms.ConditionsT, offset, limit int) ([]*ms } func (s *tweetSrv) ListUserTweets(userId int64, style uint8, justEssence bool, limit, offset int) (res []*ms.Post, total int64, err error) { - db := s.db.Table(_post_).Where("user_id = ?", userId) + db := s.db.Model(&dbr.Post{}).Where("user_id = ?", userId) switch style { case cs.StyleUserTweetsAdmin: fallthrough @@ -438,7 +438,7 @@ func (s *tweetSrv) ListIndexNewestTweets(limit, offset int) (res []*ms.Post, tot } func (s *tweetSrv) ListIndexHotsTweets(limit, offset int) (res []*ms.Post, total int64, err error) { - db := s.db.Table(_post_).Joins(fmt.Sprintf("LEFT JOIN %s metric ON %s.id=metric.post_id", _post_metric_, _post_)).Where("visibility >= ?", cs.TweetVisitPublic) + db := s.db.Table(_post_).Joins(fmt.Sprintf("LEFT JOIN %s metric ON %s.id=metric.post_id", _post_metric_, _post_)).Where(fmt.Sprintf("visibility >= ? AND %s.is_del=0 AND metric.is_del=0", _post_), cs.TweetVisitPublic) if err = db.Count(&total).Error; err != nil { return } @@ -471,7 +471,7 @@ func (s *tweetSrv) ListFollowingTweets(userId int64, limit, offset int) (res []* return nil, 0, xerr } beFriendCount, beFollowCount := len(beFriendIds), len(beFollowIds) - db := s.db.Table(_post_) + db := s.db.Model(&dbr.Post{}) //可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开', switch { case beFriendCount > 0 && beFollowCount > 0: @@ -496,10 +496,10 @@ func (s *tweetSrv) ListFollowingTweets(userId int64, limit, offset int) (res []* } func (s *tweetSrv) getUserRelation(userId int64) (beFriendIds []int64, beFollowIds []int64, err error) { - if err = s.db.Table(_contact_).Where("friend_id=?", userId).Select("user_id").Find(&beFriendIds).Error; err != nil { + if err = s.db.Table(_contact_).Where("friend_id=? AND status=2 AND is_del=0", userId).Select("user_id").Find(&beFriendIds).Error; err != nil { return } - if err = s.db.Table(_following_).Where("user_id=?", userId).Select("follow_id").Find(&beFollowIds).Error; err != nil { + if err = s.db.Table(_following_).Where("user_id=? AND is_del=0", userId).Select("follow_id").Find(&beFollowIds).Error; err != nil { return } // 即是好友又是关注者,保留好友去除关注者 diff --git a/internal/dao/sakila/auto/cc/cc.go b/internal/dao/sakila/auto/cc/cc.go index d6e2b25a..016b8ffe 100644 --- a/internal/dao/sakila/auto/cc/cc.go +++ b/internal/dao/sakila/auto/cc/cc.go @@ -110,7 +110,7 @@ const ( _Tweet_GetAnyPostCount = `SELECT count(*) FROM @post WHERE visibility IN (?)` _Tweet_GetAnyPosts = `SELECT * FROM @post WHERE visibility IN (?) AND is_del=0 LIMIT ? OFFSET ?` _Tweet_GetBeFollowIds = `SELECT follow_id FROM @following WHERE user_id=? AND is_del=0` - _Tweet_GetBeFriendIds = `SELECT user_id FROM @contact WHERE friend_id=? AND is_del=0` + _Tweet_GetBeFriendIds = `SELECT user_id FROM @contact WHERE friend_id=? AND status=2 AND is_del=0` _Tweet_GetPostAttachmentBill = `SELECT * FROM @post_attachment_bill WHERE post_id=? AND user_id=? AND is_del=0` _Tweet_GetPostById = `SELECT * FROM @post WHERE id=? AND is_del=0` _Tweet_GetPostContentById = `SELECT * FROM @post_content WHERE id=? AND is_del=0` diff --git a/internal/dao/sakila/yesql/yesql_cc.sql b/internal/dao/sakila/yesql/yesql_cc.sql index d5ae9903..cbeca061 100644 --- a/internal/dao/sakila/yesql/yesql_cc.sql +++ b/internal/dao/sakila/yesql/yesql_cc.sql @@ -1198,7 +1198,7 @@ WHERE user_id=? AND is_del=0; -- name: get_be_friend_ids@tweet -- prepare: stmt -SELECT user_id FROM @contact WHERE friend_id=? AND is_del=0; +SELECT user_id FROM @contact WHERE friend_id=? AND status=2 AND is_del=0; -- name: get_be_follow_ids@tweet -- prepare: stmt