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) }