forked from s434786/DINO_SCRUM
update readme.md
This commit is contained in:
parent
45dea34ef2
commit
58732fe0c9
@ -5,6 +5,7 @@
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/target/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
@ -82,8 +83,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="411">
|
||||
<caret line="70" column="51" lean-forward="true" selection-start-line="70" selection-start-column="51" selection-end-line="70" selection-end-column="51" />
|
||||
<state relative-caret-position="627">
|
||||
<caret line="81" column="37" lean-forward="true" selection-start-line="81" selection-start-column="37" selection-end-line="81" selection-end-column="37" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@ -91,7 +92,7 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="229">
|
||||
@ -103,8 +104,8 @@
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="678">
|
||||
<caret line="88" column="34" selection-start-line="88" selection-start-column="34" selection-end-line="88" selection-end-column="34" />
|
||||
<state relative-caret-position="333">
|
||||
<caret line="80" column="19" selection-start-line="80" selection-start-column="19" selection-end-line="80" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@ -112,20 +113,11 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="225">
|
||||
<caret line="15" selection-start-line="15" selection-end-line="15" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="333">
|
||||
<caret line="28" lean-forward="true" selection-start-line="28" selection-end-line="52" />
|
||||
<state relative-caret-position="413">
|
||||
<caret line="54" column="74" selection-start-line="54" selection-start-column="74" selection-end-line="54" selection-end-column="74" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@ -133,36 +125,30 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/pom.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="555">
|
||||
<caret line="37" column="21" selection-start-line="37" selection-start-column="21" selection-end-line="37" selection-end-column="21" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="265">
|
||||
<caret line="97" column="3" lean-forward="true" selection-start-line="97" selection-start-column="3" selection-end-line="97" selection-end-column="3" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="364">
|
||||
<caret line="177" column="8" selection-start-line="177" selection-start-column="8" selection-end-line="177" selection-end-column="8" />
|
||||
<first_editor relative-caret-position="114">
|
||||
<caret line="182" column="7" selection-start-line="182" selection-start-column="7" selection-end-line="182" selection-end-column="7" />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="295">
|
||||
<caret line="31" column="40" selection-start-line="31" selection-start-column="40" selection-end-line="31" selection-end-column="40" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
@ -198,16 +184,16 @@
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/exception/ProductNotFoundException.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/QuantityChangeValidator.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/resources/application.properties" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java" />
|
||||
<option value="$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" />
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/.gitignore" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -405,7 +391,7 @@
|
||||
<updated>1547322958782</updated>
|
||||
<workItem from="1547322960420" duration="21872000" />
|
||||
<workItem from="1547401179909" duration="33384000" />
|
||||
<workItem from="1548159944175" duration="5909000" />
|
||||
<workItem from="1548159944175" duration="9590000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="added quantityChange validation, product validation, checking existing object in db, throwing exeption">
|
||||
<created>1548121370553</created>
|
||||
@ -456,11 +442,25 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1548128323215</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="8" />
|
||||
<task id="LOCAL-00008" summary="fix exists valid">
|
||||
<created>1548176403757</created>
|
||||
<option name="number" value="00008" />
|
||||
<option name="presentableId" value="LOCAL-00008" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1548176403757</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00009" summary="fix changeQuantity">
|
||||
<created>1548177602799</created>
|
||||
<option name="number" value="00009" />
|
||||
<option name="presentableId" value="LOCAL-00009" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1548177602799</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="10" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="61165000" />
|
||||
<option name="totallyTimeSpent" value="64846000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
@ -489,7 +489,7 @@
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" weight="0.32941177" />
|
||||
<window_info anchor="bottom" id="Spring" order="7" sideWeight="0.4993895" weight="0.32941177" />
|
||||
<window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.497558" weight="0.44919786" />
|
||||
<window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.497558" weight="0.35187167" />
|
||||
<window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Event Log" order="10" sideWeight="0.502442" side_tool="true" weight="0.44919786" />
|
||||
<window_info anchor="bottom" id="Messages" order="11" weight="0.32941177" />
|
||||
@ -497,7 +497,7 @@
|
||||
<window_info anchor="bottom" id="Database Changes" order="13" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Version Control" order="14" sideWeight="0.498779" weight="0.32941177" />
|
||||
<window_info anchor="bottom" id="SVN Repositories" order="15" weight="0.32941177" />
|
||||
<window_info active="true" anchor="bottom" id="Database Console" order="16" sideWeight="0.498779" visible="true" weight="0.5893048" />
|
||||
<window_info anchor="bottom" id="Database Console" order="16" sideWeight="0.498779" weight="0.5893048" />
|
||||
<window_info anchor="right" id="Commander" order="0" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
@ -562,7 +562,9 @@
|
||||
<MESSAGE value="Merge branch 'backend' of https://git.wmi.amu.edu.pl/s434786/DINO_SCRUM # Conflicts: #	README.md" />
|
||||
<MESSAGE value="a" />
|
||||
<MESSAGE value="fix ignore" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fix ignore" />
|
||||
<MESSAGE value="fix exists valid" />
|
||||
<MESSAGE value="fix changeQuantity" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fix changeQuantity" />
|
||||
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
<option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" />
|
||||
@ -633,35 +635,9 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/QuantityChangeValidator.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="195">
|
||||
<caret line="13" column="13" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/d0158af3-b28d-407c-b7c8-7331568f6f97/console.sql">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-5">
|
||||
<caret line="13" column="4" selection-start-line="13" selection-start-column="4" selection-end-line="13" selection-end-column="4" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#438#439#0" expanded="true" />
|
||||
<element signature="e#496#497#0" expanded="true" />
|
||||
<element signature="e#234#235#0" expanded="true" />
|
||||
<element signature="e#289#290#0" expanded="true" />
|
||||
<element signature="e#351#352#0" expanded="true" />
|
||||
<element signature="e#410#411#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="300">
|
||||
@ -682,13 +658,6 @@
|
||||
<entry file="file://$PROJECT_DIR$/init">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="225">
|
||||
<caret line="15" selection-start-line="15" selection-end-line="15" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pom.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="555">
|
||||
@ -710,10 +679,34 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java">
|
||||
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="678">
|
||||
<caret line="88" column="34" selection-start-line="88" selection-start-column="34" selection-end-line="88" selection-end-column="34" />
|
||||
<state relative-caret-position="229">
|
||||
<caret line="59" lean-forward="true" selection-start-line="59" selection-end-line="59" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/QuantityChangeValidator.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="315">
|
||||
<caret line="23" column="16" selection-start-line="23" selection-start-column="16" selection-end-line="23" selection-end-column="16" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="225">
|
||||
<caret line="15" selection-start-line="15" selection-end-line="15" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="295">
|
||||
<caret line="31" column="40" selection-start-line="31" selection-start-column="40" selection-end-line="31" selection-end-column="40" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@ -722,8 +715,8 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="333">
|
||||
<caret line="28" lean-forward="true" selection-start-line="28" selection-end-line="52" />
|
||||
<state relative-caret-position="413">
|
||||
<caret line="54" column="74" selection-start-line="54" selection-start-column="74" selection-end-line="54" selection-end-column="74" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@ -732,8 +725,18 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="411">
|
||||
<caret line="70" column="51" lean-forward="true" selection-start-line="70" selection-start-column="51" selection-end-line="70" selection-end-column="51" />
|
||||
<state relative-caret-position="627">
|
||||
<caret line="81" column="37" lean-forward="true" selection-start-line="81" selection-start-column="37" selection-end-line="81" selection-end-column="37" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="333">
|
||||
<caret line="80" column="19" selection-start-line="80" selection-start-column="19" selection-end-line="80" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
@ -743,20 +746,13 @@
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="364">
|
||||
<caret line="177" column="8" selection-start-line="177" selection-start-column="8" selection-end-line="177" selection-end-column="8" />
|
||||
<first_editor relative-caret-position="114">
|
||||
<caret line="182" column="7" selection-start-line="182" selection-start-column="7" selection-end-line="182" selection-end-column="7" />
|
||||
</first_editor>
|
||||
<second_editor />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="229">
|
||||
<caret line="59" lean-forward="true" selection-start-line="59" selection-end-line="59" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
|
180
README.md
180
README.md
@ -1,19 +1,54 @@
|
||||
# DINO\_SCRUM
|
||||
|
||||
DINO\_SCRUM
|
||||
## MODEL
|
||||
|
||||
## API Endpoints
|
||||
###Product
|
||||
```json5
|
||||
{
|
||||
"id": Int,
|
||||
"name": String,
|
||||
"price": Float,
|
||||
"quantity": Int,
|
||||
"quantityMax": Int,
|
||||
"imageLink": String
|
||||
}
|
||||
```
|
||||
``id`` - id of product,
|
||||
|
||||
*POST* **/api/product/change-quantity**
|
||||
``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
|
||||
}
|
||||
```
|
||||
|
||||
Return:
|
||||
Response `HttpStatus.OK` with ``JSON``:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -26,27 +61,20 @@ Return:
|
||||
}
|
||||
```
|
||||
|
||||
Edit quantity and return the product.
|
||||
|
||||
* * *
|
||||
|
||||
*GET* **/api/get-all**
|
||||
###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`.
|
||||
|
||||
Return all products sorted by id.
|
||||
|
||||
*GET* **/api/get-all?page=X&size=Y**
|
||||
|
||||
Return page *X* with size *Y* of all products sorted by id.
|
||||
|
||||
*GET* **/api/get-all?page=X&size=Y&sorted=Z**
|
||||
|
||||
Return page *X* with size *Y* of all products sorted by *Z* field.
|
||||
|
||||
*GET* **/api/get-all?sorted=Z**
|
||||
|
||||
Return all products sorted by *Z*.
|
||||
|
||||
Return:
|
||||
```json
|
||||
GET /api/get-all?page=0&size=1&sort=id
|
||||
Content-Type: application/json
|
||||
```
|
||||
Response with ``HttpStatus.OK`` with ``JSON`` :
|
||||
|
||||
```json
|
||||
{
|
||||
@ -57,8 +85,8 @@ Return:
|
||||
"price": Float,
|
||||
"quantity": Int,
|
||||
"quantityMax": Int,
|
||||
"imageLink": String
|
||||
}
|
||||
"imageLink": string
|
||||
},
|
||||
{
|
||||
(...)
|
||||
}
|
||||
@ -92,10 +120,14 @@ Return:
|
||||
```
|
||||
|
||||
* * *
|
||||
###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**
|
||||
|
||||
Return:
|
||||
```json
|
||||
GET /api/get-price-of-all
|
||||
Content-Type: application/json
|
||||
```
|
||||
Response ``Http.Status.OK`` with ``JSON``:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -103,13 +135,28 @@ Return:
|
||||
}
|
||||
```
|
||||
|
||||
Return price of all products.
|
||||
|
||||
* * *
|
||||
|
||||
*POST* **/api/product/add**
|
||||
###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 `HttpStatus.CREATED` with `JSON`
|
||||
|
||||
```json
|
||||
|
||||
{
|
||||
"id": Int,
|
||||
"name": String,
|
||||
@ -120,46 +167,62 @@ Return price of all products.
|
||||
}
|
||||
```
|
||||
|
||||
Return:
|
||||
* * *
|
||||
###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,
|
||||
"name": String,
|
||||
"price": Float,
|
||||
"quantity": Int,
|
||||
"quantityMax": Int,
|
||||
"imageLink": String
|
||||
"id": Int
|
||||
}
|
||||
|
||||
```
|
||||
```json
|
||||
|
||||
Create and return a new product.
|
||||
Response: HttpStatus.OK
|
||||
|
||||
```
|
||||
* * *
|
||||
|
||||
*DELETE* **/api/delete-product**
|
||||
###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
|
||||
}
|
||||
```
|
||||
|
||||
Delete product with id.
|
||||
Response ``Http.Status.OK`` with `JSON`:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": Int,
|
||||
"name": String,
|
||||
"price": Float,
|
||||
"quantity": Int,
|
||||
"quantityMax": Int,
|
||||
"imageLink": String
|
||||
}
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
*GET* **/api/product/get-by-id**
|
||||
###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
|
||||
{
|
||||
"id": Int
|
||||
}
|
||||
```
|
||||
POST /api/product/update/{id}
|
||||
Content-Type: application/json
|
||||
|
||||
Return:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": Int,
|
||||
"name": String,
|
||||
@ -170,13 +233,7 @@ Return:
|
||||
}
|
||||
```
|
||||
|
||||
Return product with id.
|
||||
|
||||
* * *
|
||||
|
||||
*POST* /api/product/update/{id}
|
||||
|
||||
Id is require, other field could be null.
|
||||
Response ``Http.Status.OK`` with `JSON`:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -187,19 +244,4 @@ Id is require, other field could be null.
|
||||
"quantityMax": Int,
|
||||
"imageLink": String
|
||||
}
|
||||
```
|
||||
|
||||
Return:
|
||||
|
||||
```json
|
||||
{
|
||||
"id": Int,
|
||||
"name": String,
|
||||
"price": Float,
|
||||
"quantity": Int,
|
||||
"quantityMax": Int,
|
||||
"imageLink": String
|
||||
}
|
||||
```
|
||||
|
||||
Return updated product.
|
||||
```
|
@ -48,9 +48,10 @@ public class ProductController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/product/add")
|
||||
public Product addProduct(@Valid @RequestBody Product product) {
|
||||
public ResponseEntity addProduct(@Valid @RequestBody Product product) {
|
||||
try {
|
||||
return productService.add(product);
|
||||
productService.add(product);
|
||||
return new ResponseEntity(product, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
|
||||
}
|
||||
@ -60,7 +61,6 @@ public class ProductController {
|
||||
public ResponseEntity deleteProduct(@RequestBody IdDto id) {
|
||||
try {
|
||||
productService.delete(id.getId());
|
||||
// return "Deleted" + id;
|
||||
return new ResponseEntity("Deleted" + id, HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
|
||||
|
@ -43,11 +43,12 @@ public class ProductServiceImpl implements ProductService {
|
||||
@Override
|
||||
public Product changeQuantity(QuantityChange quantityChange) throws Exception {
|
||||
productValidator.checkIfExists(quantityChange.getId());
|
||||
System.out.println("id: " + quantityChange.getId() + " change: " + quantityChange.getChange());
|
||||
|
||||
Product product = productRepository.findById(quantityChange.getId());
|
||||
product.setChangeQuantity(quantityChange.getChange());
|
||||
productRepository.save(product);
|
||||
productRepository.save(
|
||||
productRepository.findById(quantityChange.getId())
|
||||
.setChangeQuantity(quantityChange.getChange())
|
||||
);
|
||||
|
||||
return productRepository.findById(quantityChange.getId());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user