diff --git a/pkg/common/db/controller/friend.go b/pkg/common/db/controller/friend.go index 69db8dd6e..a1cb547bf 100644 --- a/pkg/common/db/controller/friend.go +++ b/pkg/common/db/controller/friend.go @@ -209,6 +209,7 @@ func (f *friendDatabase) RefuseFriendRequest( if fr.HandleResult != 0 { return errs.ErrArgs.Wrap("the friend request has been processed") } + log.ZDebug(ctx, "refuse friend request", "friendRequest db", fr, "friendRequest arg", friendRequest) friendRequest.HandleResult = constant.FriendResponseRefuse friendRequest.HandleTime = time.Now() err = f.friendRequest.Update(ctx, friendRequest) diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go index 0abb06b44..7a1f98715 100644 --- a/pkg/common/db/relation/friend_request_model.go +++ b/pkg/common/db/relation/friend_request_model.go @@ -71,9 +71,13 @@ func (f *FriendRequestGorm) UpdateByMap( // 更新记录 (非零值). func (f *FriendRequestGorm) Update(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) { + fromUserID := friendRequest.FromUserID + toUserID := friendRequest.ToUserID + friendRequest.FromUserID = "" + friendRequest.ToUserID = "" return utils.Wrap( f.db(ctx). - Where("from_user_id = ? AND to_user_id =?", friendRequest.FromUserID, friendRequest.ToUserID). + Where("from_user_id = ? AND to_user_id =?", fromUserID, 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 }