|
|
@@ -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 获取好友列表 |
|
|
|