diff --git a/Documentation/Diagrams/Entity Relationship Diagram.md b/Documentation/Diagrams/Entity Relationship Diagram.md index 6a9b285..1507a78 100644 --- a/Documentation/Diagrams/Entity Relationship Diagram.md +++ b/Documentation/Diagrams/Entity Relationship Diagram.md @@ -1,88 +1,36 @@ ```mermaid erDiagram Customer { - int id PK + long id PK string first_name string last_name string country - string state string address int postal_code - int phone_number int mobile_number string email - int invoice_id FK int review_id FK } - Employee { - int id PK - string first_name - string last_name - string country - string state - string address - int postal_code - int phone_number - int mobile_number - string email - string designation - string department - } - - Invoice { - int id PK - string date - string time - int customer_id FK - int transaction_id FK - } - Review { - int id PK + long id PK string category - double rating string review_content + int rating int customer_id FK int product_id FK } Product { - int id PK - int item_code + long id PK string category string name string description double price int stock_quantity - string review_id FK - } - - Store { - int id PK - string name - string country - string state - string address - int postal_code - int phone_number - int store_stock_quantity - int employee_id FK - int product_id FK - } - - Transaction { - int id PK - int quantity - int product_id FK + int review_id FK } Customer ||--O{ Review : "Has" - Customer ||--O{ Invoice : "Has" - Invoice ||--|{ Transaction : "Has" Product ||--O{ Review : "Has" - Store }O--O{ Product : "Has" - Store ||--|{ Employee : "Has" - Transaction }O--|| Product : "Has" - %% Employee |O--O{ Employee : "Manages" ``` diff --git a/src/main/java/sg/com/smartinventory/DataLoader.java b/src/main/java/sg/com/smartinventory/DataLoader.java index 9346109..618aa2f 100644 --- a/src/main/java/sg/com/smartinventory/DataLoader.java +++ b/src/main/java/sg/com/smartinventory/DataLoader.java @@ -13,53 +13,60 @@ @Component public class DataLoader { - // Inject all repositories. - private CustomerRepository customerRepository; - private ProductRepository productRepository; - private ReviewRepository reviewRepository; + // Inject all repositories. + private CustomerRepository customerRepository; + private ProductRepository productRepository; + private ReviewRepository reviewRepository; - // @Autowired - public DataLoader(CustomerRepository customerRepository, ProductRepository productRepository, - ReviewRepository reviewRepository) { - this.customerRepository = customerRepository; - this.productRepository = productRepository; - this.reviewRepository = reviewRepository; - } + // @Autowired + public DataLoader(CustomerRepository customerRepository, ProductRepository productRepository, + ReviewRepository reviewRepository) { + this.customerRepository = customerRepository; + this.productRepository = productRepository; + this.reviewRepository = reviewRepository; + } - @PostConstruct - public void loadData() { - // Clear all data. - customerRepository.deleteAll(); - productRepository.deleteAll(); - reviewRepository.deleteAll(); + @PostConstruct + public void loadData() { + // Clear all data. + customerRepository.deleteAll(); + productRepository.deleteAll(); + reviewRepository.deleteAll(); - // Create fake data. - customerRepository - .save(new Customer("John", "Doe", "USA", "123 Main St", 123456, 12345678, "john.doe@example.com", 101)); - customerRepository.save( - new Customer("Alice", "Smith", "Canada", "456 Maple Ave", 543210, 98765432, "alice.smith@example.com", 102)); - customerRepository.save( - new Customer("Michael", "Johnson", "UK", "789 Oak Rd", 567890, 98761234, "michael.johnson@example.com", 103)); - customerRepository.save( - new Customer("Emily", "Brown", "Australia", "321 Elm St", 135790, 45678912, "emily.brown@example.com", 104)); - customerRepository.save( - new Customer("David", "Wilson", "Germany", "654 Pine Rd", 987655, 36985214, "david.wilson@example.com", 105)); + // Create fake data. + customerRepository + .save(new Customer("John", "Doe", "USA", "123 Main St", 123456, 12345678, "john.doe@example.com", 101)); + customerRepository.save( + new Customer("Alice", "Smith", "Canada", "456 Maple Ave", 543210, 98765432, "alice.smith@example.com", + 102)); + customerRepository.save( + new Customer("Michael", "Johnson", "UK", "789 Oak Rd", 567890, 98761234, "michael.johnson@example.com", + 103)); + customerRepository.save( + new Customer("Emily", "Brown", "Australia", "321 Elm St", 135790, 45678912, "emily.brown@example.com", + 104)); + customerRepository.save( + new Customer("David", "Wilson", "Germany", "654 Pine Rd", 987655, 36985214, "david.wilson@example.com", + 105)); - productRepository.save( - new Product("Electronics", "Smartphone", "High-end smartphone with advanced features", 999.99, 100, "101")); - productRepository.save( - new Product("Clothing", "Men's T-Shirt", "Comfortable cotton t-shirt for everyday wear", 29.99, 500, "102")); - productRepository.save(new Product("Home & Kitchen", "Coffee Maker", - "Automatic coffee maker with programmable settings", 49.99, 50, "103")); - productRepository - .save(new Product("Beauty", "Perfume", "Elegant fragrance with floral and citrus notes", 79.99, 200, "104")); - productRepository.save(new Product("Books", "Science Fiction Novel", - "Bestselling sci-fi novel set in a dystopian future", 14.99, 300, "105")); + productRepository.save( + new Product("Electronics", "Smartphone", "High-end smartphone with advanced features", 999.99, 100, + 101)); + productRepository.save( + new Product("Clothing", "Men's T-Shirt", "Comfortable cotton t-shirt for everyday wear", 29.99, 500, + 102)); + productRepository.save(new Product("Home & Kitchen", "Coffee Maker", + "Automatic coffee maker with programmable settings", 49.99, 50, 103)); + productRepository + .save(new Product("Beauty", "Perfume", "Elegant fragrance with floral and citrus notes", 79.99, 200, + 104)); + productRepository.save(new Product("Books", "Science Fiction Novel", + "Bestselling sci-fi novel set in a dystopian future", 14.99, 300, 105)); - reviewRepository.save(new Review("Electronics", "Great smartphone with excellent features.", 5, 101, 201)); - reviewRepository.save(new Review("Clothing", "Very comfortable t-shirt, fits perfectly.", 4, 102, 202)); - reviewRepository.save(new Review("Home & Kitchen", "Makes delicious coffee, easy to use.", 4, 103, 203)); - reviewRepository.save(new Review("Beauty", "Lovely fragrance, long-lasting.", 5, 104, 204)); - reviewRepository.save(new Review("Books", "Intriguing plot, couldn't put it down.", 5, 105, 205)); - } + reviewRepository.save(new Review("Electronics", "Great smartphone with excellent features.", 5, 101, 201)); + reviewRepository.save(new Review("Clothing", "Very comfortable t-shirt, fits perfectly.", 4, 102, 202)); + reviewRepository.save(new Review("Home & Kitchen", "Makes delicious coffee, easy to use.", 4, 103, 203)); + reviewRepository.save(new Review("Beauty", "Lovely fragrance, long-lasting.", 5, 104, 204)); + reviewRepository.save(new Review("Books", "Intriguing plot, couldn't put it down.", 5, 105, 205)); + } } \ No newline at end of file diff --git a/src/main/java/sg/com/smartinventory/entity/Product.java b/src/main/java/sg/com/smartinventory/entity/Product.java index 188a996..6c4268d 100644 --- a/src/main/java/sg/com/smartinventory/entity/Product.java +++ b/src/main/java/sg/com/smartinventory/entity/Product.java @@ -39,13 +39,13 @@ public class Product { private int stockQuantity; @Column(name = "review_id") - private String reviewId; // FK. + private int reviewId; // FK. public Product() { } // Define Constructor for DataLoader. - public Product(String category, String name, String description, double price, int stockQuantity, String reviewId) { + public Product(String category, String name, String description, double price, int stockQuantity, int reviewId) { this(); this.category = category;