Skip to content

Write order item dao - #1

Open
Nick040791 wants to merge 15 commits into
mainfrom
write-order-item-dao
Open

Write order item dao#1
Nick040791 wants to merge 15 commits into
mainfrom
write-order-item-dao

Conversation

@Nick040791

Copy link
Copy Markdown
Owner

Merge working branch into main.

All unit tests pass
All Postman Tests pass with exception of put update in Orders. There is no order 6.

- Created MySQL 'web_shop' server running on port 3306
- Configured spring.datasource user/pass
1. Loaded/ran 'create-database.sql' script in My SQL workbench successfully serving over port 3306
2. Test ran Spring Boor Application in IntelliJ
3. Postman collections loaded from import into workspace
3. Ran POST login to authenticate as Admin
4. Ran Profile and User REST endpoint requests with success. using Postman

*Read for exercises*
-OrderController.java
-OrderItemController.java
-ProdcutController.java
Created the Product DAO class, fixed capitalization issues and ran the spring boot application.

implemented:

get
create
update
delete

tests never reach the DAO because there is no ProductController yet.
implemented Product Controller for Product DAO

get
create
update
delete

-all ProductEndpointTests unit tests pass
-all Postman Products API endpoint  tests pass
implemented the Order Data Access Object with:

list order,
list order by username,
get order by id,
create order,
OrderController for OrderDao implemented:

list,
get,
create,
update,
delete,
controls

units tests pass for OrderEndpointTests, ProductsEndpointTests, and UserEndpointTests

Postman API endpoint tests pass for Orders other than update order --
updated OrderItemDao class with

list
list order
get by id
create
update
delete

-- cannot test without controller
Completed OrderByItemController

- all unit tests pass
- all postman endpoint tests pass

Unit 2 complete!
Copilot AI lite review requested due to automatic review settings August 10, 2026 03:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR merges a working branch that adds CRUD data-access and REST endpoints for Products, Orders, and Order Items, along with Postman collections to exercise the API. It also updates local environment/build settings (datasource config, Maven compiler settings) and includes IDE workspace metadata.

Changes:

  • Added DAO layers for products, orders, and order items using JdbcTemplate.
  • Added REST controllers for products, orders, and order items (including optional query-parameter filters).
  • Added Postman workspace/collection YAMLs for users/profile/products/orders/order-items, plus updated local config/IDE metadata.

Reviewed changes

