From c046f5dfdcff59a7ecef1382abd223e4e968e7e0 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 10 Aug 2023 19:39:32 +0800 Subject: [PATCH] fix bug: fix_add_friend --- pkg/common/db/relation/friend_request_model.go | 1 + pkg/common/db/relation/meta_db.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go index 75a0e8d65..0abb06b44 100644 --- a/pkg/common/db/relation/friend_request_model.go +++ b/pkg/common/db/relation/friend_request_model.go @@ -73,6 +73,7 @@ func (f *FriendRequestGorm) UpdateByMap( func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) { return utils.Wrap( f.db(ctx). + Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID). Updates(friendRequest). Error, "", diff --git a/pkg/common/db/relation/meta_db.go b/pkg/common/db/relation/meta_db.go index 60e4a5464..6ab980120 100644 --- a/pkg/common/db/relation/meta_db.go +++ b/pkg/common/db/relation/meta_db.go @@ -33,5 +33,6 @@ func NewMetaDB(db *gorm.DB, table any) *MetaDB { } func (g *MetaDB) db(ctx context.Context) *gorm.DB { - return g.DB.WithContext(ctx).Model(g.table) + db := g.DB.WithContext(ctx).Model(g.table) + return db }