fix(delete): update delete operations to return affected rows for cabinets, rooms, and warehouses
This commit is contained in:
@@ -173,11 +173,11 @@ func CabinetDelete(c *gin.Context) error {
|
|||||||
}
|
}
|
||||||
rowsAffected, err := repositories.DeleteCabinet(c.Request.Context(), global.Queries, id)
|
rowsAffected, err := repositories.DeleteCabinet(c.Request.Context(), global.Queries, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if rowsAffected == 0 {
|
response.InternalServerError(c, http.StatusInternalServerError, "Failed to delete cabinet")
|
||||||
response.NotFoundError(c, http.StatusNotFound, "Cabinet not found")
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
response.InternalServerError(c, http.StatusInternalServerError, "Failed to delete cabinet")
|
if rowsAffected == 0 {
|
||||||
|
response.NotFoundError(c, http.StatusNotFound, "Cabinet not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,11 +175,11 @@ func RoomDelete(c *gin.Context) error {
|
|||||||
rowsAffected, err := repositories.DeleteRoom(c.Request.Context(), global.Queries, id)
|
rowsAffected, err := repositories.DeleteRoom(c.Request.Context(), global.Queries, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msgf("Failed to delete room with ID: %d", id)
|
log.Error().Err(err).Msgf("Failed to delete room with ID: %d", id)
|
||||||
if rowsAffected == 0 {
|
response.InternalServerError(c, http.StatusInternalServerError, "Failed to delete room")
|
||||||
response.NotFoundError(c, http.StatusNotFound, "Room not found")
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
response.InternalServerError(c, http.StatusInternalServerError, "Failed to delete room")
|
if rowsAffected == 0 {
|
||||||
|
response.NotFoundError(c, http.StatusNotFound, "Room not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
response.Ok(c, "Delete Success", nil)
|
response.Ok(c, "Delete Success", nil)
|
||||||
|
|||||||
@@ -165,11 +165,12 @@ func WareHouseDelete(c *gin.Context) error {
|
|||||||
rowsAffected, err := repositories.DeleteWarehouse(c.Request.Context(), global.Queries, id)
|
rowsAffected, err := repositories.DeleteWarehouse(c.Request.Context(), global.Queries, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msgf("Failed to delete warehouse with ID: %d", id)
|
log.Error().Err(err).Msgf("Failed to delete warehouse with ID: %d", id)
|
||||||
if rowsAffected == 0 {
|
|
||||||
response.NotFoundError(c, http.StatusNotFound, "Warehouse not found")
|
response.InternalServerError(c, http.StatusInternalServerError, "Failed to delete warehouse")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
response.InternalServerError(c, http.StatusInternalServerError, "Failed to delete warehouse")
|
if rowsAffected == 0 {
|
||||||
|
response.NotFoundError(c, http.StatusNotFound, "Warehouse not found")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
response.Ok(c, "Delete Success", nil)
|
response.Ok(c, "Delete Success", nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user