Skip to content

Commit

Permalink
fix: 修改删除好友条件校验
Browse files Browse the repository at this point in the history
  • Loading branch information
danmuking committed Apr 22, 2024
1 parent a19ba7f commit c99ba5c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion service/friend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,21 @@ func DeleteFriendService(uid int64, deleteFriendReq req.DeleteFriendReq) (resp.R

contact := global.Query.Contact
contactTx := tx.Contact.WithContext(ctx)
if _, err := contactTx.Where(contact.RoomID.Eq(roomFriendR.RoomID)).Delete(); err != nil {
resultInfo, err := contactTx.Where(contact.RoomID.Eq(roomFriendR.RoomID)).Delete()
if err != nil {
if err := tx.Rollback(); err != nil {
global.Logger.Errorf("事务回滚失败 %s", err.Error())
}
global.Logger.Errorf("删除会话失败 %s", err.Error())
return resp.ErrorResponseData("删除好友失败"), errors.New("Business Error")
}
if resultInfo.RowsAffected == 0 {
if err := tx.Rollback(); err != nil {
global.Logger.Errorf("事务回滚失败 %s", err.Error())
}
global.Logger.Errorf("会话不存在 %d", roomFriendR.RoomID)
return resp.ErrorResponseData("删除好友失败"), errors.New("Business Error")
}
// TODO:删除缓存

// 发送消息
Expand Down

0 comments on commit c99ba5c

Please sign in to comment.