fix(delete): update delete operations to return affected rows for cabinets, rooms, and warehouses

This commit is contained in:
Tran Anh Tuan
2026-05-08 15:54:28 +07:00
parent 58cfe890a1
commit 4382c53aac
15 changed files with 75 additions and 36 deletions

View File

@@ -172,12 +172,16 @@ func RoomDelete(c *gin.Context) error {
response.BadRequestError(c, http.StatusBadRequest, "Invalid ID")
return nil
}
err = repositories.DeleteRoom(c.Request.Context(), global.Queries, id)
rowsAffected, err := repositories.DeleteRoom(c.Request.Context(), global.Queries, id)
if err != nil {
log.Error().Err(err).Msgf("Failed to delete room with ID: %d", id)
if rowsAffected == 0 {
response.NotFoundError(c, http.StatusNotFound, "Room not found")
return nil
}
response.InternalServerError(c, http.StatusInternalServerError, "Failed to delete room")
return nil
}
response.Ok(c, "Đã xóa thành công", nil)
response.Ok(c, "Delete Success", nil)
return nil
}