Merge branch 'master' of s434805/DINO_SCRUM into backend

This commit is contained in:
Michał Starski 2019-01-22 19:44:26 +00:00 committed by Gogs
commit 67be82915e
23 changed files with 1063 additions and 267 deletions

111
.gitignore vendored Normal file
View File

@ -0,0 +1,111 @@
application.properties
# Created by https://www.gitignore.io/api/java,intellij
# Edit at https://www.gitignore.io/?templates=java,intellij
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
git
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# End of https://www.gitignore.io/api/java,intellij

View File

@ -9,7 +9,7 @@
<module name="sysmag" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<bytecodeTargetLevel target="11">
<module name="sysmag" target="1.8" />
</bytecodeTargetLevel>
</component>

11
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="heroku" uuid="4eb55351-864c-4d3f-b24d-048a158530c7">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://ec2-54-75-230-41.eu-west-1.compute.amazonaws.com:5432/d3e1jrm08qe91q?ssl=true&amp;sslmode=require&amp;amp=org.postgresql.ssl.NonValidatingFactory</jdbc-url>
</data-source>
</component>
</project>

View File

@ -2,6 +2,5 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/sysmag" vcs="Git" />
</component>
</project>

View File

@ -3,6 +3,9 @@
<component name="ChangeListManager">
<list default="true" id="2dc093a7-8382-4e31-b457-ce6c9fd10d13" name="Default Changelist" comment="">
<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" />
@ -22,16 +25,66 @@
<option name="HIDDEN_KINDS">
<set />
</option>
<expand />
<expand>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="public: schema" type="983ebcf7:PgImplModel$Schema" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="public: schema" type="983ebcf7:PgImplModel$Schema" />
<item name="tables" type="d4e8921:DatabaseStructure$FamilyGroup" />
</path>
<path>
<item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
<item name="heroku" type="feb32156:DbDataSourceImpl" />
<item name="databases" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="d3e1jrm08qe91q: database" type="162271b6:PgImplModel$Database" />
<item name="schemas" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="public: schema" type="983ebcf7:PgImplModel$Schema" />
<item name="tables" type="d4e8921:DatabaseStructure$FamilyGroup" />
<item name="product: table" type="69fad909:PgImplModel$LocalTable" />
</path>
</expand>
<select />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<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="153">
<caret line="19" column="27" selection-start-line="19" selection-start-column="27" selection-end-line="19" selection-end-column="27" />
<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>
@ -40,10 +93,10 @@
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.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="135">
<caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
<state relative-caret-position="229">
<caret line="59" lean-forward="true" selection-start-line="59" selection-end-line="59" />
</state>
</provider>
</entry>
@ -51,36 +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="405">
<caret line="41" column="19" selection-start-line="41" selection-start-column="19" selection-end-line="41" selection-end-column="19" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1935#1936#0" expanded="true" />
<element signature="e#1982#1983#0" expanded="true" />
<element signature="e#2038#2039#0" expanded="true" />
<element signature="e#2086#2087#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<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="270">
<caret line="18" column="32" selection-start-line="18" selection-start-column="32" selection-end-line="18" selection-end-column="32" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="1" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
<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>
@ -91,8 +116,8 @@
<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="255">
<caret line="17" column="24" selection-start-line="17" selection-start-column="24" selection-end-line="17" selection-end-column="24" />
<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>
@ -100,23 +125,26 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/HomeController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="13" selection-start-line="11" selection-start-column="13" selection-end-line="11" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
<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="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/model/dto/IdDto.java">
<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="120">
<caret line="8" column="7" selection-start-line="8" selection-start-column="7" selection-end-line="8" selection-end-column="7" />
<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>
@ -126,11 +154,16 @@
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Interface" />
<option value="Class" />
<option value="Interface" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>asc</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="ROOT_SYNC" value="SYNC" />
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -144,17 +177,23 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.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/service/ProductServiceImpl.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/HomeController.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/repository/ProductRepository.java" />
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/src/main/resources/application.properties" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/controller/MainController.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java" />
<option value="$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java" />
<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/resources/application.properties" />
<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$/pom.xml" />
<option value="$PROJECT_DIR$/.gitignore" />
<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>
@ -165,7 +204,23 @@
</MavenImportingSettings>
</option>
</component>
<component name="ProjectFrameBounds">
<component name="MavenProjectNavigator">
<treeState>
<expand>
<path>
<item name="" type="16c1761:MavenProjectsStructure$RootNode" />
<item name="sysmag" type="9519ce18:MavenProjectsStructure$ProjectNode" />
</path>
<path>
<item name="" type="16c1761:MavenProjectsStructure$RootNode" />
<item name="sysmag" type="9519ce18:MavenProjectsStructure$ProjectNode" />
<item name="Lifecycle" type="58874e2:MavenProjectsStructure$LifecycleNode" />
</path>
</expand>
<select />
</treeState>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<option name="y" value="23" />
<option name="width" value="840" />
<option name="height" value="1027" />
@ -179,6 +234,7 @@
</navigator>
<panes>
<pane id="Scope" />
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<expand>
@ -237,26 +293,7 @@
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="sysmag" type="462c0819:PsiDirectoryNode" />
<item name="model" type="462c0819:PsiDirectoryNode" />
<item name="dto" 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="repository" 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="service" type="462c0819:PsiDirectoryNode" />
<item name="validator" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="sysmag" type="b2602c69:ProjectViewProjectNode" />
@ -269,17 +306,17 @@
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="DatabaseDriversLRU" value="h2" />
<property name="DatabaseDriversLRU" value="h2&#10;postgresql" />
<property name="RequestMappingsPanelOrder0" value="0" />
<property name="RequestMappingsPanelOrder1" value="1" />
<property name="RequestMappingsPanelWidth0" value="75" />
<property name="RequestMappingsPanelWidth1" value="75" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="database.console.LAST_STATE" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
@ -353,44 +390,120 @@
<option name="presentableId" value="Default" />
<updated>1547322958782</updated>
<workItem from="1547322960420" duration="21872000" />
<workItem from="1547401179909" duration="588000" />
<workItem from="1547401179909" duration="33384000" />
<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>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1548121370553</updated>
</task>
<task id="LOCAL-00002" summary="add update product and omitted validation">
<created>1548123400861</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1548123400861</updated>
</task>
<task id="LOCAL-00003" summary="fix pom.xml">
<created>1548125729921</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1548125729921</updated>
</task>
<task id="LOCAL-00004" summary="Merge branch 'backend' of https://git.wmi.amu.edu.pl/s434786/DINO_SCRUM&#10;&#10;# Conflicts:&#10;#&#9;README.md">
<created>1548126421537</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1548126421537</updated>
</task>
<task id="LOCAL-00005" summary="a">
<created>1548127778120</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1548127778120</updated>
</task>
<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>
<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="22460000" />
<option name="totallyTimeSpent" value="64846000" />
</component>
<component name="TodoView">
<todo-panel id="selected-file">
<is-autoscroll-to-source value="true" />
</todo-panel>
<todo-panel id="all">
<are-packages-shown value="true" />
<is-autoscroll-to-source value="true" />
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="840" height="1027" extended-state="0" />
<frame x="0" y="23" width="1680" height="1027" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.36842105" />
<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="Designer" order="2" />
<window_info id="UI Designer" order="3" />
<window_info id="Favorites" order="4" side_tool="true" />
<window_info id="Web" order="5" side_tool="true" />
<window_info id="Web" order="5" sideWeight="0.50189394" side_tool="true" weight="0.36842105" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" 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="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<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 active="true" anchor="bottom" id="Terminal" order="8" sideWeight="0.4993895" visible="true" weight="0.43529412" />
<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.50061053" side_tool="true" weight="0.32941177" />
<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="Java Enterprise" order="12" />
<window_info anchor="bottom" id="Database Changes" order="13" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="14" sideWeight="0.4993895" 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="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" />
<window_info anchor="right" id="Maven" order="3" />
<window_info anchor="right" id="Maven" order="3" weight="0.32967034" />
<window_info anchor="right" id="Palette" order="4" />
<window_info anchor="right" id="Database" order="5" weight="0.32967034" />
<window_info anchor="right" id="Database" order="5" weight="0.6466165" />
<window_info anchor="right" id="Palette&#9;" order="6" />
<window_info anchor="right" id="Bean Validation" order="7" />
</layout>
@ -440,9 +553,21 @@
</component>
<component name="VcsManagerConfiguration">
<ignored-roots>
<path value="$PROJECT_DIR$" />
<path value="$PROJECT_DIR$/DINO_SCRUM" />
<path value="$PROJECT_DIR$/sysmag" />
</ignored-roots>
<MESSAGE value="added quantityChange validation, product validation, checking existing object in db, throwing exeption" />
<MESSAGE value="add update product and omitted validation" />
<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="a" />
<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" />
</component>
<component name="editorHistoryManager">
<entry file="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-autoconfigure/2.1.2.RELEASE/spring-boot-autoconfigure-2.1.2.RELEASE.jar!/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.class">
@ -452,78 +577,24 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/pom.xml">
<entry file="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-commons/2.1.4.RELEASE/spring-data-commons-2.1.4.RELEASE.jar!/org/springframework/data/repository/PagingAndSortingRepository.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="310">
<caret line="43" selection-start-line="43" selection-end-line="44" />
<state relative-caret-position="180">
<caret line="17" lean-forward="true" selection-start-line="17" selection-end-line="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/resources/application.properties">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" />
<state relative-caret-position="150">
<caret line="10" selection-start-line="10" selection-end-line="10" />
</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/exception/ProductNotFoundException.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="19" column="27" selection-start-line="19" selection-start-column="27" selection-end-line="19" selection-end-column="27" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
</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="405">
<caret line="41" column="19" selection-start-line="41" selection-start-column="19" selection-end-line="41" selection-end-column="19" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1935#1936#0" expanded="true" />
<element signature="e#1982#1983#0" expanded="true" />
<element signature="e#2038#2039#0" expanded="true" />
<element signature="e#2086#2087#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="270">
<caret line="18" column="32" selection-start-line="18" selection-start-column="32" selection-end-line="18" selection-end-column="32" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="1" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</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="255">
<caret line="17" column="24" selection-start-line="17" selection-start-column="24" selection-end-line="17" selection-end-column="24" />
<folding>
<element signature="imports" expanded="true" />
</folding>
<state relative-caret-position="120">
<caret line="8" lean-forward="true" selection-start-line="8" selection-end-line="8" />
</state>
</provider>
</entry>
@ -537,10 +608,148 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/IdDto.java">
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/model/dto/QuantityChange.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="8" column="7" selection-start-line="8" selection-start-column="7" selection-end-line="8" selection-end-column="7" />
<state relative-caret-position="150">
<caret line="10" column="18" selection-start-line="10" selection-start-column="18" selection-end-line="10" selection-end-column="18" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-commons/2.1.4.RELEASE/spring-data-commons-2.1.4.RELEASE.jar!/org/springframework/data/repository/CrudRepository.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="15" column="16" selection-start-line="15" selection-start-column="16" selection-end-line="15" selection-end-column="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/repository/ProductRepository.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="21" lean-forward="true" selection-start-line="21" selection-end-line="21" />
<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/service/ProductService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
<caret line="20" column="43" selection-start-line="20" selection-start-column="43" selection-end-line="20" selection-end-column="43" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/main/java/com/dino/scrum/sysmag/validationGroup/UpdateGroup.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="28" selection-start-line="6" selection-start-column="28" selection-end-line="6" selection-end-column="28" />
</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="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://$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>
<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>
</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="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>
</state>
</provider>
</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="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>
</state>
</provider>
</entry>
<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="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>

