From 8e46e7eb8b9c008bc4697657c8c63dfeab6c1263 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 30 Nov 2022 19:02:01 +0800 Subject: [PATCH] update --- internal/logic/domain/friend/friend_repo.go | 14 ++++++++++++-- test/tcp_conn/main.go | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/logic/domain/friend/friend_repo.go b/internal/logic/domain/friend/friend_repo.go index 570801d..28f39fd 100644 --- a/internal/logic/domain/friend/friend_repo.go +++ b/internal/logic/domain/friend/friend_repo.go @@ -30,9 +30,19 @@ func (*friendRepo) Save(friend *Friend) error { } // Delete 删除好友 -func (*friendRepo) Delete(userId, friendId int64) error { +func (*friendRepo) Delete(userId, friendId int64) (err error) { friend := Friend{} - return gerrors.WrapError(db.DB.Where("user_id = ? and friend_id = ?", userId, friendId).Delete(&friend).Error) + //1、正向删除自己这一方 + err = gerrors.WrapError(db.DB.Where("user_id = ? and friend_id = ?", userId, friendId).Delete(&friend).Error) + if err != nil { + return err + } + //2、反向删除好友这一方 + err = gerrors.WrapError(db.DB.Where("user_id = ? and friend_id = ?", friendId, userId).Delete(&friend).Error) + if err != nil { + return err + } + return nil } // List 获取好友列表 diff --git a/test/tcp_conn/main.go b/test/tcp_conn/main.go index da2c5d5..a6e93d3 100644 --- a/test/tcp_conn/main.go +++ b/test/tcp_conn/main.go @@ -87,7 +87,7 @@ func (c *TcpClient) SignIn() { signIn := pb.SignInInput{ UserId: c.UserId, DeviceId: c.DeviceId, - Token: "RRTTGFUKCAQGAIDXMITFIBPMZOVSYDQQUQRZNMYG", + Token: "JNSTQKMVVIEBWQWEILZXIZJILHBUWHUUNWPLZYDF", } c.Output(pb.PackageType_PT_SIGN_IN, time.Now().UnixNano(), &signIn) }