A fictional company has been created for a customer who is passionate about flying drones for activities such as aerial photography and exploring locations inaccessible to humans. Their enthusiasm led them to start a business that not only sells drones and accessories but also offers blogs to help fellow drone enthusiasts select the right equipment for any task or adventure.
My collaboration on this project was instrumental in making the website fully functional by implementing CRUD (Create, Read, Update, Delete) functionality and ensuring logic was in place to validate entries and operations. Below is a detailed walk-through of my contributions, outlining the changes made and where they can be found within the project.
-
Line 14:
Changed<title> My Bicycle Shop <title>
To<title> Ndlovu Drone Shop </title>
-
Line 19:
Changed<h1>Shop </h1>
To<h1>Ndlovu Drone Shop </h1>
-
Line 21:
Changed<h2>Parts </h2>
To<h2>Accessories </h2>
-
Line 54:
Changed<h2>Products </h2>
To<h2>Consoles </h2>
- Content:
Created an "About Us" page that includes company details, contact information, and a link to the main screen.
- Lines 17-22:
Added an "About Us" button linking to theabout.html
.
- Controller Creation:
CreatedAboutController
with@GetMapping
for servingabout.html
.
Added@Controller
annotation.
-
New Imports:
- Line 16:
import java.util.HashSet;
- Line 19:
import java.util.Set;
- Line 16:
-
Conditional Check:
- Line 54: Added a condition to populate the repository only if it's empty:
if (outsourcedPartRepository.count() == 0 && productRepository.count() == 0)
- Line 54: Added a condition to populate the repository only if it's empty:
-
Outsourced Parts Added:
- Lines 55-96: Added 5 parts with their prices, inventory, and IDs.
-
Multi-pack Logic:
- Lines 113-127: Implemented logic to create "Multi-pack" versions for existing parts.
-
Products Added:
- Lines 131-141: Added 5 products including their prices and inventory.
-
Annotations:
- Line 13: Added
@Controller
annotation. - Line 16: Added
@Autowired
annotation.
- Line 13: Added
-
Private Variable:
- Line 17: Initialized
ProductRepository
.
- Line 17: Initialized
-
Methods:
- Lines 19-36: Created a method to decrement inventory upon purchase using
@PostMapping
. - Lines 37-45: Created methods with
@GetMapping
to serve success and failure pages.
- Lines 19-36: Created a method to decrement inventory upon purchase using
- Lines 93-97:
Added a Thymeleaf form to create a functional "Buy Now" button.
- Displays a success message for each successful purchase and includes a link to return to the main screen.
- Displays a failure message when a purchase is unsuccessful, with a link back to the main screen.
- Lines 32-33: Initialized
minInv
. - Lines 35-36: Initialized
maxInv
. - Lines 46-49: Added a constructor with
minInv
andmaxInv
parameters. - Lines 112-122: Created getters and setters for
minInv
andmaxInv
.
-
Min/Max Inventory Updates:
- Lines 61-102: Set
minInv
andmaxInv
for all sample inventory items.
- Lines 61-102: Set
-
Table Updates:
- Lines 174-175: Added "Minimum Inventory" and "Maximum Inventory" table headers.
- Lines 184-185: Added
minInv
andmaxInv
fields in the table.
- Line 6: Updated database name to
spring-boot-h2-db106somerandomstring
.
-
AddOutsourcedPartController.java:
- Lines 43-57: Added validation to check if inventory is within the min/max range using
lessThanMin()
andgreaterThanMax()
methods.
- Lines 43-57: Added validation to check if inventory is within the min/max range using
-
AddInhousePartController.java:
- Lines 43-57: Implemented validation to display errors if the inventory is below the minimum or above the maximum.
- Lines 105-144:
Created unit tests forgetMinInv()
,setMinInv()
,getMaxInv()
, andsetMaxInv()
.
- Deleted the
DeletePartValidator.java
class as it was no longer in use.