SanzaGemini / Stores-Inventory

0 stars 0 forks source link

Implement POST Method for Adding Product to Inventory #8

Open SanzaGemini opened 1 week ago

SanzaGemini commented 1 week ago

Description:

Create an endpoint that allows users to add new products to the existing inventory database. This feature should validate the input and respond with appropriate success or error messages.

Acceptance Criteria:

  1. Endpoint Creation:

    • A POST endpoint /api/products is created.
  2. Request Payload:

    • The request should accept a JSON body containing:
      • name (String, required)
      • description (String, optional)
      • price (Decimal, required)
      • quantity (Integer, required)
  3. Validation:

    • Ensure that:
      • name is not empty.
      • price is a positive number.
      • quantity is a non-negative integer.
  4. Database Interaction:

    • On successful validation, a new product should be added to the inventory database.
    • Use JPA/Hibernate for database interactions.
  5. Response:

    • On success, return HTTP status 201 (Created) with the newly created product details.
    • On validation failure, return HTTP status 400 (Bad Request) with error messages.
  6. Error Handling:

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

Tasks: