Task Definition
Objective: Develop a web API to manage product entries with the following functionalities:
Add Product:
Input fields include in form:
Product Name
Category Name
Sale Price
Color
Quantity
Manufacture Price
Product Code (must be unique and exactly 6 digits, zero-padded)
Product Images (support for multiple images)
Description:
Validation:
Ensure the Product Code is unique in the database. If a duplicate code is entered, return an error
message.
Format the Product Code to always display as 6 digits (e.g., input 1 should be stored as 000001).
Profit Calculation:
Automatically calculate profit for each product using the formula: Profit = Sale Price - Manufacture Price.
Return the calculated profit along with the product details upon successful addition.
Image Handling:
Allow users to associate multiple images with a single product.
Suggested API Endpoints
Add Product: Endpoint to create a new product entry.
Get Product Details: Endpoint to retrieve details of a product.
Update Product: Endpoint to modify an existing product’s details.
Delete Product: Endpoint to remove a product from the database.
List Products: Endpoint to retrieve a list of all products with optional filtering options. we can search on
any field.
Add Category: Endpoint to create a new category.
Get Categories: Endpoint to retrieve a list of all categories.
Update Category: Endpoint to modify an existing category.
Delete Category: Endpoint to remove a category from the database.(with checks to ensure it's not in use
in product.)
Make sure, that you follow the coding standard.