Copilot reviewed 45 out of 59 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
java-springboot-final/src/main/resources/application.properties Updates datasource credentials.
java-springboot-final/src/main/java/org/example/daos/ProductDao.java Adds JDBC DAO for products.
java-springboot-final/src/main/java/org/example/daos/OrderItemDao.java Adds JDBC DAO for order items.
java-springboot-final/src/main/java/org/example/daos/OrderDao.java Adds JDBC DAO for orders.
java-springboot-final/src/main/java/org/example/controllers/ProductController.java Adds REST CRUD endpoints for products.
java-springboot-final/src/main/java/org/example/controllers/OrderItemController.java Adds REST CRUD endpoints for order items (+ optional orderId filter).
java-springboot-final/src/main/java/org/example/controllers/OrderController.java Adds REST CRUD endpoints for orders (+ optional username filter, Principal override on POST).
java-springboot-final/postman/postman/globals/workspace.globals.yaml Adds Postman globals scaffold.
java-springboot-final/postman/postman/collections/web-store/Users/Get Test User.request.yaml Adds Postman request for getting test user.
java-springboot-final/postman/postman/collections/web-store/Users/Get Test User Roles.request.yaml Adds Postman request for getting test user roles.
java-springboot-final/postman/postman/collections/web-store/Users/Get All Users.request.yaml Adds Postman request for listing users.
java-springboot-final/postman/postman/collections/web-store/Users/Delete Test User.request.yaml Adds Postman request for deleting test user.
java-springboot-final/postman/postman/collections/web-store/Users/Delete TEST role from test.request.yaml Adds Postman request for removing a role from test user.
java-springboot-final/postman/postman/collections/web-store/Users/Create Test User.request.yaml Adds Postman request for creating test user.
java-springboot-final/postman/postman/collections/web-store/Users/Change Test Password.request.yaml Adds Postman request for changing test user password.
java-springboot-final/postman/postman/collections/web-store/Users/Add TEST role to test.request.yaml Adds Postman request for adding TEST role.
java-springboot-final/postman/postman/collections/web-store/Users/Add ADMIN role to test.request.yaml Adds Postman request for adding ADMIN role.
java-springboot-final/postman/postman/collections/web-store/Users/.resources/definition.yaml Adds Postman folder definition for Users.
java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile.request.yaml Adds Postman request for profile.
java-springboot-final/postman/postman/collections/web-store/Profile/Get Profile Roles.request.yaml Adds Postman request for profile roles.
java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -test-.request.yaml Adds Postman request for changing profile password to test.
java-springboot-final/postman/postman/collections/web-store/Profile/Change Password To -admin-.request.yaml Adds Postman request for changing profile password to admin.
java-springboot-final/postman/postman/collections/web-store/Profile/.resources/definition.yaml Adds Postman folder definition for Profile.
java-springboot-final/postman/postman/collections/web-store/Products/Update Product 6.request.yaml Adds Postman request for updating product.
java-springboot-final/postman/postman/collections/web-store/Products/Get Product By Id.request.yaml Adds Postman request for getting product by id.
java-springboot-final/postman/postman/collections/web-store/Products/Get All Products.request.yaml Adds Postman request for listing products.
java-springboot-final/postman/postman/collections/web-store/Products/Delete Product 6.request.yaml Adds Postman request for deleting product.
java-springboot-final/postman/postman/collections/web-store/Products/Create Product 6.request.yaml Adds Postman request for creating product.
java-springboot-final/postman/postman/collections/web-store/Products/.resources/definition.yaml Adds Postman folder definition for Products.
java-springboot-final/postman/postman/collections/web-store/Orders/Update Order 6.request.yaml Adds Postman request for updating order.
java-springboot-final/postman/postman/collections/web-store/Orders/Get Order By Id.request.yaml Adds Postman request for getting order by id.
java-springboot-final/postman/postman/collections/web-store/Orders/Get All Orders.request.yaml Adds Postman request for listing orders.
java-springboot-final/postman/postman/collections/web-store/Orders/Delete Order 6.request.yaml Adds Postman request for deleting order.
java-springboot-final/postman/postman/collections/web-store/Orders/Create Order 6.request.yaml Adds Postman request for creating order.
java-springboot-final/postman/postman/collections/web-store/Orders/.resources/definition.yaml Adds Postman folder definition for Orders.
java-springboot-final/postman/postman/collections/web-store/Order Items/Update Order Item 1.request.yaml Adds Postman request for updating order item.
java-springboot-final/postman/postman/collections/web-store/Order Items/Get Order Item By Id.request.yaml Adds Postman request for getting order item by id.
java-springboot-final/postman/postman/collections/web-store/Order Items/Get All Order Items.request.yaml Adds Postman request for listing order items.
java-springboot-final/postman/postman/collections/web-store/Order Items/Delete Order Item 1.request.yaml Adds Postman request for deleting order item.
java-springboot-final/postman/postman/collections/web-store/Order Items/Create Order Item 1.request.yaml Adds Postman request for creating order item.
java-springboot-final/postman/postman/collections/web-store/Order Items/.resources/definition.yaml Adds Postman folder definition for Order Items.
java-springboot-final/postman/postman/collections/web-store/login.request.yaml Adds Postman login request with token extraction script.
java-springboot-final/postman/postman/collections/web-store/.resources/definition.yaml Adds Postman collection definition (variables/auth).
java-springboot-final/postman/.postman/resources.yaml Adds Postman workspace resources mapping.
java-springboot-final/pom.xml Adds Maven compiler plugin configuration.
java-springboot-final/.idea/sqldialects.xml Adds IntelliJ SQL dialect mapping (IDE metadata).
java-springboot-final/.idea/dataSources/data_sources_history.xml Adds IntelliJ datasource history (IDE metadata).
java-springboot-final/.idea/dataSources.xml Adds IntelliJ datasource config (IDE metadata).
java-springboot-final/.idea/dataSources.local.xml Adds IntelliJ local datasource config (IDE metadata).
java-springboot-final/.idea/data_source_mapping.xml Adds IntelliJ datasource file mappings (IDE metadata).
.idea/vcs.xml Adds root IntelliJ VCS mapping (IDE metadata).
.idea/modules.xml Adds root IntelliJ module config (IDE metadata).
.idea/misc.xml Adds root IntelliJ project SDK config (IDE metadata).
.idea/jarRepositories.xml Adds root IntelliJ jar repos config (IDE metadata).
.idea/flexpath-unit-2-final.iml Adds root IntelliJ module file (IDE metadata).
.idea/encodings.xml Adds root IntelliJ encodings config (IDE metadata).
.idea/dataSources.xml Adds root IntelliJ datasource config (IDE metadata).
.idea/compiler.xml Adds root IntelliJ compiler settings (IDE metadata).
.idea/.gitignore Adds IntelliJ gitignore rules.
Files not reviewed (14)
  • .idea/.gitignore: Generated file
  • .idea/compiler.xml: Generated file
  • .idea/dataSources.xml: Generated file
  • .idea/encodings.xml: Generated file
  • .idea/flexpath-unit-2-final.iml: Generated file
  • .idea/jarRepositories.xml: Generated file
  • .idea/misc.xml: Generated file
  • .idea/modules.xml: Generated file
  • .idea/vcs.xml: Generated file
  • java-springboot-final/.idea/dataSources.local.xml: Generated file
  • java-springboot-final/.idea/dataSources.xml: Generated file
  • java-springboot-final/.idea/dataSources/data_sources_history.xml: Generated file
  • java-springboot-final/.idea/data_source_mapping.xml: Generated file
  • java-springboot-final/.idea/sqldialects.xml: Generated file
