fix exists valid

This commit is contained in:
prgres 2019-01-22 18:00:03 +01:00
parent b80b51730c
commit 37cdc842ea
3 changed files with 149 additions and 95 deletions

View File

@ -1,22 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="2dc093a7-8382-4e31-b457-ce6c9fd10d13" name="Default Changelist" comment="a"> <list default="true" id="2dc093a7-8382-4e31-b457-ce6c9fd10d13" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/SysmagApplication.java" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/HomeController.java" beforeDir="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" /> <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/exception/ProductNotFoundException.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validationGroup/UpdateGroup.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/ProductValidator.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validator/QuantityChangeValidator.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/application.properties" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/test/java/com/dino/scrum/sysmag/SysmagApplicationTests.java" beforeDir="false" />
</list> </list>
<ignored path="$PROJECT_DIR$/target/" /> <ignored path="$PROJECT_DIR$/target/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -90,12 +78,12 @@
<select /> <select />
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="295"> <state relative-caret-position="411">
<caret line="85" column="9" selection-start-line="83" selection-start-column="30" selection-end-line="85" selection-end-column="9" /> <caret line="70" column="51" lean-forward="true" selection-start-line="70" selection-start-column="51" selection-end-line="70" selection-end-column="51" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@ -103,11 +91,11 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="true">
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql"> <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="64"> <state relative-caret-position="229">
<caret line="48" column="14" selection-start-line="48" selection-start-column="14" selection-end-line="48" selection-end-column="14" /> <caret line="59" lean-forward="true" selection-start-line="59" selection-end-line="59" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -124,15 +112,6 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/SysmagApplication.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/resources/application.properties"> <entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
@ -145,8 +124,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/Product.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221"> <state relative-caret-position="333">
<caret line="45" column="25" selection-start-line="45" selection-start-column="25" selection-end-line="45" selection-end-column="25" /> <caret line="28" lean-forward="true" selection-start-line="28" selection-end-line="52" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@ -157,17 +136,29 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/pom.xml"> <entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="108"> <state relative-caret-position="555">
<caret line="37" column="21" lean-forward="true" selection-start-line="37" selection-start-column="21" selection-end-line="37" selection-end-column="21" /> <caret line="37" column="21" selection-start-line="37" selection-start-column="21" selection-end-line="37" selection-end-column="21" />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.gitignore"> <entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="400"> <state relative-caret-position="265">
<caret line="106" lean-forward="true" selection-start-line="106" selection-end-line="106" /> <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">
<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>
<second_editor />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -212,10 +203,11 @@
<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/model/Product.java" />
<option value="$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql" /> <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/ProductService.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.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/service/ProductServiceImpl.java" />
<option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/.gitignore" /> <option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java" />
</list> </list>
</option> </option>
</component> </component>
@ -256,6 +248,7 @@
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" /> <pane id="Scope" />
<pane id="PackagesPane" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
@ -274,6 +267,48 @@
<item name="src" type="462c0819:PsiDirectoryNode" /> <item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" /> <item name="main" type="462c0819:PsiDirectoryNode" />
</path> </path>
<path>
<item name="sysmag" type="b2602c69:ProjectViewProjectNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sysmag" type="b2602c69:ProjectViewProjectNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sysmag" type="b2602c69:ProjectViewProjectNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="controller" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sysmag" type="b2602c69:ProjectViewProjectNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="model" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sysmag" type="b2602c69:ProjectViewProjectNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="validator" type="462c0819:PsiDirectoryNode" />
</path>
<path> <path>
<item name="sysmag" type="b2602c69:ProjectViewProjectNode" /> <item name="sysmag" type="b2602c69:ProjectViewProjectNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" /> <item name="sysmag" type="462c0819:PsiDirectoryNode" />
@ -285,7 +320,6 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="PackagesPane" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -370,7 +404,8 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1547322958782</updated> <updated>1547322958782</updated>
<workItem from="1547322960420" duration="21872000" /> <workItem from="1547322960420" duration="21872000" />
<workItem from="1547401179909" duration="33163000" /> <workItem from="1547401179909" duration="33384000" />
<workItem from="1548159944175" duration="5909000" />
</task> </task>
<task id="LOCAL-00001" summary="added quantityChange validation, product validation, checking existing object in db, throwing exeption"> <task id="LOCAL-00001" summary="added quantityChange validation, product validation, checking existing object in db, throwing exeption">
<created>1548121370553</created> <created>1548121370553</created>
@ -407,11 +442,25 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1548127778120</updated> <updated>1548127778120</updated>
</task> </task>
<option name="localTasksCounter" value="6" /> <task id="LOCAL-00006" summary="a">
<created>1548128278948</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1548128278948</updated>
</task>
<task id="LOCAL-00007" summary="fix ignore">
<created>1548128323215</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1548128323215</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="55035000" /> <option name="totallyTimeSpent" value="61165000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -426,13 +475,12 @@
<frame x="0" y="23" width="1680" height="1027" extended-state="6" /> <frame x="0" y="23" width="1680" height="1027" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.49810606" visible="true" weight="0.17948718" /> <window_info content_ui="combo" id="Project" order="0" sideWeight="0.49810606" weight="0.18131869" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Designer" order="2" /> <window_info id="Designer" order="2" />
<window_info id="UI Designer" order="3" /> <window_info id="UI Designer" order="3" />
<window_info id="Favorites" order="4" side_tool="true" /> <window_info id="Favorites" order="4" side_tool="true" />
<window_info id="Web" order="5" sideWeight="0.50189394" side_tool="true" weight="0.36842105" /> <window_info id="Web" order="5" sideWeight="0.50189394" side_tool="true" weight="0.36842105" />
<window_info anchor="bottom" id="Database Console" sideWeight="0.498779" weight="0.5893048" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" sideWeight="0.498779" weight="0.32941177" /> <window_info anchor="bottom" id="Find" order="1" sideWeight="0.498779" weight="0.32941177" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.498779" weight="0.3315508" /> <window_info anchor="bottom" id="Run" order="2" sideWeight="0.498779" weight="0.3315508" />
@ -441,14 +489,15 @@
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <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="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="Spring" order="7" sideWeight="0.4993895" weight="0.32941177" />
<window_info active="true" anchor="bottom" id="Terminal" order="8" sideWeight="0.4981685" visible="true" weight="0.44919786" /> <window_info anchor="bottom" id="Terminal" order="8" sideWeight="0.497558" weight="0.44919786" />
<window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" /> <window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="10" sideWeight="0.50183153" side_tool="true" visible="true" weight="0.44919786" /> <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" /> <window_info anchor="bottom" id="Messages" order="11" weight="0.32941177" />
<window_info anchor="bottom" id="Java Enterprise" order="12" /> <window_info anchor="bottom" id="Java Enterprise" order="12" />
<window_info anchor="bottom" id="Database Changes" order="13" show_stripe_button="false" /> <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="Version Control" order="14" sideWeight="0.498779" weight="0.32941177" />
<window_info anchor="bottom" id="SVN Repositories" order="15" 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="right" id="Commander" order="0" weight="0.4" /> <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" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@ -512,7 +561,8 @@
<MESSAGE value="fix pom.xml" /> <MESSAGE value="fix pom.xml" />
<MESSAGE value="Merge branch 'backend' of https://git.wmi.amu.edu.pl/s434786/DINO_SCRUM&#10;&#10;# Conflicts:&#10;#&#9;README.md" /> <MESSAGE value="Merge branch 'backend' of https://git.wmi.amu.edu.pl/s434786/DINO_SCRUM&#10;&#10;# Conflicts:&#10;#&#9;README.md" />
<MESSAGE value="a" /> <MESSAGE value="a" />
<option name="LAST_COMMIT_MESSAGE" value="a" /> <MESSAGE value="fix ignore" />
<option name="LAST_COMMIT_MESSAGE" value="fix ignore" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" /> <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" />
@ -612,13 +662,6 @@
</state> </state>
</provider> </provider>
</entry> </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="64">
<caret line="48" column="14" selection-start-line="48" selection-start-column="14" selection-end-line="48" selection-end-column="14" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductService.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300"> <state relative-caret-position="300">
@ -629,13 +672,16 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/SysmagApplication.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validationGroup/UpdateGroup.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75"> <state relative-caret-position="90">
<caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" /> <caret line="6" column="28" selection-start-line="6" selection-start-column="28" selection-end-line="6" selection-end-column="28" />
</state> </state>
</provider> </provider>
</entry> </entry>
<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"> <entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225"> <state relative-caret-position="225">
@ -643,6 +689,27 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<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>
<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>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/SysmagApplication.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="6" column="13" selection-start-line="6" selection-start-column="13" selection-end-line="6" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/service/ProductServiceImpl.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="678"> <state relative-caret-position="678">
@ -653,10 +720,20 @@
</state> </state>
</provider> </provider>
</entry> </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" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java"> <entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/ProductController.java">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="295"> <state relative-caret-position="411">
<caret line="85" column="9" selection-start-line="83" selection-start-column="30" selection-end-line="85" selection-end-column="9" /> <caret line="70" column="51" lean-forward="true" selection-start-line="70" selection-start-column="51" selection-end-line="70" selection-end-column="51" />
<folding> <folding>
<element signature="imports" expanded="true" /> <element signature="imports" expanded="true" />
</folding> </folding>
@ -666,42 +743,17 @@
<entry file="file://$PROJECT_DIR$/README.md"> <entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor /> <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>
<second_editor /> <second_editor />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validationGroup/UpdateGroup.java"> <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/4eb55351-864c-4d3f-b24d-048a158530c7/console.sql">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90"> <state relative-caret-position="229">
<caret line="6" column="28" selection-start-line="6" selection-start-column="28" selection-end-line="6" selection-end-column="28" /> <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/model/Product.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="221">
<caret line="45" column="25" selection-start-line="45" selection-start-column="25" selection-end-line="45" selection-end-column="25" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/init">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="108">
<caret line="37" column="21" lean-forward="true" selection-start-line="37" selection-start-column="21" selection-end-line="37" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="400">
<caret line="106" lean-forward="true" selection-start-line="106" selection-end-line="106" />
</state> </state>
</provider> </provider>
</entry> </entry>

