diff --git a/pkg/common/db/relation/friend_request_model.go b/pkg/common/db/relation/friend_request_model.go index bc04b27f8..9cb30ecbf 100644 --- a/pkg/common/db/relation/friend_request_model.go +++ b/pkg/common/db/relation/friend_request_model.go @@ -31,13 +31,13 @@ func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID str } // 更新零值 -func (f *FriendRequestGorm) UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]interface{}) (err error) { - return utils.Wrap(f.db(ctx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? AND to_user_id =?", formUserID, toUserID).Updates(args).Error, "") +func (f *FriendRequestGorm) UpdateByMap(ctx context.Context, fromUserID string, toUserID string, args map[string]interface{}) (err error) { + return utils.Wrap(f.db(ctx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? AND to_user_id =?", fromUserID, toUserID).Updates(args).Error, "") } -// 更新多条记录 (非零值) -func (f *FriendRequestGorm) Update(ctx context.Context, friendRequests *relation.FriendRequestModel) (err error) { - return utils.Wrap(f.db(ctx).Updates(friendRequests).Error, "") +// 更新记录 (非零值) +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/table/relation/friend_request.go b/pkg/common/db/table/relation/friend_request.go index 998a76719..b14ecb2c2 100644 --- a/pkg/common/db/table/relation/friend_request.go +++ b/pkg/common/db/table/relation/friend_request.go @@ -31,7 +31,7 @@ type FriendRequestModelInterface interface { // 更新零值 UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]interface{}) (err error) // 更新多条记录 (非零值) - Update(ctx context.Context, friendRequests *FriendRequestModel) (err error) + Update(ctx context.Context, friendRequest *FriendRequestModel) (err error) // 获取来指定用户的好友申请 未找到 不返回错误 Find(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error) Take(ctx context.Context, fromUserID, toUserID string) (friendRequest *FriendRequestModel, err error)