SanzaGemini / Stores-Inventory

0 stars 0 forks source link

Implement DELETE Method for Removing Product from Inventory #9

Open SanzaGemini opened 1 week ago

SanzaGemini commented 1 week ago

Description:

Create an endpoint that allows users to delete a product from the existing inventory database by its ID. This feature should validate the request and respond with appropriate success or error messages.

Acceptance Criteria:

  1. Endpoint Creation:

    • A DELETE endpoint /api/products/{id} is created, where {id} is the product's unique identifier.
  2. Request Parameter:

    • The endpoint accepts a path variable id (Long, required).
  3. Validation:

    • Check if the product with the given ID exists in the database.
    • If the product does not exist, return an appropriate error response.
  4. Database Interaction:

    • On successful validation, the product should be removed from the inventory database.
    • Use JPA/Hibernate for database interactions.
  5. Response:

    • On success, return HTTP status 204 (No Content).
    • If the product does not exist, return HTTP status 404 (Not Found).
  6. Error Handling:

    • Handle database errors and return appropriate responses (e.g., 500 Internal Server Error).

Tasks: