1
0
forked from s434786/DINO_SCRUM
DINO_SCRUM
Go to file
2019-01-22 20:21:36 +01:00
.idea update readme.md 2019-01-22 19:02:52 +01:00
.mvn/wrapper all 2019-01-13 18:41:23 +01:00
src fix default page size in /get-all 2019-01-22 20:21:36 +01:00
target ignore 2019-01-22 04:33:32 +01:00
.gitignore ignore 2019-01-22 04:33:32 +01:00
init initialized backend branch 2019-01-13 19:49:28 +01:00
mvnw all 2019-01-13 18:41:23 +01:00
mvnw.cmd all 2019-01-13 18:41:23 +01:00
pom.xml all 2019-01-13 18:41:23 +01:00
README.md update readme.md 2019-01-22 19:02:52 +01:00
sysmag.iml all 2019-01-13 18:41:23 +01:00

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 HttpStatus.OK 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 with HttpStatus.OK 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 Http.Status.OK 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 HttpStatus.CREATED 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: HttpStatus.OK


###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 Http.Status.OK 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 Http.Status.OK with JSON:

{
 "id": Int,
 "name": String,
 "price": Float,
 "quantity": Int,
 "quantityMax": Int,
 "imageLink": String
}