1
0
forked from s434786/DINO_SCRUM
DINO_SCRUM/README.md

247 lines
4.2 KiB
Markdown
Raw Normal View History

2019-01-22 03:49:08 +01:00
# DINO\_SCRUM
2019-01-10 20:57:47 +01:00
2019-01-22 19:02:52 +01:00
## MODEL
2019-01-22 03:49:08 +01:00
2019-01-22 19:02:52 +01:00
###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;
2019-01-22 03:49:08 +01:00
2019-01-22 19:02:52 +01:00
``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).
2019-01-22 03:49:08 +01:00
```json
2019-01-22 19:02:52 +01:00
POST /api/product/change-quantity
Content-Type: application/json
2019-01-22 03:49:08 +01:00
{
"id": Int,
"change": Int
}
```
2019-01-22 19:02:52 +01:00
Response `HttpStatus.OK` with ``JSON``:
2019-01-22 03:49:08 +01:00
```json
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
```
* * *
2019-01-22 19:02:52 +01:00
###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`.
2019-01-22 03:49:08 +01:00
2019-01-22 19:02:52 +01:00
```json
GET /api/get-all?page=0&size=1&sort=id
Content-Type: application/json
```
Response with ``HttpStatus.OK`` with ``JSON`` :
2019-01-22 03:49:08 +01:00
```json
{
"content": [
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
2019-01-22 19:02:52 +01:00
"imageLink": string
},
2019-01-22 03:49:08 +01:00
{
(...)
}
],
"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
}
```
* * *
2019-01-22 19:02:52 +01:00
###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.
2019-01-22 03:49:08 +01:00
2019-01-22 19:02:52 +01:00
```json
GET /api/get-price-of-all
Content-Type: application/json
```
Response ``Http.Status.OK`` with ``JSON``:
2019-01-22 03:49:08 +01:00
```json
{
"price-of-all": Float
}
```
* * *
2019-01-22 19:02:52 +01:00
###Create a new product.
The service will handle `POST` request `/api/product/add`, by adding `Product` to database.
2019-01-22 03:49:08 +01:00
```json
2019-01-22 19:02:52 +01:00
POST /api/product/add
Content-Type: application/json
2019-01-22 03:49:08 +01:00
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
```
2019-01-22 19:02:52 +01:00
Response `HttpStatus.CREATED` with `JSON`
2019-01-22 03:49:08 +01:00
```json
2019-01-22 19:02:52 +01:00
2019-01-22 03:49:08 +01:00
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
```
* * *
2019-01-22 19:02:52 +01:00
###Delete product with `id`.
The service will handle `DELETE` request `/api/delete-product`, by
2019-01-22 03:49:08 +01:00
```json
2019-01-22 19:02:52 +01:00
DELETE /api/delete-product
Content-Type: application/json
2019-01-22 03:49:08 +01:00
{
"id": Int
}
2019-01-22 19:02:52 +01:00
2019-01-22 03:49:08 +01:00
```
2019-01-22 19:02:52 +01:00
```json
2019-01-22 03:49:08 +01:00
2019-01-22 19:02:52 +01:00
Response: HttpStatus.OK
2019-01-22 03:49:08 +01:00
2019-01-22 19:02:52 +01:00
```
2019-01-22 03:49:08 +01:00
* * *
2019-01-22 19:02:52 +01:00
###Get product with `id`
The service wil handle `GET` request `/api/product/get-by-id`, by returning product with `id`.
2019-01-22 03:49:08 +01:00
```json
2019-01-22 19:02:52 +01:00
GET /api/product/get-by-id
Content-Type: application/json
2019-01-22 03:49:08 +01:00
{
"id": Int
}
```
2019-01-22 19:02:52 +01:00
Response ``Http.Status.OK`` with `JSON`:
2019-01-22 03:49:08 +01:00
```json
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
```
* * *
2019-01-22 19:02:52 +01:00
###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`.
2019-01-22 03:49:08 +01:00
```json
2019-01-22 19:02:52 +01:00
POST /api/product/update/{id}
Content-Type: application/json
2019-01-22 03:49:08 +01:00
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
```
2019-01-22 19:02:52 +01:00
Response ``Http.Status.OK`` with `JSON`:
2019-01-22 03:49:08 +01:00
```json
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
2019-01-22 19:02:52 +01:00
```