247
README.md Normal file
View File

@ -0,0 +1,247 @@
# 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 `HttpStatus.OK` 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 with ``HttpStatus.OK`` 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 ``Http.Status.OK`` 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 `HttpStatus.CREATED` 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
}
```
```json
Response: HttpStatus.OK
```
* * *
###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 ``Http.Status.OK`` 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 ``Http.Status.OK`` with `JSON`:
```json
{
"id": Int,
"name": String,
"price": Float,
"quantity": Int,
"quantityMax": Int,
"imageLink": String
}
```

View File

@ -1,7 +1,6 @@
package com.dino.scrum.sysmag.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
@ -12,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
public class HomeController {
@GetMapping("/")
public String home(){
public String home() {
return "System magazynowy";
}
}

View File

@ -3,12 +3,19 @@ package com.dino.scrum.sysmag.controller;
import com.dino.scrum.sysmag.model.Product;
import com.dino.scrum.sysmag.model.dto.IdDto;
import com.dino.scrum.sysmag.model.dto.QuantityChange;
import com.dino.scrum.sysmag.service.ProductService;
import com.dino.scrum.sysmag.service.ProductServiceImpl;
import com.dino.scrum.sysmag.validationGroup.UpdateGroup;
import com.dino.scrum.sysmag.validator.QuantityChangeValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
import javax.validation.Valid;
import java.util.Collections;
import java.util.Map;
@ -16,53 +23,82 @@ import java.util.Map;
* Created by prgres on 2019-01-12.
*/
@Controller
@RestController
@RequestMapping(value = "/api")
public class ProductController {
private final ProductServiceImpl productService;
private final
ProductServiceImpl productService;
private final
QuantityChangeValidator quantityChangeValidator;
@Autowired
public ProductController(ProductServiceImpl productService) {
public ProductController(ProductServiceImpl productService, QuantityChangeValidator quantityChangeValidator) {
this.productService = productService;
this.quantityChangeValidator = quantityChangeValidator;
}
@GetMapping(value = "/get-all")
public @ResponseBody
Iterable<Product> getAll(){
return productService.getAllProducts();
public Iterable<Product> getAll(@PageableDefault(size = Integer.MAX_VALUE) Pageable pageable) {
System.out.println(pageable.getPageSize());
try {
return productService.getAll(pageable);
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
}
}
@GetMapping(value = "/get-price-of-all")
public @ResponseBody
Map getPriceOfAllProducts(){
return Collections.singletonMap("price-of-all", productService.getPriceOfAllProducts());
public Map getPriceOfAllProducts() {
return Collections.singletonMap("price-of-all", productService.getPriceOfAll());
}
@PostMapping(value = "/product/add")
public @ResponseBody
Product addProduct(@RequestBody Product product){
return productService.addProduct(product);
public ResponseEntity addProduct(@Valid @RequestBody Product product) {
try {
productService.add(product);
return new ResponseEntity(product, HttpStatus.CREATED);
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
}
}
@DeleteMapping(value = "/product/delete")
public @ResponseBody
String deleteProduct(@RequestBody IdDto id){
productService.deleteProduct(id.getId());
return "Deleted" + id;
public ResponseEntity deleteProduct(@RequestBody IdDto id) {
try {
productService.delete(id.getId());
return new ResponseEntity("Deleted" + id, HttpStatus.OK);
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
}
}
@GetMapping(value = "/product/get-by-id")
public @ResponseBody
Product getById(@RequestBody IdDto id){
public Product getById(@RequestBody IdDto id) {
try {
return productService.getById(id.getId());
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
}
}
@PostMapping(value = "/product/update/{id}")
public Product update(@Validated(UpdateGroup.class) @RequestBody Product product, @PathVariable("id") long id) {
try {
return productService.update(product, id);
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
}
}
@PostMapping(value = "/product/change-quantity")
public @ResponseBody
Product changeQuantity(@RequestBody QuantityChange quantityChange){
public Product changeQuantity(@RequestBody QuantityChange quantityChange) {
try {
quantityChangeValidator.validate(quantityChange);
return productService.changeQuantity(quantityChange);
} catch (Exception e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, e.toString());
}
}
}

View File

@ -0,0 +1,8 @@
package com.dino.scrum.sysmag.exception;
/**
* Created by prgres on 2019-01-21.
*/
public class ProductNotFoundException extends ClassNotFoundException {
}

View File

@ -5,6 +5,10 @@ import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
/**
@ -23,16 +27,35 @@ public class Product {
@Column(name = "id")
private Long id;
@NotNull(message = "name cannot be null")
@Size(min = 2, message = "name cannot be shorter that 2")
@Column(name = "name")
private String name;
@NotNull(message = "price cannot be null")
@DecimalMin(value = "0.00", message = "price cannot be under 0.00")
@Column(name = "price")
private BigDecimal price;
@NotNull(message = "quantity cannot be null")
@Min(value = 0, message = "quantity cannot be under 0")
@Column(name = "quantity")
private long quantity;
@NotNull(message = "quantityMax cannot be null")
@Min(value = 1, message = "quantityMax cannot be under 1")
@Column(name = "quantityMax")
private long quantityMax;
@NotNull(message = "image_link cannot be null")
@Column(name = "image_link")
private String imageLink;
public Product setChangeQuantity(long change) {
System.out.println("IN MODEL quantity: " + this.getQuantity() + " change" + change);
this.quantity += change;
System.out.println("IN MODEL after change quantity: " + this.getQuantity());
return this;
}
}

View File

@ -8,5 +8,6 @@ import lombok.Getter;
@Getter
public class IdDto {
long id;
}

View File

@ -1,5 +1,6 @@
package com.dino.scrum.sysmag.model.dto;
import lombok.EqualsAndHashCode;
import lombok.Getter;
/**
@ -7,6 +8,7 @@ import lombok.Getter;
*/
@Getter
@EqualsAndHashCode
public class QuantityChange {
long id;
long change;

View File

@ -1,16 +1,19 @@
package com.dino.scrum.sysmag.repository;
import com.dino.scrum.sysmag.model.Product;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
/**
* Created by prgres on 2019-01-12.
*/
@Repository
public interface ProductRepository extends PagingAndSortingRepository<Product, Long> {
boolean existsByName(String name);
public interface ProductRepository extends CrudRepository<Product, Long> {
List<Product> findAll();
Optional<Product> findByName(String name);
Product findById(long id);
}

View File

@ -2,19 +2,28 @@ package com.dino.scrum.sysmag.service;
import com.dino.scrum.sysmag.model.Product;
import com.dino.scrum.sysmag.model.dto.QuantityChange;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
/**
* Created by prgres on 2019-01-12.
*/
public interface ProductService {
List<Product> getAllProducts();
Product changeQuantity(QuantityChange quantityChange);
Product getById(Long id);
float getPriceOfAllProducts();
Product addProduct(Product product);
void deleteProduct(long id);
Page<Product> getAll(Pageable pageable) throws Exception;
Product changeQuantity(QuantityChange quantityChange) throws Exception;
Product getById(Long id) throws Exception;
Product add(Product product) throws Exception;
Product update(Product product, long id) throws Exception;
long count();
float getPriceOfAll();
void delete(long id) throws Exception;
}

View File

@ -3,14 +3,15 @@ package com.dino.scrum.sysmag.service;
import com.dino.scrum.sysmag.model.Product;
import com.dino.scrum.sysmag.model.dto.QuantityChange;
import com.dino.scrum.sysmag.repository.ProductRepository;
import com.dino.scrum.sysmag.validator.ProductValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import javax.persistence.EntityNotFoundException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* Created by prgres on 2019-01-12.
@ -19,57 +20,104 @@ import java.util.stream.Collectors;
@Service
public class ProductServiceImpl implements ProductService {
private final ProductRepository productRepository;
private final
ProductRepository productRepository;
private final
ProductValidator productValidator;
@Autowired
public ProductServiceImpl(ProductRepository productRepository) {
public ProductServiceImpl(ProductRepository productRepository, ProductValidator productValidator) {
this.productRepository = productRepository;
this.productValidator = productValidator;
}
@Override
public List<Product> getAllProducts() {
return productRepository.findAll();
public Page<Product> getAll(Pageable pageable) throws Exception {
System.out.println("pagenumber: " + pageable.getPageNumber() + " pageSize: " + pageable.getPageSize() + " sort: " + pageable.getSort());
if (pageable.getSort().isUnsorted()) {
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), new Sort(Sort.Direction.ASC, "id"));
}
Page<Product> productSlice = productRepository.findAll(pageable);
productValidator.checkIfPageIsOutOfBound(productSlice.getTotalPages(), pageable.getPageNumber());
return productSlice;
}
@Override
public Product changeQuantity(QuantityChange quantityChange) {
return productRepository.findById(quantityChange.getId())
.map(product -> {
product.setQuantity(
product.getQuantity() + quantityChange.getChange()
public Product changeQuantity(QuantityChange quantityChange) throws Exception {
productValidator.checkIfNotExists(quantityChange.getId());
productRepository.save(
productRepository.findById(quantityChange.getId())
.setChangeQuantity(quantityChange.getChange())
);
return productRepository.save(product);
}).orElse(null);
return productRepository.findById(quantityChange.getId());
}
@Override
public Product getById(Long id) {
return productRepository.findById(id).orElse(null);
public Product getById(Long id) throws Exception {
productValidator.checkIfNotExists(id);
return productRepository.findById(id.longValue());
}
@Override
public float getPriceOfAllProducts() {
public float getPriceOfAll() {
BigDecimal result = new BigDecimal(0);
List<Product> tempProductList = productRepository.findAll();
Iterable<Product> tempProductList = productRepository.findAll();
for (Product product : tempProductList) {
result = result.add(
product.getPrice()
.multiply( new BigDecimal(product.getQuantity())));
.multiply(new BigDecimal(product.getQuantity())));
}
return result.floatValue();
}
@Override
public Product addProduct(Product product) {
public Product add(Product product) throws Exception {
productValidator.checkIfNotExists(product.getName());
return productRepository.save(product);
}
@Override
public void deleteProduct(long id) {
productRepository.deleteById(id);
public Product update(Product productReceived, long id) throws Exception {
productValidator.checkIfNotExists(productReceived.getId());
Product productToChange = productRepository.findById(id);
if (productReceived.getName() != null)
productToChange.setName(productReceived.getName());
if (productReceived.getName() != null)
productToChange.setPrice(productReceived.getPrice());
if (productReceived.getName() != null)
productToChange.setQuantity(productReceived.getQuantity());
if (productReceived.getName() != null)
productToChange.setQuantityMax(productReceived.getQuantityMax());
if (productReceived.getName() != null)
productToChange.setImageLink(productReceived.getImageLink());
productRepository.save(productToChange);
return productRepository.findById(productToChange.getId().longValue());
}
@Override
public long count() {
return productRepository.count();
}
@Override
public void delete(long id) throws Exception {
productValidator.checkIfNotExists(id);
productRepository.deleteById(id);
}
}

View File

@ -0,0 +1,8 @@
package com.dino.scrum.sysmag.validationGroup;
/**
* Created by prgres on 2019-01-22.
*/
public interface UpdateGroup {
}

View File

@ -0,0 +1,48 @@
package com.dino.scrum.sysmag.validator;
import com.dino.scrum.sysmag.repository.ProductRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created by prgres on 2019-01-22.
*/
@Component
public class ProductValidator {
private final ProductRepository productRepository;
@Autowired
public ProductValidator(ProductRepository productRepository) {
this.productRepository = productRepository;
}
private boolean existsById(long id) {
return productRepository.existsById(id);
}
private boolean existsByName(String name) {
return productRepository.existsByName(name);
}
private boolean ifRequestPageInLimit(int limit, int requestPage) {
return requestPage < limit;
}
public void checkIfNotExists(long id) throws Exception {
if (!existsById(id))
throw new Exception("Product with id: " + id + " not found");
System.out.println(id + " exists");
}
public void checkIfNotExists(String name) throws Exception {
if (existsByName(name))
throw new Exception("Product " + name + " already exists");
}
public void checkIfPageIsOutOfBound(int totalPages, int requestPage) throws Exception {
if (ifRequestPageInLimit(requestPage, totalPages))
throw new Exception("Page " + requestPage + " is out of the total pages number.");
}
}

View File

@ -0,0 +1,44 @@
package com.dino.scrum.sysmag.validator;
import com.dino.scrum.sysmag.model.Product;
import com.dino.scrum.sysmag.model.dto.QuantityChange;
import com.dino.scrum.sysmag.service.ProductServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created by prgres on 2019-01-20.
*/
@Component
public class QuantityChangeValidator {
private final
ProductServiceImpl productService;
@Autowired
public QuantityChangeValidator(ProductServiceImpl productService) {
this.productService = productService;
}
public void validate(QuantityChange quantityChange) throws Exception {
Product product = productService.getById(quantityChange.getId());
if (ifUnderStock(product.getQuantity(), quantityChange.getChange())) {
throw new RuntimeException("Too low product with id: " + quantityChange.getId() + " on stock");
}
if (ifAboveMaxLimitStock(product.getQuantity(), product.getQuantityMax(), quantityChange.getChange())) {
throw new RuntimeException("Over max quantity limit of product with id: " + quantityChange.getId());
}
}
private boolean ifUnderStock(long quantityOfProduct, long quantityChange) {
return ((quantityOfProduct + quantityChange) < 0);
}
private boolean ifAboveMaxLimitStock(long quantityOfProduct, long maxQuantityOfProduct, long quantityChange) {
return ((quantityOfProduct + quantityChange) > maxQuantityOfProduct);
}
}

View File

@ -1,16 +0,0 @@
# Details for our datasource heroku
spring.datasource.url=jdbc:postgresql://ec2-54-75-230-41.eu-west-1.compute.amazonaws.com/d3e1jrm08qe91q?ssl=true&sslmode=require&amp;sslfactory=org.postgresql.ssl.NonValidatingFactory
spring.datasource.username=eecsegponwphcn
spring.datasource.password=4045a1e5a2de22362149709c3a2a1d5eb6e243cd553fd1a15f76fc54923638ce
spring.datasource.driverClassName=org.postgresql.Driver
# Hibernate properties
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
spring.jpa.generate-ddl=true
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
#spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false

Binary file not shown.

View File

@ -1,10 +1,16 @@
# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.jpa.hibernate.ddl-auto=create
# Details for our datasource heroku
spring.datasource.url=jdbc:postgresql://ec2-54-75-230-41.eu-west-1.compute.amazonaws.com/d3e1jrm08qe91q?ssl=true&sslmode=require&amp;sslfactory=org.postgresql.ssl.NonValidatingFactory
spring.datasource.username=eecsegponwphcn
spring.datasource.password=4045a1e5a2de22362149709c3a2a1d5eb6e243cd553fd1a15f76fc54923638ce
spring.datasource.driverClassName=org.postgresql.Driver
# Hibernate properties
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
spring.jpa.generate-ddl=true
# Datasource
spring.datasource.url=jdbc:h2:file:~/sysmag
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
#spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false