forked from s434786/DINO_SCRUM
48f36a188b
# Conflicts: # README.md
246 lines
4.1 KiB
Markdown
246 lines
4.1 KiB
Markdown
# DINO\_SCRUM
|
|
|
|
## MODEL
|
|
|
|
### Product
|
|
```json5
|
|
{
|
|
"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).
|
|
|
|
|
|
```json
|
|
POST /api/product/change-quantity
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"id": Int,
|
|
"change": Int
|
|
}
|
|
```
|
|
|
|
Response `200` with `JSON`:
|
|
|
|
```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` and`sort` parameters in the query string.
|
|
Page start numbering on `page=0`. Default list is sorted by `id`.
|
|
|
|
|
|
```json
|
|
GET /api/get-all?page=0&size=1&sort=id
|
|
Content-Type: application/json
|
|
```
|
|
Response `200` with `JSON`:
|
|
|
|
|
|
```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.
|
|
|
|
```json
|
|
GET /api/get-price-of-all
|
|
Content-Type: application/json
|
|
```
|
|
Response `200` with `JSON`:
|
|
|
|
```json
|
|
{
|
|
"price-of-all": Float
|
|
}
|
|
```
|
|
|
|
|
|
* * *
|
|
### Create a new product.
|
|
The service will handle `POST` request `/api/product/add`, by adding `Product` to database.
|
|
|
|
```json
|
|
POST /api/product/add
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"id": Int,
|
|
"name": String,
|
|
"price": Float,
|
|
"quantity": Int,
|
|
"quantityMax": Int,
|
|
"imageLink": String
|
|
}
|
|
```
|
|
Response `201` with `JSON`
|
|
|
|
```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
|
|
|
|
```json
|
|
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`.
|
|
|
|
```json
|
|
GET /api/product/get-by-id
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"id": Int
|
|
}
|
|
```
|
|
|
|
Response `200` with `JSON`:
|
|
|
|
```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`.
|
|
|
|
|
|
```json
|
|
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`:
|
|
|
|
```json
|
|
{
|
|
"id": Int,
|
|
"name": String,
|
|
"price": Float,
|
|
"quantity": Int,
|
|
"quantityMax": Int,
|
|
"imageLink": String
|
|
}
|
|
``` |