Suppressed comments (1)

java-springboot-final/src/main/java/org/example/controllers/OrderController.java:67

  • This comment is a local Postman run note and doesn't belong in production code. If it's still needed, move it to the Postman collection/README instead.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +2 to +3
spring.datasource.username=nick0
spring.datasource.password=Nb221291??
Comment thread java-springboot-final/pom.xml Outdated
Comment on lines +95 to +102
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>25</source>
<target>25</target>
</configuration>
</plugin>
Comment on lines +40 to +44
try {
return orderItemDao.updateOrderItem(item);
} catch (RuntimeException e) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Order item not found");
}
Comment on lines +51 to +55
try {
return orderDao.updateOrder(order);
} catch (RuntimeException e) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Order not found");
}
Comment on lines +1 to +19
<DataSourcesHistory>
<DataSourceFromHistory isRemovedFromProject="false">
<data-source source="LOCAL" name="web_shop@localhost" uuid="85733b47-5a05-4bc1-95af-19085e761aa9">
<database-info product="" version="" jdbc-version="" driver-name="" driver-version="" dbms="MYSQL" />
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>C:/Users/nicho/OneDrive/Documents/GitHub/flexpath-unit-2-final/java-springboot-final/src/main/resources/application.properties</remarks>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306/web_shop</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<secret-storage>master_key</secret-storage>
<user-name>nick0</user-name>
<schema-mapping />
<working-dir>$ProjectFileDir$</working-dir>
Comment on lines +1 to +6
/*
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.
*/
Comment on lines +37 to +41
try {
return productDao.updateProduct(product);
} catch (RuntimeException e) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Product not found");
}
-changed project settings to JDK 17
- removed java 25 compiler plugin from pom.xl
clear sensitive credentials
set to placeholder values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants