The Product API
service manages product-related operations such as adding, retrieving, and updating product details. It is part of the organization's microservices architecture.
The Product API
provides functionality for:
- Adding new products.
- Retrieving product details by ID, code, or a list of IDs.
- Updating product information.
- URL:
/product
- Method:
POST
- Description: Adds a new product.
- Request Body:
{ "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" }
- Response:
{ "id": "long", "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" }
- Response Code:
201 Created
- URL:
/product/{id}
- Method:
GET
- Description: Retrieves a product by its ID.
- Path Variable:
id
(Long) - Response:
{ "id": "long", "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" }
- Response Code:
200 OK
- URL:
/product?code={code}
- Method:
GET
- Description: Retrieves a product by its unique code.
- Request Param:
code
(String) - Response:
{ "id": "long", "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" }
- Response Code:
200 OK
- URL:
/product?ids={ids}
- Method:
GET
- Description: Retrieves a list of products by their IDs.
- Request Param:
ids
(Set of Longs) - Response:
[ { "id": "long", "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" } ]
- Response Code:
200 OK
- URL:
/product
- Method:
GET
- Description: Retrieves a list of all products.
- Response:
[ { "id": "long", "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" } ]
- Response Code:
200 OK
- URL:
/product/{id}
- Method:
PUT
- Description: Updates an existing product by ID.
- Path Variable:
id
(Long) - Request Body:
{ "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" }
- Response:
{ "id": "long", "code": "string", "name": "string", "description": "string", "price": "number", "image": "string" }
- Response Code:
200 OK
- Configure the database connection in the
application.properties
file:spring.datasource.url=jdbc:mysql://localhost:3306/your_database_name spring.datasource.username=your_db_username spring.datasource.password=your_db_password