View File

@ -9,6 +9,7 @@ import com.dino.scrum.sysmag.validator.QuantityChangeValidator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException; import org.springframework.web.server.ResponseStatusException;
@ -56,10 +57,11 @@ public class ProductController {
} }
@DeleteMapping(value = "/product/delete") @DeleteMapping(value = "/product/delete")
public String deleteProduct(@RequestBody IdDto id) { public ResponseEntity deleteProduct(@RequestBody IdDto id) {
try { try {
productService.delete(id.getId()); productService.delete(id.getId());
return "Deleted" + id; // return "Deleted" + id;
return new ResponseEntity("Deleted" + id, HttpStatus.OK);
} catch (Exception e) { } catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString()); throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
} }

View File

@ -27,12 +27,12 @@ public class ProductValidator {
} }
public void checkIfExists(long id) throws Exception { public void checkIfExists(long id) throws Exception {
if (existsById(id)) if (!existsById(id))
throw new Exception("Product with id: " + id + " not found"); throw new Exception("Product with id: " + id + " not found");
} }
public void checkIfExists(String name) throws Exception { public void checkIfExists(String name) throws Exception {
if (existsByName(name)) if (!existsByName(name))
throw new Exception("Product " + name + " already exists"); throw new Exception("Product " + name + " already exists");
} }
} }