From 7f5183f83bbfc113ea865f4d10cee575c3bda9b1 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 6 Apr 2024 03:03:22 +0800 Subject: [PATCH] :bug: Fix filter issue --- pkg/services/friendships.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/services/friendships.go b/pkg/services/friendships.go index e21a12d..64cae36 100644 --- a/pkg/services/friendships.go +++ b/pkg/services/friendships.go @@ -11,8 +11,7 @@ import ( func ListFriend(anyside models.Account, status models.FriendshipStatus) ([]models.AccountFriendship, error) { var relationships []models.AccountFriendship if err := database.C. - Where(&models.AccountFriendship{AccountID: anyside.ID, Status: status}). - Or(&models.AccountFriendship{RelatedID: anyside.ID, Status: status}). + Where("(account_id = ? OR related_id = ?) AND status = ?", anyside.ID, anyside.ID, status). Preload("Account"). Preload("Related"). Find(&relationships).Error; err != nil {