diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..30cf57e
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Ignored default folder with query files
+/queries/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..84b29a0
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..eac9a25
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ mysql.8
+ true
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://localhost:3306
+
+
+
+
+
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..ba609eb
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/flexpath-unit-2-final.iml b/.idea/flexpath-unit-2-final.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/flexpath-unit-2-final.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..859aef5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..2177b28
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java-springboot-final/.idea/dataSources.local.xml b/java-springboot-final/.idea/dataSources.local.xml
new file mode 100644
index 0000000..76651b3
--- /dev/null
+++ b/java-springboot-final/.idea/dataSources.local.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ master_key
+ nick0
+
+
+
+
\ No newline at end of file
diff --git a/java-springboot-final/.idea/dataSources.xml b/java-springboot-final/.idea/dataSources.xml
new file mode 100644
index 0000000..0a23f24
--- /dev/null
+++ b/java-springboot-final/.idea/dataSources.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ mysql.8
+ true
+ true
+ $PROJECT_DIR$/src/main/resources/application.properties
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://localhost:3306/web_shop
+
+
+
+
+
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/java-springboot-final/.idea/dataSources/data_sources_history.xml b/java-springboot-final/.idea/dataSources/data_sources_history.xml
new file mode 100644
index 0000000..c24d484
--- /dev/null
+++ b/java-springboot-final/.idea/dataSources/data_sources_history.xml
@@ -0,0 +1,22 @@
+
+
+
+
+ mysql.8
+ true
+ true
+ C:/Users/nicho/OneDrive/Documents/GitHub/flexpath-unit-2-final/java-springboot-final/src/main/resources/application.properties
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://localhost:3306/web_shop
+
+
+
+
+
+ master_key
+ nick0
+
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/java-springboot-final/.idea/data_source_mapping.xml b/java-springboot-final/.idea/data_source_mapping.xml
new file mode 100644
index 0000000..ce094f8
--- /dev/null
+++ b/java-springboot-final/.idea/data_source_mapping.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java-springboot-final/.idea/sqldialects.xml b/java-springboot-final/.idea/sqldialects.xml
new file mode 100644
index 0000000..eb57b26
--- /dev/null
+++ b/java-springboot-final/.idea/sqldialects.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java-springboot-final/pom.xml b/java-springboot-final/pom.xml
index d3a53e2..52c2feb 100644
--- a/java-springboot-final/pom.xml
+++ b/java-springboot-final/pom.xml
@@ -92,6 +92,14 @@
org.springframework.boot
spring-boot-maven-plugin
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 25
+ 25
+
+
diff --git a/java-springboot-final/postman/.postman/resources.yaml b/java-springboot-final/postman/.postman/resources.yaml
new file mode 100644
index 0000000..33ff8ff
--- /dev/null
+++ b/java-springboot-final/postman/.postman/resources.yaml
@@ -0,0 +1,11 @@
+# Use this workspace to collaborate
+workspace:
+ id: 3125f098-2d4b-4cee-82d6-fdf6b8cfbf60
+
+localResources:
+ collections:
+ - ../web-store.postman_collection.json
+
+cloudResources:
+ collections:
+ ../postman/collections/web-store: 7aa67b5d-f01a-499d-908b-d2893184bd9c
diff --git a/java-springboot-final/postman/postman/collections/web-store/.resources/definition.yaml b/java-springboot-final/postman/postman/collections/web-store/.resources/definition.yaml
new file mode 100644
index 0000000..b2e3d41
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/.resources/definition.yaml
@@ -0,0 +1,11 @@
+$kind: collection
+description: ""
+variables:
+ token: ""
+ password: admin
+auth:
+ - id: 0868ff0e-f89f-4f44-9f70-6a5cf6e40fc1
+ type: bearer
+ name: bearer auth
+ credentials:
+ token: "{{token}}"
diff --git a/java-springboot-final/postman/postman/collections/web-store/Order Items/.resources/definition.yaml b/java-springboot-final/postman/postman/collections/web-store/Order Items/.resources/definition.yaml
new file mode 100644
index 0000000..afdeb9a
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Order Items/.resources/definition.yaml
@@ -0,0 +1,2 @@
+$kind: collection
+order: 5000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Order Items/Create Order Item 1.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Order Items/Create Order Item 1.request.yaml
new file mode 100644
index 0000000..f20d8b6
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Order Items/Create Order Item 1.request.yaml
@@ -0,0 +1,12 @@
+$kind: http-request
+url: http://localhost:8080/api/order-items
+method: POST
+body:
+ type: json
+ content: |-
+ {
+ "orderId": 1,
+ "productId": 1,
+ "quantity": 1
+ }
+order: 3000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Order Items/Delete Order Item 1.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Order Items/Delete Order Item 1.request.yaml
new file mode 100644
index 0000000..574b1c4
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Order Items/Delete Order Item 1.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/order-items/1
+method: DELETE
+order: 5000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Order Items/Get All Order Items.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Order Items/Get All Order Items.request.yaml
new file mode 100644
index 0000000..792067b
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Order Items/Get All Order Items.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/order-items
+method: GET
+order: 1000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Order Items/Get Order Item By Id.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Order Items/Get Order Item By Id.request.yaml
new file mode 100644
index 0000000..fe977a2
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Order Items/Get Order Item By Id.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/order-items/1
+method: GET
+order: 2000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Order Items/Update Order Item 1.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Order Items/Update Order Item 1.request.yaml
new file mode 100644
index 0000000..ca94f1b
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Order Items/Update Order Item 1.request.yaml
@@ -0,0 +1,12 @@
+$kind: http-request
+url: http://localhost:8080/api/order-items/1
+method: PUT
+body:
+ type: json
+ content: |-
+ {
+ "orderId": 1,
+ "productId": 1,
+ "quantity": 2
+ }
+order: 4000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Orders/.resources/definition.yaml b/java-springboot-final/postman/postman/collections/web-store/Orders/.resources/definition.yaml
new file mode 100644
index 0000000..dcd7396
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Orders/.resources/definition.yaml
@@ -0,0 +1,2 @@
+$kind: collection
+order: 4000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Orders/Create Order 6.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Orders/Create Order 6.request.yaml
new file mode 100644
index 0000000..b3962ad
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Orders/Create Order 6.request.yaml
@@ -0,0 +1,10 @@
+$kind: http-request
+url: http://localhost:8080/api/orders
+method: POST
+body:
+ type: json
+ content: |-
+ {
+ "username": "admin"
+ }
+order: 3000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Orders/Delete Order 6.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Orders/Delete Order 6.request.yaml
new file mode 100644
index 0000000..9a4b9d3
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Orders/Delete Order 6.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/orders/6
+method: DELETE
+order: 5000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Orders/Get All Orders.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Orders/Get All Orders.request.yaml
new file mode 100644
index 0000000..917e167
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Orders/Get All Orders.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/orders
+method: GET
+order: 1000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Orders/Get Order By Id.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Orders/Get Order By Id.request.yaml
new file mode 100644
index 0000000..b12fcab
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Orders/Get Order By Id.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/orders/1
+method: GET
+order: 2000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Orders/Update Order 6.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Orders/Update Order 6.request.yaml
new file mode 100644
index 0000000..bb7fecd
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Orders/Update Order 6.request.yaml
@@ -0,0 +1,10 @@
+$kind: http-request
+url: http://localhost:8080/api/orders/6
+method: PUT
+body:
+ type: json
+ content: |-
+ {
+ "username" : "test"
+ }
+order: 4000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Products/.resources/definition.yaml b/java-springboot-final/postman/postman/collections/web-store/Products/.resources/definition.yaml
new file mode 100644
index 0000000..40bbb1c
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Products/.resources/definition.yaml
@@ -0,0 +1,2 @@
+$kind: collection
+order: 3000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Products/Create Product 6.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Products/Create Product 6.request.yaml
new file mode 100644
index 0000000..9fea8be
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Products/Create Product 6.request.yaml
@@ -0,0 +1,11 @@
+$kind: http-request
+url: http://localhost:8080/api/products
+method: POST
+body:
+ type: json
+ content: |-
+ {
+ "name": "test",
+ "price": 100
+ }
+order: 3000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Products/Delete Product 6.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Products/Delete Product 6.request.yaml
new file mode 100644
index 0000000..74a143f
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Products/Delete Product 6.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/products/6
+method: DELETE
+order: 5000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Products/Get All Products.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Products/Get All Products.request.yaml
new file mode 100644
index 0000000..33c1789
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Products/Get All Products.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/products
+method: GET
+order: 1000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Products/Get Product By Id.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Products/Get Product By Id.request.yaml
new file mode 100644
index 0000000..3eeac89
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Products/Get Product By Id.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/products/1
+method: GET
+order: 2000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Products/Update Product 6.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Products/Update Product 6.request.yaml
new file mode 100644
index 0000000..055fbe2
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Products/Update Product 6.request.yaml
@@ -0,0 +1,11 @@
+$kind: http-request
+url: http://localhost:8080/api/products/6
+method: PUT
+body:
+ type: json
+ content: |-
+ {
+ "name": "test",
+ "price": 200
+ }
+order: 4000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Profile/.resources/definition.yaml b/java-springboot-final/postman/postman/collections/web-store/Profile/.resources/definition.yaml
new file mode 100644
index 0000000..53d990d
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Profile/.resources/definition.yaml
@@ -0,0 +1,2 @@
+$kind: collection
+order: 1000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -admin-.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -admin-.request.yaml
new file mode 100644
index 0000000..eac03b4
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -admin-.request.yaml
@@ -0,0 +1,12 @@
+$kind: http-request
+name: Change Password To "admin"
+url: http://localhost:8080/api/profile/change-password
+method: PUT
+body:
+ type: json
+ content: admin
+scripts:
+ - type: afterResponse
+ code: pm.collectionVariables.set('password', 'admin');
+ language: text/javascript
+order: 4000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -test-.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -test-.request.yaml
new file mode 100644
index 0000000..a906d7c
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -test-.request.yaml
@@ -0,0 +1,12 @@
+$kind: http-request
+name: Change Password To "test"
+url: http://localhost:8080/api/profile/change-password
+method: PUT
+body:
+ type: json
+ content: test
+scripts:
+ - type: afterResponse
+ code: pm.collectionVariables.set('password', 'test');
+ language: text/javascript
+order: 3000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile Roles.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile Roles.request.yaml
new file mode 100644
index 0000000..f02c928
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile Roles.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/profile/roles
+method: GET
+order: 2000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile.request.yaml
new file mode 100644
index 0000000..d034a7d
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/profile
+method: GET
+order: 1000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/.resources/definition.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/.resources/definition.yaml
new file mode 100644
index 0000000..6522e17
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/.resources/definition.yaml
@@ -0,0 +1,2 @@
+$kind: collection
+order: 2000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Add ADMIN role to test.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Add ADMIN role to test.request.yaml
new file mode 100644
index 0000000..135b9fe
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Add ADMIN role to test.request.yaml
@@ -0,0 +1,7 @@
+$kind: http-request
+url: http://localhost:8080/api/users/test/roles
+method: POST
+body:
+ type: json
+ content: ADMIN
+order: 5000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Add TEST role to test.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Add TEST role to test.request.yaml
new file mode 100644
index 0000000..f8a1324
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Add TEST role to test.request.yaml
@@ -0,0 +1,7 @@
+$kind: http-request
+url: http://localhost:8080/api/users/test/roles
+method: POST
+body:
+ type: json
+ content: TEST
+order: 6000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Change Test Password.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Change Test Password.request.yaml
new file mode 100644
index 0000000..1fca6c8
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Change Test Password.request.yaml
@@ -0,0 +1,7 @@
+$kind: http-request
+url: http://localhost:8080/api/users/test/password
+method: PUT
+body:
+ type: json
+ content: test
+order: 4000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Create Test User.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Create Test User.request.yaml
new file mode 100644
index 0000000..8a727e6
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Create Test User.request.yaml
@@ -0,0 +1,11 @@
+$kind: http-request
+url: http://localhost:8080/api/users
+method: POST
+body:
+ type: json
+ content: |-
+ {
+ "username": "test",
+ "password": "admin"
+ }
+order: 2000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Delete TEST role from test.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Delete TEST role from test.request.yaml
new file mode 100644
index 0000000..4fab4cb
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Delete TEST role from test.request.yaml
@@ -0,0 +1,7 @@
+$kind: http-request
+url: http://localhost:8080/api/users/test/roles/test
+method: DELETE
+body:
+ type: json
+ content: TEST
+order: 8000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Delete Test User.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Delete Test User.request.yaml
new file mode 100644
index 0000000..9c4773c
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Delete Test User.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/users/test
+method: DELETE
+order: 9000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Get All Users.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Get All Users.request.yaml
new file mode 100644
index 0000000..dd557f7
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Get All Users.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/users
+method: GET
+order: 1000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Get Test User Roles.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Get Test User Roles.request.yaml
new file mode 100644
index 0000000..d653ec3
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Get Test User Roles.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/users/test/roles
+method: GET
+order: 7000
diff --git a/java-springboot-final/postman/postman/collections/web-store/Users/Get Test User.request.yaml b/java-springboot-final/postman/postman/collections/web-store/Users/Get Test User.request.yaml
new file mode 100644
index 0000000..317f589
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/Users/Get Test User.request.yaml
@@ -0,0 +1,4 @@
+$kind: http-request
+url: http://localhost:8080/api/users/test
+method: GET
+order: 3000
diff --git a/java-springboot-final/postman/postman/collections/web-store/login.request.yaml b/java-springboot-final/postman/postman/collections/web-store/login.request.yaml
new file mode 100644
index 0000000..33826ad
--- /dev/null
+++ b/java-springboot-final/postman/postman/collections/web-store/login.request.yaml
@@ -0,0 +1,17 @@
+$kind: http-request
+url: http://localhost:8080/auth/login
+method: POST
+body:
+ type: json
+ content: |-
+ {
+ "username": "admin",
+ "password": "admin"
+ }
+scripts:
+ - type: afterResponse
+ code: |-
+ var res = pm.response.json();
+ pm.collectionVariables.set('token', res.accessToken.token);
+ language: text/javascript
+order: 6000
diff --git a/java-springboot-final/postman/postman/globals/workspace.globals.yaml b/java-springboot-final/postman/postman/globals/workspace.globals.yaml
new file mode 100644
index 0000000..e96c6d6
--- /dev/null
+++ b/java-springboot-final/postman/postman/globals/workspace.globals.yaml
@@ -0,0 +1,2 @@
+name: Globals
+values: []
diff --git a/java-springboot-final/src/main/java/org/example/controllers/OrderController.java b/java-springboot-final/src/main/java/org/example/controllers/OrderController.java
new file mode 100644
index 0000000..b5dfee6
--- /dev/null
+++ b/java-springboot-final/src/main/java/org/example/controllers/OrderController.java
@@ -0,0 +1,65 @@
+/*
+The README bonus says overwriting the username from Principal on both create and
+update. The unit test "putOrderShouldUpdateThirdOrder" sends a body with username "user" and says
+that the returned order still has username "user". If I overwrite on PUT, that test fails. So only apply the
+Principal overwrite on POST.
+ */
+
+package org.example.controllers;
+import org.example.daos.OrderDao;
+import org.example.models.Order;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.server.ResponseStatusException;
+import java.security.Principal;
+import java.util.List;
+@RestController
+@CrossOrigin
+@RequestMapping("/api/orders")
+@PreAuthorize("isAuthenticated()")
+public class OrderController {
+ @Autowired
+ private OrderDao orderDao;
+ @GetMapping
+ public List getAll(@RequestParam(required = false) String username) {
+ if (username != null) {
+ return orderDao.getOrdersByUsername(username);
+ }
+ return orderDao.getOrders();
+ }
+ @GetMapping("/{id}")
+ public Order get(@PathVariable int id) {
+ Order order = orderDao.getOrderById(id);
+ if (order == null) {
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Order not found");
+ }
+ return order;
+ }
+ @PostMapping
+ @ResponseStatus(HttpStatus.CREATED)
+ public Order create(@RequestBody Order order, Principal principal) {
+ // Bonus 2 only on create
+ order.setUsername(principal.getName());
+ return orderDao.createOrder(order);
+ }
+ @PutMapping("/{id}")
+ public Order update(@PathVariable int id, @RequestBody Order order) {
+ // Do NOT overwrite username from Principal
+ order.setId(id);
+ try {
+ return orderDao.updateOrder(order);
+ } catch (RuntimeException e) {
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Order not found");
+ }
+ }
+ @DeleteMapping("/{id}")
+ public int delete(@PathVariable int id) {
+ int rows = orderDao.deleteOrder(id);
+ if (rows == 0) {
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Order not found");
+ }
+ return rows;
+ }
+}
diff --git a/java-springboot-final/src/main/java/org/example/controllers/OrderItemController.java b/java-springboot-final/src/main/java/org/example/controllers/OrderItemController.java
new file mode 100644
index 0000000..ee7f95c
--- /dev/null
+++ b/java-springboot-final/src/main/java/org/example/controllers/OrderItemController.java
@@ -0,0 +1,4 @@
+package org.example.controllers;
+
+public class OrderItemController {
+}
diff --git a/java-springboot-final/src/main/java/org/example/controllers/ProductController.java b/java-springboot-final/src/main/java/org/example/controllers/ProductController.java
new file mode 100644
index 0000000..f29981c
--- /dev/null
+++ b/java-springboot-final/src/main/java/org/example/controllers/ProductController.java
@@ -0,0 +1,51 @@
+package org.example.controllers;
+import org.example.daos.ProductDao;
+import org.example.models.Product;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.server.ResponseStatusException;
+import java.util.List;
+@RestController
+@CrossOrigin
+@RequestMapping("/api/products")
+@PreAuthorize("isAuthenticated()")
+public class ProductController {
+ @Autowired
+ private ProductDao productDao;
+ @GetMapping
+ public List getAll() {
+ return productDao.getProducts();
+ }
+ @GetMapping("/{id}")
+ public Product get(@PathVariable int id) {
+ Product product = productDao.getProductById(id);
+ if (product == null) {
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Product not found");
+ }
+ return product;
+ }
+ @PostMapping
+ @ResponseStatus(HttpStatus.CREATED)
+ public Product create(@RequestBody Product product) {
+ return productDao.createProduct(product);
+ }
+ @PutMapping("/{id}")
+ public Product update(@PathVariable int id, @RequestBody Product product) {
+ product.setId(id);
+ try {
+ return productDao.updateProduct(product);
+ } catch (RuntimeException e) {
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Product not found");
+ }
+ }
+ @DeleteMapping("/{id}")
+ public int delete(@PathVariable int id) {
+ int rows = productDao.deleteProduct(id);
+ if (rows == 0) {
+ throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Product not found");
+ }
+ return rows;
+ }
+}
\ No newline at end of file
diff --git a/java-springboot-final/src/main/java/org/example/daos/OrderDao.java b/java-springboot-final/src/main/java/org/example/daos/OrderDao.java
new file mode 100644
index 0000000..870acc6
--- /dev/null
+++ b/java-springboot-final/src/main/java/org/example/daos/OrderDao.java
@@ -0,0 +1,59 @@
+package org.example.daos;
+import org.example.exceptions.DaoException;
+import org.example.models.Order;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+@Component
+public class OrderDao {
+ private final JdbcTemplate jdbcTemplate;
+ public OrderDao(DataSource dataSource) {
+ this.jdbcTemplate = new JdbcTemplate(dataSource);
+ }
+ public List getOrders() {
+ return jdbcTemplate.query(
+ "SELECT * FROM orders ORDER BY id;",
+ this::mapToOrder);
+ }
+ /** you know I'm using that username query parameter!! */
+ public List getOrdersByUsername(String username) {
+ return jdbcTemplate.query(
+ "SELECT * FROM orders WHERE username = ? ORDER BY id;",
+ this::mapToOrder, username);
+ }
+ public Order getOrderById(int id) {
+ try {
+ return jdbcTemplate.queryForObject(
+ "SELECT * FROM orders WHERE id = ?",
+ this::mapToOrder, id);
+ } catch (EmptyResultDataAccessException e) {
+ return null;
+ }
+ }
+ public Order createOrder(Order order) {
+ String sql = "INSERT INTO orders (username) VALUES (?);";
+ jdbcTemplate.update(sql, order.getUsername());
+ return jdbcTemplate.queryForObject(
+ "SELECT * FROM orders WHERE id = LAST_INSERT_ID();",
+ this::mapToOrder);
+ }
+ public Order updateOrder(Order order) {
+ String sql = "UPDATE orders SET username = ? WHERE id = ?;";
+ int rows = jdbcTemplate.update(sql,
+ order.getUsername(), order.getId());
+ if (rows == 0) {
+ throw new DaoException("Zero rows affected, expected at least one.");
+ }
+ return getOrderById(order.getId());
+ }
+ public int deleteOrder(int id) {
+ return jdbcTemplate.update("DELETE FROM orders WHERE id = ?;", id);
+ }
+ private Order mapToOrder(ResultSet rs, int rowNum) throws SQLException {
+ return new Order(rs.getInt("id"), rs.getString("username"));
+ }
+}
\ No newline at end of file
diff --git a/java-springboot-final/src/main/java/org/example/daos/OrderItemDao.java b/java-springboot-final/src/main/java/org/example/daos/OrderItemDao.java
new file mode 100644
index 0000000..b5bfc04
--- /dev/null
+++ b/java-springboot-final/src/main/java/org/example/daos/OrderItemDao.java
@@ -0,0 +1,4 @@
+package org.example.daos;
+
+public class OrderItemDao {
+}
diff --git a/java-springboot-final/src/main/java/org/example/daos/ProductDao.java b/java-springboot-final/src/main/java/org/example/daos/ProductDao.java
new file mode 100644
index 0000000..1b9d292
--- /dev/null
+++ b/java-springboot-final/src/main/java/org/example/daos/ProductDao.java
@@ -0,0 +1,72 @@
+
+
+package org.example.daos;
+
+//We need exceptions, model, spring (stereotype component), jdbc template, and our datasource imported
+import org.example.exceptions.DaoException;
+import org.example.models.Product;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Component;
+
+//Imports for datasource, result set, exceptions, and list
+import javax.sql.DataSource;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+@Component
+public class ProductDao {
+ //We want to use this class to provide access to the Product data table
+ private final JdbcTemplate jdbcTemplate;
+
+ public ProductDao(DataSource dataSource) {
+ //use the datasource input to create a new JDBC template
+ this.jdbcTemplate = new JdbcTemplate(dataSource);
+ }
+
+ //List all products sorted by id
+ public List getProducts() {
+ return jdbcTemplate.query("SELECT * FROM products ORDER BY id;", this::mapToProduct);
+ }
+
+ //grab the product using its id
+ public Product getProductById(int id) {
+ try {
+ return jdbcTemplate.queryForObject("SELECT * FROM products WHERE id = ?", this::mapToProduct, id);
+ } catch (EmptyResultDataAccessException e) {
+ return null;
+ }
+ }
+
+ //create a product method
+ public Product createProduct(Product product) {
+ String sql = "INSERT INTO products (name, price) VALUES (?,?)";
+ jdbcTemplate.update(sql, product.getName(), product.getPrice());
+ return jdbcTemplate.queryForObject("SELECT * FROM products WHERE id = LAST_INSERT_ID();", this::mapToProduct);
+ }
+
+ //update a product method
+ public Product updateProduct(Product product) {
+ String sql = "UPDATE products SET name = ?, price = ? WHERE id = ?;";
+ int rows = jdbcTemplate.update(sql, product.getName(), product.getPrice(), product.getId());
+ if (rows == 0) {
+ throw new DaoException("Zero rows touched, expected at least one row");
+ }
+ return getProductById(product.getId());
+ }
+
+ //delete a product method
+ public int deleteProduct(int id) {
+ return jdbcTemplate.update("DELETE FROM products WHERE id = ?;", id);
+
+ }
+
+ private Product mapToProduct(ResultSet resultSet, int rowNum) throws SQLException {
+ return new Product(
+ resultSet.getInt("id"),
+ resultSet.getString("name"),
+ resultSet.getBigDecimal("price")
+ );
+ }
+}
\ No newline at end of file
diff --git a/java-springboot-final/src/main/resources/application.properties b/java-springboot-final/src/main/resources/application.properties
index 6a7d9e5..034ecb9 100644
--- a/java-springboot-final/src/main/resources/application.properties
+++ b/java-springboot-final/src/main/resources/application.properties
@@ -1,3 +1,3 @@
spring.datasource.url=jdbc:mysql://localhost:3306/web_shop
-spring.datasource.username=root
-spring.datasource.password=your-password
+spring.datasource.username=nick0
+spring.datasource.password=Nb221291??