.idea | ||
.mvn/wrapper | ||
src | ||
target | ||
.gitignore | ||
init | ||
mvnw | ||
mvnw.cmd | ||
pom.xml | ||
README.md | ||
sysmag.iml |
DINO_SCRUM
MODEL
Product
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
id
- id of product,
name
- name of product with minimal length 2;
price
price of product, cannot be under 0.00;
quantity
: quantity of product in database, cannot be under 0;
quantityMax
: maximum quantity of product in database, cannot be under 0;
imageLink
: link to image of product
Any of these couldn't be null
API
Edit quantity of the product.
The service will handle POST
requests for /api/product/change-quantity
, by changing quantity of product in database.
id
- product's to change id
change
- value of change (positive value for increase quantity, negative valude for decrease).
POST /api/product/change-quantity
Content-Type: application/json
{
"id": Int,
"change": Int
}
Response 200
with JSON
:
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
Retrieve a paginated list of products
The service will handle GET
requests for /api/get-all
, by retreving a paginated list of products. Optionally with a page
, size
or page
, size
andsort
parameters in the query string.
Page start numbering on page=0
. Default list is sorted by id
.
GET /api/get-all?page=0&size=1&sort=id
Content-Type: application/json
Response 200
with JSON
:
{
"content": [
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": string
},
{
(...)
}
],
"pageable": {
"sort": {
"sorted": Boolean,
"unsorted": Boolean,
"empty": Boolean
},
"offset": Int,
"pageSize": Int,
"pageNumber": Int,
"unpaged": Boolean,
"paged": Boolean
},
"totalPages": Int,
"totalElements": Int,
"last": Boolean,
"size": Int,
"number": Int,
"numberOfElements": Int,
"first": Boolean,
"sort": {
"sorted": Boolean,
"unsorted": Boolean,
"empty": Boolean
},
"empty": Boolean
}
Get price of all products.
The service will handle GET
request on /api/get-price-of-all
returing Float
price of all products in the database.
GET /api/get-price-of-all
Content-Type: application/json
Response 200
with JSON
:
{
"price-of-all": Float
}
Create a new product.
The service will handle POST
request /api/product/add
, by adding Product
to database.
POST /api/product/add
Content-Type: application/json
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
Response 201
with JSON
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
Delete product with id
.
The service will handle DELETE
request /api/delete-product
, by
DELETE /api/delete-product
Content-Type: application/json
{
"id": Int
}
Response: 200
Get product with id
The service wil handle GET
request /api/product/get-by-id
, by returning product with id
.
GET /api/product/get-by-id
Content-Type: application/json
{
"id": Int
}
Response 200
with JSON
:
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
Update product
The service will handle POST
request /api/product/update/{id}
with path variable id
, by updating existing product. In request
id
is required, fields which won't be modified should be null
.
POST /api/product/update/{id}
Content-Type: application/json
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
Response 200
with JSON
:
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}