@@ -393,7 +393,7 @@ func (s *tweetSrv) GetPosts(conditions ms.ConditionsT, offset, limit int) ([]*ms
393393}
394394
395395func (s * tweetSrv ) ListUserTweets (userId int64 , style uint8 , justEssence bool , limit , offset int ) (res []* ms.Post , total int64 , err error ) {
396- db := s .db .Table ( _post_ ).Where ("user_id = ?" , userId )
396+ db := s .db .Model ( & dbr. Post {} ).Where ("user_id = ?" , userId )
397397 switch style {
398398 case cs .StyleUserTweetsAdmin :
399399 fallthrough
@@ -438,7 +438,7 @@ func (s *tweetSrv) ListIndexNewestTweets(limit, offset int) (res []*ms.Post, tot
438438}
439439
440440func (s * tweetSrv ) ListIndexHotsTweets (limit , offset int ) (res []* ms.Post , total int64 , err error ) {
441- 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 )
441+ 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 )
442442 if err = db .Count (& total ).Error ; err != nil {
443443 return
444444 }
@@ -471,7 +471,7 @@ func (s *tweetSrv) ListFollowingTweets(userId int64, limit, offset int) (res []*
471471 return nil , 0 , xerr
472472 }
473473 beFriendCount , beFollowCount := len (beFriendIds ), len (beFollowIds )
474- db := s .db .Table ( _post_ )
474+ db := s .db .Model ( & dbr. Post {} )
475475 //可见性: 0私密 10充电可见 20订阅可见 30保留 40保留 50好友可见 60关注可见 70保留 80保留 90公开',
476476 switch {
477477 case beFriendCount > 0 && beFollowCount > 0 :
@@ -496,10 +496,10 @@ func (s *tweetSrv) ListFollowingTweets(userId int64, limit, offset int) (res []*
496496}
497497
498498func (s * tweetSrv ) getUserRelation (userId int64 ) (beFriendIds []int64 , beFollowIds []int64 , err error ) {
499- if err = s .db .Table (_contact_ ).Where ("friend_id=?" , userId ).Select ("user_id" ).Find (& beFriendIds ).Error ; err != nil {
499+ 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 {
500500 return
501501 }
502- if err = s .db .Table (_following_ ).Where ("user_id=?" , userId ).Select ("follow_id" ).Find (& beFollowIds ).Error ; err != nil {
502+ if err = s .db .Table (_following_ ).Where ("user_id=? AND is_del=0 " , userId ).Select ("follow_id" ).Find (& beFollowIds ).Error ; err != nil {
503503 return
504504 }
505505 // 即是好友又是关注者,保留好友去除关注者
0 commit comments