diff --git a/Petstoredata.sql b/Petstoredata.sql new file mode 100644 index 00000000..8c7c1576 --- /dev/null +++ b/Petstoredata.sql @@ -0,0 +1,394 @@ +DROP DATABASE IF EXISTS Petstoredb; +CREATE DATABASE Petstoredb; +USE Petstoredb; + +-- Create Tables + +CREATE TABLE storeLocation ( + storeId INT AUTO_INCREMENT PRIMARY KEY, + storeName VARCHAR(100) NOT NULL, + address VARCHAR(255) NOT NULL, + phone VARCHAR(20) NOT NULL, + email VARCHAR(100) NOT NULL +); + +CREATE TABLE employee ( + employeeId INT AUTO_INCREMENT PRIMARY KEY, + firstName VARCHAR(50) NOT NULL, + lastName VARCHAR(50) NOT NULL, + email VARCHAR(100) NOT NULL, + phone VARCHAR(20) NOT NULL, + role VARCHAR(50) NOT NULL, + isActive BOOLEAN DEFAULT TRUE NOT NULL +); + +CREATE TABLE employeeStore ( + employeeId INT NOT NULL, + storeId INT NOT NULL, + PRIMARY KEY (employeeId, storeId), + FOREIGN KEY (employeeId) REFERENCES employee(employeeId), + FOREIGN KEY (storeId) REFERENCES storeLocation(storeId) +); + +CREATE TABLE customer ( + customerId INT AUTO_INCREMENT PRIMARY KEY, + firstName VARCHAR(50) NOT NULL, + lastName VARCHAR(50) NOT NULL, + email VARCHAR(100) NOT NULL, + phone VARCHAR(20) NOT NULL +); + +CREATE TABLE pet ( + petId INT AUTO_INCREMENT PRIMARY KEY, + petName VARCHAR(50) NOT NULL, + petSpecies VARCHAR(50) NOT NULL, + petBreed VARCHAR(50) NOT NULL, + petAge INT NOT NULL, + petStatus VARCHAR(20) NOT NULL, + petPrice DECIMAL(10, 2) NOT NULL +); + +CREATE TABLE adoption ( + adoptionId INT AUTO_INCREMENT PRIMARY KEY, + petId INT NOT NULL, + customerId INT NOT NULL, + adoptionDate DATE NOT NULL, + adoptionStatus VARCHAR(20) NOT NULL, + FOREIGN KEY (petId) REFERENCES pet(petId), + FOREIGN KEY (customerId) REFERENCES customer(customerId) +); + +CREATE TABLE supplier ( + supId INT AUTO_INCREMENT PRIMARY KEY, + supCompany VARCHAR(100) NOT NULL, + supContactFirstName VARCHAR(50) NOT NULL, + supContactLastName VARCHAR(50) NOT NULL, + supEmail VARCHAR(100) NOT NULL, + supPhone VARCHAR(20) NOT NULL +); + +CREATE TABLE category ( + categoryId INT AUTO_INCREMENT PRIMARY KEY, + categoryName VARCHAR(100) NOT NULL, + categoryType VARCHAR(50) NOT NULL +); + +CREATE TABLE product ( + prodId INT AUTO_INCREMENT PRIMARY KEY, + prodName VARCHAR(100) NOT NULL, + prodPrice DECIMAL(10, 2) NOT NULL, + categoryId INT NOT NULL, + prodDesc TEXT, + FOREIGN KEY (categoryId) REFERENCES category(categoryId) +); + +CREATE TABLE productSupplier ( + supId INT NOT NULL, + prodId INT NOT NULL, + cost DECIMAL(10, 2) NOT NULL, + PRIMARY KEY (supId, prodId), + FOREIGN KEY (supId) REFERENCES supplier(supId), + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE inventory ( + inventoryId INT AUTO_INCREMENT PRIMARY KEY, + prodId INT NOT NULL, + quantity INT DEFAULT 0 NOT NULL, + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE service ( + serviceId INT AUTO_INCREMENT PRIMARY KEY, + serviceName VARCHAR(100) NOT NULL, + serviceDesc TEXT, + serviceDuration INT NOT NULL, + servicePrice DECIMAL(10, 2) NOT NULL +); + +CREATE TABLE appointment ( + appointmentId INT AUTO_INCREMENT PRIMARY KEY, + serviceId INT NOT NULL, + customerId INT NOT NULL, + appointmentDate DATE NOT NULL, + appointmentTime TIME NOT NULL, + appointmentStatus VARCHAR(20) NOT NULL, + FOREIGN KEY (serviceId) REFERENCES service(serviceId), + FOREIGN KEY (customerId) REFERENCES customer(customerId) +); + +CREATE TABLE appointmentPet ( + appointmentId INT NOT NULL, + petId INT NOT NULL, + PRIMARY KEY (appointmentId, petId), + FOREIGN KEY (appointmentId) REFERENCES appointment(appointmentId), + FOREIGN KEY (petId) REFERENCES pet(petId) +); + +CREATE TABLE sale ( + saleId INT AUTO_INCREMENT PRIMARY KEY, + saleDate DATETIME NOT NULL, + totalAmount DECIMAL(10, 2) NOT NULL, + paymentMethod VARCHAR(50) NOT NULL, + employeeId INT NOT NULL, + storeId INT NOT NULL, + isRefund BOOLEAN DEFAULT FALSE NOT NULL, + originalSaleId INT NULL, + FOREIGN KEY (employeeId) REFERENCES employee(employeeId), + FOREIGN KEY (storeId) REFERENCES storeLocation(storeId), + FOREIGN KEY (originalSaleId) REFERENCES sale(saleId) +); + +CREATE TABLE saleItem ( + saleItemId INT AUTO_INCREMENT PRIMARY KEY, + saleId INT NOT NULL, + prodId INT NOT NULL, + quantity INT NOT NULL, + unitPrice DECIMAL(10, 2) NOT NULL, + FOREIGN KEY (saleId) REFERENCES sale(saleId), + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE purchaseOrder ( + purchaseOrderId INT AUTO_INCREMENT PRIMARY KEY, + supId INT NOT NULL, + orderDate DATE NOT NULL, + status VARCHAR(50) NOT NULL, + FOREIGN KEY (supId) REFERENCES supplier(supId) +); + +CREATE TABLE activityLog ( + logId INT AUTO_INCREMENT PRIMARY KEY, + employeeId INT NOT NULL, + activity TEXT NOT NULL, + logTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (employeeId) REFERENCES employee(employeeId) +); + +-- Insert Sample Data + +INSERT INTO storeLocation (storeName, address, phone, email) +VALUES +('Downtown Branch', '123 Main St', '123-456-7890', 'downtown@petshop.com'), +('North Branch', '456 North Ave', '987-654-3210', 'north@petshop.com'), +('West Side Store', '789 West Blvd', '555-123-4567', 'westside@petshop.com'), +('East End Shop', '321 East Road', '555-987-6543', 'eastend@petshop.com'), +('South Mall Location', '654 South Plaza', '555-246-8135', 'southmall@petshop.com'); + +INSERT INTO employee (firstName, lastName, email, phone, role, isActive) +VALUES +('John', 'Doe', 'john@petshop.com', '111-222-3333', 'Manager', TRUE), +('Sara', 'Smith', 'sara@petshop.com', '444-555-6666', 'Staff', TRUE), +('Michael', 'Johnson', 'michael@petshop.com', '222-333-4444', 'Groomer', TRUE), +('Lisa', 'Williams', 'lisa@petshop.com', '333-444-5555', 'Staff', TRUE), +('David', 'Brown', 'david@petshop.com', '555-666-7777', 'Veterinarian', TRUE), +('Emma', 'Davis', 'emma@petshop.com', '666-777-8888', 'Manager', FALSE); + +INSERT INTO employeeStore (employeeId, storeId) +VALUES +(1, 1), +(2, 1), +(2, 2), +(3, 2), +(4, 3), +(5, 1), +(5, 4), +(6, 5); + +INSERT INTO customer (firstName, lastName, email, phone) +VALUES +('Alex', 'Brown', 'alex@gmail.com', '777-888-9999'), +('Emily', 'Clark', 'emily@gmail.com', '666-555-4444'), +('James', 'Wilson', 'james@gmail.com', '888-999-0000'), +('Olivia', 'Martinez', 'olivia@gmail.com', '999-000-1111'), +('William', 'Anderson', 'william@gmail.com', '000-111-2222'), +('Sophia', 'Taylor', 'sophia@gmail.com', '111-222-3333'); + +INSERT INTO pet (petName, petSpecies, petBreed, petAge, petStatus, petPrice) +VALUES +('Buddy', 'Dog', 'Labrador', 2, 'Available', 500.00), +('Milo', 'Cat', 'Persian', 1, 'Available', 300.00), +('Charlie', 'Dog', 'Golden Retriever', 3, 'Available', 550.00), +('Luna', 'Cat', 'Siamese', 2, 'Adopted', 350.00), +('Max', 'Dog', 'Beagle', 1, 'Available', 450.00), +('Bella', 'Cat', 'Maine Coon', 4, 'Available', 400.00); + +INSERT INTO adoption (petId, customerId, adoptionDate, adoptionStatus) +VALUES +(1, 1, '2026-01-15', 'Completed'), +(4, 3, '2026-01-20', 'Completed'), +(2, 2, '2026-01-25', 'Pending'), +(5, 4, '2026-02-01', 'Completed'), +(6, 5, '2026-02-02', 'Pending'); + +INSERT INTO supplier (supCompany, supContactFirstName, supContactLastName, supEmail, supPhone) +VALUES +('PetFood Inc', 'Robert', 'King', 'contact@petfood.com', '888-111-2222'), +('Toy World', 'Jennifer', 'Lee', 'sales@toyworld.com', '888-222-3333'), +('Pet Supplies Co', 'Kevin', 'White', 'info@petsupplies.com', '888-333-4444'), +('Animal Care Products', 'Nancy', 'Green', 'orders@animalcare.com', '888-444-5555'), +('Premium Pet Goods', 'Tom', 'Black', 'support@premiumpet.com', '888-555-6666'); + +INSERT INTO category (categoryName, categoryType) +VALUES +('Dog Food', 'Product'), +('Cat Toys', 'Product'), +('Bird Supplies', 'Product'), +('Aquarium', 'Product'), +('Small Animals', 'Product'); + +INSERT INTO product (prodName, prodPrice, categoryId, prodDesc) +VALUES +('Premium Dog Food', 50.00, 1, 'High quality dog food'), +('Cat Toy Ball', 10.00, 2, 'Colorful toy for cats'), +('Bird Cage Large', 120.00, 3, 'Spacious bird cage'), +('Fish Tank 20 Gallon', 80.00, 4, 'Complete aquarium kit'), +('Hamster Wheel', 15.00, 5, 'Exercise wheel for small pets'), +('Organic Dog Treats', 25.00, 1, 'Natural dog treats'); + +INSERT INTO productSupplier (supId, prodId, cost) +VALUES +(1, 1, 35.00), +(1, 2, 6.50), +(2, 2, 7.00), +(3, 3, 90.00), +(3, 4, 60.00), +(4, 5, 10.00), +(5, 6, 18.00), +(1, 6, 17.50); + +INSERT INTO inventory (prodId, quantity) +VALUES +(1, 100), +(2, 200), +(3, 50), +(4, 30), +(5, 150), +(6, 75); + +INSERT INTO service (serviceName, serviceDesc, serviceDuration, servicePrice) +VALUES +('Pet Grooming', 'Full grooming service', 60, 40.00), +('Nail Trimming', 'Quick nail trim', 15, 10.00), +('Bath and Brush', 'Bathing and brushing service', 45, 30.00), +('Veterinary Checkup', 'Complete health examination', 30, 75.00), +('Teeth Cleaning', 'Professional dental cleaning', 90, 100.00); + +INSERT INTO appointment (serviceId, customerId, appointmentDate, appointmentTime, appointmentStatus) +VALUES +(1, 2, '2026-02-01', '10:30:00', 'Booked'), +(2, 1, '2026-02-03', '14:00:00', 'Booked'), +(3, 3, '2026-02-05', '09:00:00', 'Completed'), +(4, 4, '2026-02-07', '11:30:00', 'Booked'), +(5, 5, '2026-02-10', '15:00:00', 'Cancelled'); + +INSERT INTO appointmentPet (appointmentId, petId) +VALUES +(1, 2), +(2, 1), +(3, 3), +(4, 5), +(5, 6); + +INSERT INTO sale (saleDate, totalAmount, paymentMethod, employeeId, storeId) +VALUES +-- January Sales +('2026-01-05 09:15:00', 125.00, 'Card', 1, 1), -- Sale 1: Dog food + treats +('2026-01-08 11:30:00', 200.00, 'Card', 2, 1), -- Sale 2: Bird cage + fish tank +('2026-01-12 14:20:00', 60.00, 'Cash', 3, 2), -- Sale 3: Cat toys + hamster wheel +('2026-01-15 10:45:00', 150.00, 'Debit', 1, 1), -- Sale 4: Dog food (bulk purchase) +('2026-01-18 16:30:00', 80.00, 'Card', 4, 3), -- Sale 5: Fish tank +('2026-01-22 13:15:00', 95.00, 'Cash', 2, 2), -- Sale 6: Mixed items +('2026-01-25 15:40:00', 240.00, 'Card', 5, 4), -- Sale 7: Two bird cages +('2026-01-28 10:30:00', 80.00, 'Cash', 1, 1), -- Sale 8: Dog food + cat toys +-- February Sales +('2026-02-01 09:00:00', 175.00, 'Card', 3, 3), -- Sale 9: Dog food + treats (bulk) +('2026-02-03 11:20:00', 120.00, 'Card', 2, 1), -- Sale 10: Bird cage +('2026-02-05 14:50:00', 45.00, 'Cash', 4, 2), -- Sale 11: Hamster wheel + cat toys +('2026-02-08 16:15:00', 160.00, 'Debit', 1, 1), -- Sale 12: Fish tank + accessories +('2026-02-10 10:25:00', 100.00, 'Card', 5, 4), -- Sale 13: Dog treats (bulk) +('2026-02-12 13:45:00', 50.00, 'Cash', 2, 2), -- Sale 14: Dog food +('2026-02-15 15:30:00', 85.00, 'Card', 3, 3), -- Sale 15: Mixed pet supplies +('2026-02-18 11:10:00', 200.00, 'Card', 1, 1), -- Sale 16: Bird cage + hamster wheel +('2026-02-20 14:35:00', 155.00, 'Debit', 4, 3), -- Sale 17: Fish tank + cat toys +('2026-02-22 16:50:00', 75.00, 'Cash', 2, 1), -- Sale 18: Dog treats + toys +('2026-02-24 10:15:00', 140.00, 'Card', 5, 4), -- Sale 19: Dog food + treats +(NOW(), 95.00, 'Card', 1, 1); -- Sale 20: Recent sale (current timestamp) + +INSERT INTO saleItem (saleId, prodId, quantity, unitPrice) +VALUES +-- Sale 1 items (Dog food + treats) +(1, 1, 2, 50.00), -- 2x Premium Dog Food +(1, 6, 1, 25.00), -- 1x Organic Dog Treats +-- Sale 2 items (Bird cage + fish tank) +(2, 3, 1, 120.00), -- 1x Bird Cage Large +(2, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +-- Sale 3 items (Cat toys + hamster wheel) +(3, 2, 3, 10.00), -- 3x Cat Toy Ball +(3, 5, 2, 15.00), -- 2x Hamster Wheel +-- Sale 4 items (Dog food bulk) +(4, 1, 3, 50.00), -- 3x Premium Dog Food +-- Sale 5 items (Fish tank) +(5, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +-- Sale 6 items (Mixed) +(6, 2, 4, 10.00), -- 4x Cat Toy Ball +(6, 5, 1, 15.00), -- 1x Hamster Wheel +(6, 6, 1, 25.00), -- 1x Organic Dog Treats +(6, 1, 1, 50.00), -- 1x Premium Dog Food (partial - discount applied) +-- Sale 7 items (Two bird cages) +(7, 3, 2, 120.00), -- 2x Bird Cage Large +-- Sale 8 items (Dog food + cat toys) +(8, 1, 1, 50.00), -- 1x Premium Dog Food +(8, 2, 3, 10.00), -- 3x Cat Toy Ball +-- Sale 9 items (Dog food + treats bulk) +(9, 1, 3, 50.00), -- 3x Premium Dog Food +(9, 6, 1, 25.00), -- 1x Organic Dog Treats +-- Sale 10 items (Bird cage) +(10, 3, 1, 120.00), -- 1x Bird Cage Large +-- Sale 11 items (Hamster wheel + cat toys) +(11, 5, 1, 15.00), -- 1x Hamster Wheel +(11, 2, 3, 10.00), -- 3x Cat Toy Ball +-- Sale 12 items (Fish tank + accessories) +(12, 4, 2, 80.00), -- 2x Fish Tank 20 Gallon +-- Sale 13 items (Dog treats bulk) +(13, 6, 4, 25.00), -- 4x Organic Dog Treats +-- Sale 14 items (Dog food) +(14, 1, 1, 50.00), -- 1x Premium Dog Food +-- Sale 15 items (Mixed supplies) +(15, 2, 2, 10.00), -- 2x Cat Toy Ball +(15, 5, 1, 15.00), -- 1x Hamster Wheel +(15, 6, 2, 25.00), -- 2x Organic Dog Treats +-- Sale 16 items (Bird cage + hamster wheel) +(16, 3, 1, 120.00), -- 1x Bird Cage Large +(16, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +-- Sale 17 items (Fish tank + cat toys) +(17, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +(17, 1, 1, 50.00), -- 1x Premium Dog Food +(17, 6, 1, 25.00), -- 1x Organic Dog Treats +-- Sale 18 items (Dog treats + toys) +(18, 6, 2, 25.00), -- 2x Organic Dog Treats +(18, 2, 2, 10.00), -- 2x Cat Toy Ball +(18, 5, 1, 15.00), -- 1x Hamster Wheel +-- Sale 19 items (Dog food + treats) +(19, 1, 2, 50.00), -- 2x Premium Dog Food +(19, 6, 2, 25.00), -- 2x Organic Dog Treats (discount applied) +-- Sale 20 items (Recent sale) +(20, 2, 5, 10.00), -- 5x Cat Toy Ball +(20, 5, 3, 15.00); -- 3x Hamster Wheel + +INSERT INTO purchaseOrder (supId, orderDate, status) +VALUES +(1, '2025-01-15', 'Delivered'), +(2, '2025-01-20', 'Pending'), +(3, '2025-02-01', 'Delivered'), +(4, '2025-02-10', 'In Transit'), +(1, '2025-02-15', 'Pending'); + +INSERT INTO activityLog (employeeId, activity) +VALUES +(1, 'Created new sale'), +(2, 'Booked appointment'), +(3, 'Completed grooming service'), +(4, 'Processed inventory order'), +(5, 'Conducted health checkup'), +(1, 'Updated customer information'); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index f82b2d8e..3e8a175b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: - "3306:3306" volumes: - db_data:/var/lib/mysql + - ./sql:/docker-entrypoint-initdb.d healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"] interval: 5s @@ -24,8 +25,8 @@ services: SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/Petstoredb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC SPRING_DATASOURCE_USERNAME: petshop SPRING_DATASOURCE_PASSWORD: petshop - # Change this in real use - JWT_SECRET: change_me_please + # Change this in real use (must be at least 32 characters) + JWT_SECRET: change_me_please_this_secret_key_is_long_enough_for_jwt_hmac_sha256 ports: - "8080:8080" depends_on: diff --git a/sql/01_petstore_init.sql b/sql/01_petstore_init.sql new file mode 100644 index 00000000..c8e8dbea --- /dev/null +++ b/sql/01_petstore_init.sql @@ -0,0 +1,436 @@ +DROP DATABASE IF EXISTS Petstoredb; +CREATE DATABASE Petstoredb; +USE Petstoredb; + +-- Create Tables + +CREATE TABLE storeLocation ( + storeId BIGINT AUTO_INCREMENT PRIMARY KEY, + storeName VARCHAR(100) NOT NULL, + address VARCHAR(255) NOT NULL, + phone VARCHAR(20) NOT NULL, + email VARCHAR(100) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +CREATE TABLE employee ( + employeeId BIGINT AUTO_INCREMENT PRIMARY KEY, + firstName VARCHAR(50) NOT NULL, + lastName VARCHAR(50) NOT NULL, + email VARCHAR(100) NOT NULL, + phone VARCHAR(20) NOT NULL, + role VARCHAR(50) NOT NULL, + isActive BOOLEAN DEFAULT TRUE NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +CREATE TABLE employeeStore ( + employeeId BIGINT NOT NULL, + storeId BIGINT NOT NULL, + PRIMARY KEY (employeeId, storeId), + FOREIGN KEY (employeeId) REFERENCES employee(employeeId), + FOREIGN KEY (storeId) REFERENCES storeLocation(storeId) +); + +CREATE TABLE customer ( + customerId BIGINT AUTO_INCREMENT PRIMARY KEY, + firstName VARCHAR(50) NOT NULL, + lastName VARCHAR(50) NOT NULL, + email VARCHAR(100) NOT NULL, + phone VARCHAR(20) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +CREATE TABLE pet ( + petId BIGINT AUTO_INCREMENT PRIMARY KEY, + petName VARCHAR(50) NOT NULL, + petSpecies VARCHAR(50) NOT NULL, + petBreed VARCHAR(50) NOT NULL, + petAge INT NOT NULL, + petStatus VARCHAR(20) NOT NULL, + petPrice DECIMAL(10, 2) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +CREATE TABLE adoption ( + adoptionId BIGINT AUTO_INCREMENT PRIMARY KEY, + petId BIGINT NOT NULL, + customerId BIGINT NOT NULL, + adoptionDate DATE NOT NULL, + adoptionStatus VARCHAR(20) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (petId) REFERENCES pet(petId), + FOREIGN KEY (customerId) REFERENCES customer(customerId) +); + +CREATE TABLE supplier ( + supId BIGINT AUTO_INCREMENT PRIMARY KEY, + supCompany VARCHAR(100) NOT NULL, + supContactFirstName VARCHAR(50) NOT NULL, + supContactLastName VARCHAR(50) NOT NULL, + supEmail VARCHAR(100) NOT NULL, + supPhone VARCHAR(20) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +CREATE TABLE category ( + categoryId BIGINT AUTO_INCREMENT PRIMARY KEY, + categoryName VARCHAR(100) NOT NULL, + categoryType VARCHAR(50) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +CREATE TABLE product ( + prodId BIGINT AUTO_INCREMENT PRIMARY KEY, + prodName VARCHAR(100) NOT NULL, + prodPrice DECIMAL(10, 2) NOT NULL, + categoryId BIGINT NOT NULL, + prodDesc TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (categoryId) REFERENCES category(categoryId) +); + +CREATE TABLE productSupplier ( + supId BIGINT NOT NULL, + prodId BIGINT NOT NULL, + cost DECIMAL(10, 2) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (supId, prodId), + FOREIGN KEY (supId) REFERENCES supplier(supId), + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE inventory ( + inventoryId BIGINT AUTO_INCREMENT PRIMARY KEY, + prodId BIGINT NOT NULL, + quantity INT DEFAULT 0 NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE service ( + serviceId BIGINT AUTO_INCREMENT PRIMARY KEY, + serviceName VARCHAR(100) NOT NULL, + serviceDesc TEXT, + serviceDuration INT NOT NULL, + servicePrice DECIMAL(10, 2) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +CREATE TABLE appointment ( + appointmentId BIGINT AUTO_INCREMENT PRIMARY KEY, + serviceId BIGINT NOT NULL, + customerId BIGINT NOT NULL, + appointmentDate DATE NOT NULL, + appointmentTime TIME NOT NULL, + appointmentStatus VARCHAR(20) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (serviceId) REFERENCES service(serviceId), + FOREIGN KEY (customerId) REFERENCES customer(customerId) +); + +CREATE TABLE appointmentPet ( + appointmentId BIGINT NOT NULL, + petId BIGINT NOT NULL, + PRIMARY KEY (appointmentId, petId), + FOREIGN KEY (appointmentId) REFERENCES appointment(appointmentId), + FOREIGN KEY (petId) REFERENCES pet(petId) +); + +CREATE TABLE sale ( + saleId BIGINT AUTO_INCREMENT PRIMARY KEY, + saleDate DATETIME NOT NULL, + totalAmount DECIMAL(10, 2) NOT NULL, + paymentMethod VARCHAR(50) NOT NULL, + employeeId BIGINT NOT NULL, + storeId BIGINT NOT NULL, + isRefund BOOLEAN DEFAULT FALSE NOT NULL, + originalSaleId BIGINT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (employeeId) REFERENCES employee(employeeId), + FOREIGN KEY (storeId) REFERENCES storeLocation(storeId), + FOREIGN KEY (originalSaleId) REFERENCES sale(saleId) +); + +CREATE TABLE saleItem ( + saleItemId BIGINT AUTO_INCREMENT PRIMARY KEY, + saleId BIGINT NOT NULL, + prodId BIGINT NOT NULL, + quantity INT NOT NULL, + unitPrice DECIMAL(10, 2) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (saleId) REFERENCES sale(saleId), + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE purchaseOrder ( + purchaseOrderId BIGINT AUTO_INCREMENT PRIMARY KEY, + supId BIGINT NOT NULL, + orderDate DATE NOT NULL, + status VARCHAR(50) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (supId) REFERENCES supplier(supId) +); + +CREATE TABLE activityLog ( + logId BIGINT AUTO_INCREMENT PRIMARY KEY, + employeeId BIGINT NOT NULL, + activity TEXT NOT NULL, + logTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, + FOREIGN KEY (employeeId) REFERENCES employee(employeeId) +); + +-- Backend-only table for API authentication +CREATE TABLE users ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) UNIQUE NOT NULL, + password VARCHAR(255) NOT NULL, + role VARCHAR(20) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); + +-- Insert Sample Data + +INSERT INTO storeLocation (storeName, address, phone, email) +VALUES +('Downtown Branch', '123 Main St', '123-456-7890', 'downtown@petshop.com'), +('North Branch', '456 North Ave', '987-654-3210', 'north@petshop.com'), +('West Side Store', '789 West Blvd', '555-123-4567', 'westside@petshop.com'), +('East End Shop', '321 East Road', '555-987-6543', 'eastend@petshop.com'), +('South Mall Location', '654 South Plaza', '555-246-8135', 'southmall@petshop.com'); + +INSERT INTO employee (firstName, lastName, email, phone, role, isActive) +VALUES +('John', 'Doe', 'john@petshop.com', '111-222-3333', 'Manager', TRUE), +('Sara', 'Smith', 'sara@petshop.com', '444-555-6666', 'Staff', TRUE), +('Michael', 'Johnson', 'michael@petshop.com', '222-333-4444', 'Groomer', TRUE), +('Lisa', 'Williams', 'lisa@petshop.com', '333-444-5555', 'Staff', TRUE), +('David', 'Brown', 'david@petshop.com', '555-666-7777', 'Veterinarian', TRUE), +('Emma', 'Davis', 'emma@petshop.com', '666-777-8888', 'Manager', FALSE); + +INSERT INTO employeeStore (employeeId, storeId) +VALUES +(1, 1), +(2, 1), +(2, 2), +(3, 2), +(4, 3), +(5, 1), +(5, 4), +(6, 5); + +INSERT INTO customer (firstName, lastName, email, phone) +VALUES +('Alex', 'Brown', 'alex@gmail.com', '777-888-9999'), +('Emily', 'Clark', 'emily@gmail.com', '666-555-4444'), +('James', 'Wilson', 'james@gmail.com', '888-999-0000'), +('Olivia', 'Martinez', 'olivia@gmail.com', '999-000-1111'), +('William', 'Anderson', 'william@gmail.com', '000-111-2222'), +('Sophia', 'Taylor', 'sophia@gmail.com', '111-222-3333'); + +INSERT INTO pet (petName, petSpecies, petBreed, petAge, petStatus, petPrice) +VALUES +('Buddy', 'Dog', 'Labrador', 2, 'Available', 500.00), +('Milo', 'Cat', 'Persian', 1, 'Available', 300.00), +('Charlie', 'Dog', 'Golden Retriever', 3, 'Available', 550.00), +('Luna', 'Cat', 'Siamese', 2, 'Adopted', 350.00), +('Max', 'Dog', 'Beagle', 1, 'Available', 450.00), +('Bella', 'Cat', 'Maine Coon', 4, 'Available', 400.00); + +INSERT INTO adoption (petId, customerId, adoptionDate, adoptionStatus) +VALUES +(1, 1, '2026-01-15', 'Completed'), +(4, 3, '2026-01-20', 'Completed'), +(2, 2, '2026-01-25', 'Pending'), +(5, 4, '2026-02-01', 'Completed'), +(6, 5, '2026-02-02', 'Pending'); + +INSERT INTO supplier (supCompany, supContactFirstName, supContactLastName, supEmail, supPhone) +VALUES +('PetFood Inc', 'Robert', 'King', 'contact@petfood.com', '888-111-2222'), +('Toy World', 'Jennifer', 'Lee', 'sales@toyworld.com', '888-222-3333'), +('Pet Supplies Co', 'Kevin', 'White', 'info@petsupplies.com', '888-333-4444'), +('Animal Care Products', 'Nancy', 'Green', 'orders@animalcare.com', '888-444-5555'), +('Premium Pet Goods', 'Tom', 'Black', 'support@premiumpet.com', '888-555-6666'); + +INSERT INTO category (categoryName, categoryType) +VALUES +('Dog Food', 'Product'), +('Cat Toys', 'Product'), +('Bird Supplies', 'Product'), +('Aquarium', 'Product'), +('Small Animals', 'Product'); + +INSERT INTO product (prodName, prodPrice, categoryId, prodDesc) +VALUES +('Premium Dog Food', 50.00, 1, 'High quality dog food'), +('Cat Toy Ball', 10.00, 2, 'Colorful toy for cats'), +('Bird Cage Large', 120.00, 3, 'Spacious bird cage'), +('Fish Tank 20 Gallon', 80.00, 4, 'Complete aquarium kit'), +('Hamster Wheel', 15.00, 5, 'Exercise wheel for small pets'), +('Organic Dog Treats', 25.00, 1, 'Natural dog treats'); + +INSERT INTO productSupplier (supId, prodId, cost) +VALUES +(1, 1, 35.00), +(1, 2, 6.50), +(2, 2, 7.00), +(3, 3, 90.00), +(3, 4, 60.00), +(4, 5, 10.00), +(5, 6, 18.00), +(1, 6, 17.50); + +INSERT INTO inventory (prodId, quantity) +VALUES +(1, 100), +(2, 200), +(3, 50), +(4, 30), +(5, 150), +(6, 75); + +INSERT INTO service (serviceName, serviceDesc, serviceDuration, servicePrice) +VALUES +('Pet Grooming', 'Full grooming service', 60, 40.00), +('Nail Trimming', 'Quick nail trim', 15, 10.00), +('Bath and Brush', 'Bathing and brushing service', 45, 30.00), +('Veterinary Checkup', 'Complete health examination', 30, 75.00), +('Teeth Cleaning', 'Professional dental cleaning', 90, 100.00); + +INSERT INTO appointment (serviceId, customerId, appointmentDate, appointmentTime, appointmentStatus) +VALUES +(1, 2, '2026-02-01', '10:30:00', 'Booked'), +(2, 1, '2026-02-03', '14:00:00', 'Booked'), +(3, 3, '2026-02-05', '09:00:00', 'Completed'), +(4, 4, '2026-02-07', '11:30:00', 'Booked'), +(5, 5, '2026-02-10', '15:00:00', 'Cancelled'); + +INSERT INTO appointmentPet (appointmentId, petId) +VALUES +(1, 2), +(2, 1), +(3, 3), +(4, 5), +(5, 6); + +INSERT INTO sale (saleDate, totalAmount, paymentMethod, employeeId, storeId) +VALUES +-- January Sales +('2026-01-05 09:15:00', 125.00, 'Card', 1, 1), -- Sale 1: Dog food + treats +('2026-01-08 11:30:00', 200.00, 'Card', 2, 1), -- Sale 2: Bird cage + fish tank +('2026-01-12 14:20:00', 60.00, 'Cash', 3, 2), -- Sale 3: Cat toys + hamster wheel +('2026-01-15 10:45:00', 150.00, 'Debit', 1, 1), -- Sale 4: Dog food (bulk purchase) +('2026-01-18 16:30:00', 80.00, 'Card', 4, 3), -- Sale 5: Fish tank +('2026-01-22 13:15:00', 95.00, 'Cash', 2, 2), -- Sale 6: Mixed items +('2026-01-25 15:40:00', 240.00, 'Card', 5, 4), -- Sale 7: Two bird cages +('2026-01-28 10:30:00', 80.00, 'Cash', 1, 1), -- Sale 8: Dog food + cat toys +-- February Sales +('2026-02-01 09:00:00', 175.00, 'Card', 3, 3), -- Sale 9: Dog food + treats (bulk) +('2026-02-03 11:20:00', 120.00, 'Card', 2, 1), -- Sale 10: Bird cage +('2026-02-05 14:50:00', 45.00, 'Cash', 4, 2), -- Sale 11: Hamster wheel + cat toys +('2026-02-08 16:15:00', 160.00, 'Debit', 1, 1), -- Sale 12: Fish tank + accessories +('2026-02-10 10:25:00', 100.00, 'Card', 5, 4), -- Sale 13: Dog treats (bulk) +('2026-02-12 13:45:00', 50.00, 'Cash', 2, 2), -- Sale 14: Dog food +('2026-02-15 15:30:00', 85.00, 'Card', 3, 3), -- Sale 15: Mixed pet supplies +('2026-02-18 11:10:00', 200.00, 'Card', 1, 1), -- Sale 16: Bird cage + hamster wheel +('2026-02-20 14:35:00', 155.00, 'Debit', 4, 3), -- Sale 17: Fish tank + cat toys +('2026-02-22 16:50:00', 75.00, 'Cash', 2, 1), -- Sale 18: Dog treats + toys +('2026-02-24 10:15:00', 140.00, 'Card', 5, 4), -- Sale 19: Dog food + treats +(NOW(), 95.00, 'Card', 1, 1); -- Sale 20: Recent sale (current timestamp) + +INSERT INTO saleItem (saleId, prodId, quantity, unitPrice) +VALUES +-- Sale 1 items (Dog food + treats) +(1, 1, 2, 50.00), -- 2x Premium Dog Food +(1, 6, 1, 25.00), -- 1x Organic Dog Treats +-- Sale 2 items (Bird cage + fish tank) +(2, 3, 1, 120.00), -- 1x Bird Cage Large +(2, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +-- Sale 3 items (Cat toys + hamster wheel) +(3, 2, 3, 10.00), -- 3x Cat Toy Ball +(3, 5, 2, 15.00), -- 2x Hamster Wheel +-- Sale 4 items (Dog food bulk) +(4, 1, 3, 50.00), -- 3x Premium Dog Food +-- Sale 5 items (Fish tank) +(5, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +-- Sale 6 items (Mixed) +(6, 2, 4, 10.00), -- 4x Cat Toy Ball +(6, 5, 1, 15.00), -- 1x Hamster Wheel +(6, 6, 1, 25.00), -- 1x Organic Dog Treats +(6, 1, 1, 50.00), -- 1x Premium Dog Food (partial - discount applied) +-- Sale 7 items (Two bird cages) +(7, 3, 2, 120.00), -- 2x Bird Cage Large +-- Sale 8 items (Dog food + cat toys) +(8, 1, 1, 50.00), -- 1x Premium Dog Food +(8, 2, 3, 10.00), -- 3x Cat Toy Ball +-- Sale 9 items (Dog food + treats bulk) +(9, 1, 3, 50.00), -- 3x Premium Dog Food +(9, 6, 1, 25.00), -- 1x Organic Dog Treats +-- Sale 10 items (Bird cage) +(10, 3, 1, 120.00), -- 1x Bird Cage Large +-- Sale 11 items (Hamster wheel + cat toys) +(11, 5, 1, 15.00), -- 1x Hamster Wheel +(11, 2, 3, 10.00), -- 3x Cat Toy Ball +-- Sale 12 items (Fish tank + accessories) +(12, 4, 2, 80.00), -- 2x Fish Tank 20 Gallon +-- Sale 13 items (Dog treats bulk) +(13, 6, 4, 25.00), -- 4x Organic Dog Treats +-- Sale 14 items (Dog food) +(14, 1, 1, 50.00), -- 1x Premium Dog Food +-- Sale 15 items (Mixed supplies) +(15, 2, 2, 10.00), -- 2x Cat Toy Ball +(15, 5, 1, 15.00), -- 1x Hamster Wheel +(15, 6, 2, 25.00), -- 2x Organic Dog Treats +-- Sale 16 items (Bird cage + hamster wheel) +(16, 3, 1, 120.00), -- 1x Bird Cage Large +(16, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +-- Sale 17 items (Fish tank + cat toys) +(17, 4, 1, 80.00), -- 1x Fish Tank 20 Gallon +(17, 1, 1, 50.00), -- 1x Premium Dog Food +(17, 6, 1, 25.00), -- 1x Organic Dog Treats +-- Sale 18 items (Dog treats + toys) +(18, 6, 2, 25.00), -- 2x Organic Dog Treats +(18, 2, 2, 10.00), -- 2x Cat Toy Ball +(18, 5, 1, 15.00), -- 1x Hamster Wheel +-- Sale 19 items (Dog food + treats) +(19, 1, 2, 50.00), -- 2x Premium Dog Food +(19, 6, 2, 25.00), -- 2x Organic Dog Treats (discount applied) +-- Sale 20 items (Recent sale) +(20, 2, 5, 10.00), -- 5x Cat Toy Ball +(20, 5, 3, 15.00); -- 3x Hamster Wheel + +INSERT INTO purchaseOrder (supId, orderDate, status) +VALUES +(1, '2025-01-15', 'Delivered'), +(2, '2025-01-20', 'Pending'), +(3, '2025-02-01', 'Delivered'), +(4, '2025-02-10', 'In Transit'), +(1, '2025-02-15', 'Pending'); + +INSERT INTO activityLog (employeeId, activity) +VALUES +(1, 'Created new sale'), +(2, 'Booked appointment'), +(3, 'Completed grooming service'), +(4, 'Processed inventory order'), +(5, 'Conducted health checkup'), +(1, 'Updated customer information'); + +-- Sample users created by DataInitializer (admin/admin123, staff/staff123) diff --git a/src/main/java/com/petshop/backend/config/DataInitializer.java b/src/main/java/com/petshop/backend/config/DataInitializer.java index cf311496..a3db73ab 100644 --- a/src/main/java/com/petshop/backend/config/DataInitializer.java +++ b/src/main/java/com/petshop/backend/config/DataInitializer.java @@ -23,10 +23,7 @@ public class DataInitializer implements CommandLineRunner { User admin = new User(); admin.setUsername("admin"); admin.setPassword(passwordEncoder.encode("admin123")); - admin.setFullName("Admin User"); - admin.setEmail("admin@petshop.com"); admin.setRole(User.Role.ADMIN); - admin.setActive(true); userRepository.save(admin); } @@ -34,10 +31,7 @@ public class DataInitializer implements CommandLineRunner { User staff = new User(); staff.setUsername("staff"); staff.setPassword(passwordEncoder.encode("staff123")); - staff.setFullName("Staff User"); - staff.setEmail("staff@petshop.com"); staff.setRole(User.Role.STAFF); - staff.setActive(true); userRepository.save(staff); } } diff --git a/src/main/java/com/petshop/backend/controller/AuthController.java b/src/main/java/com/petshop/backend/controller/AuthController.java index 491c4833..d0a6cc39 100644 --- a/src/main/java/com/petshop/backend/controller/AuthController.java +++ b/src/main/java/com/petshop/backend/controller/AuthController.java @@ -2,7 +2,6 @@ package com.petshop.backend.controller; import com.petshop.backend.dto.auth.LoginRequest; import com.petshop.backend.dto.auth.LoginResponse; -import com.petshop.backend.dto.auth.RegisterRequest; import com.petshop.backend.dto.auth.UserInfoResponse; import com.petshop.backend.entity.User; import com.petshop.backend.repository.UserRepository; @@ -39,40 +38,6 @@ public class AuthController { this.passwordEncoder = passwordEncoder; } - @PostMapping("/register") - public ResponseEntity register(@Valid @RequestBody RegisterRequest request) { - if (userRepository.findByUsername(request.getEmail()).isPresent()) { - Map error = new HashMap<>(); - error.put("message", "Email already registered"); - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(error); - } - - User user = new User(); - user.setUsername(request.getEmail()); - user.setEmail(request.getEmail()); - user.setPassword(passwordEncoder.encode(request.getPassword())); - user.setFullName(request.getFirstName() + " " + request.getLastName()); - user.setRole(User.Role.CUSTOMER); - user.setActive(true); - - user = userRepository.save(user); - - UserDetails userDetails = new org.springframework.security.core.userdetails.User( - user.getUsername(), - user.getPassword(), - java.util.Collections.emptyList() - ); - - String token = jwtUtil.generateToken(userDetails); - - return ResponseEntity.status(HttpStatus.CREATED).body(new LoginResponse( - token, - user.getUsername(), - user.getFullName(), - user.getRole().name() - )); - } - @PostMapping("/login") public ResponseEntity login(@Valid @RequestBody LoginRequest request) { try { @@ -94,7 +59,6 @@ public class AuthController { return ResponseEntity.ok(new LoginResponse( token, user.getUsername(), - user.getFullName(), user.getRole().name() )); @@ -116,8 +80,6 @@ public class AuthController { return ResponseEntity.ok(new UserInfoResponse( user.getId(), user.getUsername(), - user.getFullName(), - user.getEmail(), user.getRole().name() )); } diff --git a/src/main/java/com/petshop/backend/controller/DropdownController.java b/src/main/java/com/petshop/backend/controller/DropdownController.java index b0b60930..bf1d1c48 100644 --- a/src/main/java/com/petshop/backend/controller/DropdownController.java +++ b/src/main/java/com/petshop/backend/controller/DropdownController.java @@ -40,7 +40,7 @@ public class DropdownController { public ResponseEntity> getPets() { return ResponseEntity.ok( petRepository.findAll().stream() - .map(p -> new DropdownOption(p.getId(), p.getPetName())) + .map(p -> new DropdownOption(p.getPetId(), p.getPetName())) .collect(Collectors.toList()) ); } @@ -49,7 +49,7 @@ public class DropdownController { public ResponseEntity> getCustomers() { return ResponseEntity.ok( customerRepository.findAll().stream() - .map(c -> new DropdownOption(c.getId(), c.getCustomerName())) + .map(c -> new DropdownOption(c.getCustomerId(), c.getFirstName() + " " + c.getLastName())) .collect(Collectors.toList()) ); } @@ -58,7 +58,7 @@ public class DropdownController { public ResponseEntity> getServices() { return ResponseEntity.ok( serviceRepository.findAll().stream() - .map(s -> new DropdownOption(s.getId(), s.getServiceName())) + .map(s -> new DropdownOption(s.getServiceId(), s.getServiceName())) .collect(Collectors.toList()) ); } @@ -67,7 +67,7 @@ public class DropdownController { public ResponseEntity> getProducts() { return ResponseEntity.ok( productRepository.findAll().stream() - .map(p -> new DropdownOption(p.getId(), p.getProductName())) + .map(p -> new DropdownOption(p.getProdId(), p.getProdName())) .collect(Collectors.toList()) ); } @@ -76,7 +76,7 @@ public class DropdownController { public ResponseEntity> getCategories() { return ResponseEntity.ok( categoryRepository.findAll().stream() - .map(c -> new DropdownOption(c.getId(), c.getCategoryName())) + .map(c -> new DropdownOption(c.getCategoryId(), c.getCategoryName())) .collect(Collectors.toList()) ); } @@ -85,7 +85,7 @@ public class DropdownController { public ResponseEntity> getStores() { return ResponseEntity.ok( storeRepository.findAll().stream() - .map(s -> new DropdownOption(s.getId(), s.getStoreName())) + .map(s -> new DropdownOption(s.getStoreId(), s.getStoreName())) .collect(Collectors.toList()) ); } @@ -95,7 +95,7 @@ public class DropdownController { public ResponseEntity> getSuppliers() { return ResponseEntity.ok( supplierRepository.findAll().stream() - .map(s -> new DropdownOption(s.getId(), s.getSupplierName())) + .map(s -> new DropdownOption(s.getSupId(), s.getSupCompany())) .collect(Collectors.toList()) ); } diff --git a/src/main/java/com/petshop/backend/controller/RefundController.java b/src/main/java/com/petshop/backend/controller/RefundController.java deleted file mode 100644 index 1086b9af..00000000 --- a/src/main/java/com/petshop/backend/controller/RefundController.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.petshop.backend.controller; - -import com.petshop.backend.dto.refund.RefundRequest; -import com.petshop.backend.dto.refund.RefundResponse; -import com.petshop.backend.service.RefundService; -import jakarta.validation.Valid; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/api/v1/sales") -public class RefundController { - - private final RefundService refundService; - - public RefundController(RefundService refundService) { - this.refundService = refundService; - } - - @PostMapping("/{saleId}/refunds") - public ResponseEntity createRefund( - @PathVariable Long saleId, - @Valid @RequestBody RefundRequest request) { - return ResponseEntity.status(HttpStatus.CREATED).body(refundService.createRefund(saleId, request)); - } -} diff --git a/src/main/java/com/petshop/backend/dto/adoption/AdoptionRequest.java b/src/main/java/com/petshop/backend/dto/adoption/AdoptionRequest.java index 417ef3a9..1807f5b4 100644 --- a/src/main/java/com/petshop/backend/dto/adoption/AdoptionRequest.java +++ b/src/main/java/com/petshop/backend/dto/adoption/AdoptionRequest.java @@ -1,8 +1,7 @@ package com.petshop.backend.dto.adoption; +import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Positive; -import java.math.BigDecimal; import java.time.LocalDate; import java.util.Objects; @@ -16,11 +15,8 @@ public class AdoptionRequest { @NotNull(message = "Adoption date is required") private LocalDate adoptionDate; - @NotNull(message = "Adoption fee is required") - @Positive(message = "Adoption fee must be positive") - private BigDecimal adoptionFee; - - private String notes; + @NotBlank(message = "Adoption status is required") + private String adoptionStatus; public Long getPetId() { return petId; @@ -46,20 +42,12 @@ public class AdoptionRequest { this.adoptionDate = adoptionDate; } - public BigDecimal getAdoptionFee() { - return adoptionFee; + public String getAdoptionStatus() { + return adoptionStatus; } - public void setAdoptionFee(BigDecimal adoptionFee) { - this.adoptionFee = adoptionFee; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; + public void setAdoptionStatus(String adoptionStatus) { + this.adoptionStatus = adoptionStatus; } @Override @@ -70,13 +58,12 @@ public class AdoptionRequest { return Objects.equals(petId, that.petId) && Objects.equals(customerId, that.customerId) && Objects.equals(adoptionDate, that.adoptionDate) && - Objects.equals(adoptionFee, that.adoptionFee) && - Objects.equals(notes, that.notes); + Objects.equals(adoptionStatus, that.adoptionStatus); } @Override public int hashCode() { - return Objects.hash(petId, customerId, adoptionDate, adoptionFee, notes); + return Objects.hash(petId, customerId, adoptionDate, adoptionStatus); } @Override @@ -85,8 +72,7 @@ public class AdoptionRequest { "petId=" + petId + ", customerId=" + customerId + ", adoptionDate=" + adoptionDate + - ", adoptionFee=" + adoptionFee + - ", notes='" + notes + '\'' + + ", adoptionStatus='" + adoptionStatus + '\'' + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/adoption/AdoptionResponse.java b/src/main/java/com/petshop/backend/dto/adoption/AdoptionResponse.java index e0c3faec..d26e88a1 100644 --- a/src/main/java/com/petshop/backend/dto/adoption/AdoptionResponse.java +++ b/src/main/java/com/petshop/backend/dto/adoption/AdoptionResponse.java @@ -1,44 +1,41 @@ package com.petshop.backend.dto.adoption; -import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Objects; public class AdoptionResponse { - private Long id; + private Long adoptionId; private Long petId; private String petName; private Long customerId; private String customerName; private LocalDate adoptionDate; - private BigDecimal adoptionFee; - private String notes; + private String adoptionStatus; private LocalDateTime createdAt; private LocalDateTime updatedAt; public AdoptionResponse() { } - public AdoptionResponse(Long id, Long petId, String petName, Long customerId, String customerName, LocalDate adoptionDate, BigDecimal adoptionFee, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public AdoptionResponse(Long adoptionId, Long petId, String petName, Long customerId, String customerName, LocalDate adoptionDate, String adoptionStatus, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.adoptionId = adoptionId; this.petId = petId; this.petName = petName; this.customerId = customerId; this.customerName = customerName; this.adoptionDate = adoptionDate; - this.adoptionFee = adoptionFee; - this.notes = notes; + this.adoptionStatus = adoptionStatus; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getAdoptionId() { + return adoptionId; } - public void setId(Long id) { - this.id = id; + public void setAdoptionId(Long adoptionId) { + this.adoptionId = adoptionId; } public Long getPetId() { @@ -81,20 +78,12 @@ public class AdoptionResponse { this.adoptionDate = adoptionDate; } - public BigDecimal getAdoptionFee() { - return adoptionFee; + public String getAdoptionStatus() { + return adoptionStatus; } - public void setAdoptionFee(BigDecimal adoptionFee) { - this.adoptionFee = adoptionFee; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; + public void setAdoptionStatus(String adoptionStatus) { + this.adoptionStatus = adoptionStatus; } public LocalDateTime getCreatedAt() { @@ -118,25 +107,24 @@ public class AdoptionResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AdoptionResponse that = (AdoptionResponse) o; - return Objects.equals(id, that.id) && Objects.equals(petId, that.petId) && Objects.equals(petName, that.petName) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(adoptionDate, that.adoptionDate) && Objects.equals(adoptionFee, that.adoptionFee) && Objects.equals(notes, that.notes) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(adoptionId, that.adoptionId) && Objects.equals(petId, that.petId) && Objects.equals(petName, that.petName) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(adoptionDate, that.adoptionDate) && Objects.equals(adoptionStatus, that.adoptionStatus) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, petId, petName, customerId, customerName, adoptionDate, adoptionFee, notes, createdAt, updatedAt); + return Objects.hash(adoptionId, petId, petName, customerId, customerName, adoptionDate, adoptionStatus, createdAt, updatedAt); } @Override public String toString() { return "AdoptionResponse{" + - "id=" + id + + "adoptionId=" + adoptionId + ", petId=" + petId + ", petName='" + petName + '\'' + ", customerId=" + customerId + ", customerName='" + customerName + '\'' + ", adoptionDate=" + adoptionDate + - ", adoptionFee=" + adoptionFee + - ", notes='" + notes + '\'' + + ", adoptionStatus='" + adoptionStatus + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/appointment/AppointmentRequest.java b/src/main/java/com/petshop/backend/dto/appointment/AppointmentRequest.java index 107e6856..bd2b2356 100644 --- a/src/main/java/com/petshop/backend/dto/appointment/AppointmentRequest.java +++ b/src/main/java/com/petshop/backend/dto/appointment/AppointmentRequest.java @@ -1,6 +1,5 @@ package com.petshop.backend.dto.appointment; -import com.petshop.backend.entity.Appointment; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; import java.time.LocalDate; @@ -21,14 +20,12 @@ public class AppointmentRequest { @NotNull(message = "Appointment time is required") private LocalTime appointmentTime; - @NotNull(message = "Status is required") - private Appointment.AppointmentStatus status; + @NotNull(message = "Appointment status is required") + private String appointmentStatus; @NotEmpty(message = "At least one pet must be specified") private List petIds; - private String notes; - public Long getCustomerId() { return customerId; } @@ -61,12 +58,12 @@ public class AppointmentRequest { this.appointmentTime = appointmentTime; } - public Appointment.AppointmentStatus getStatus() { - return status; + public String getAppointmentStatus() { + return appointmentStatus; } - public void setStatus(Appointment.AppointmentStatus status) { - this.status = status; + public void setAppointmentStatus(String appointmentStatus) { + this.appointmentStatus = appointmentStatus; } public List getPetIds() { @@ -77,14 +74,6 @@ public class AppointmentRequest { this.petIds = petIds; } - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -94,14 +83,13 @@ public class AppointmentRequest { Objects.equals(serviceId, that.serviceId) && Objects.equals(appointmentDate, that.appointmentDate) && Objects.equals(appointmentTime, that.appointmentTime) && - status == that.status && - Objects.equals(petIds, that.petIds) && - Objects.equals(notes, that.notes); + Objects.equals(appointmentStatus, that.appointmentStatus) && + Objects.equals(petIds, that.petIds); } @Override public int hashCode() { - return Objects.hash(customerId, serviceId, appointmentDate, appointmentTime, status, petIds, notes); + return Objects.hash(customerId, serviceId, appointmentDate, appointmentTime, appointmentStatus, petIds); } @Override @@ -111,9 +99,8 @@ public class AppointmentRequest { ", serviceId=" + serviceId + ", appointmentDate=" + appointmentDate + ", appointmentTime=" + appointmentTime + - ", status=" + status + + ", appointmentStatus='" + appointmentStatus + '\'' + ", petIds=" + petIds + - ", notes='" + notes + '\'' + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/appointment/AppointmentResponse.java b/src/main/java/com/petshop/backend/dto/appointment/AppointmentResponse.java index b84b4dad..a4077a87 100644 --- a/src/main/java/com/petshop/backend/dto/appointment/AppointmentResponse.java +++ b/src/main/java/com/petshop/backend/dto/appointment/AppointmentResponse.java @@ -7,45 +7,43 @@ import java.util.List; import java.util.Objects; public class AppointmentResponse { - private Long id; + private Long appointmentId; private Long customerId; private String customerName; private Long serviceId; private String serviceName; private LocalDate appointmentDate; private LocalTime appointmentTime; - private String status; + private String appointmentStatus; private List petNames; private List petIds; - private String notes; private LocalDateTime createdAt; private LocalDateTime updatedAt; public AppointmentResponse() { } - public AppointmentResponse(Long id, Long customerId, String customerName, Long serviceId, String serviceName, LocalDate appointmentDate, LocalTime appointmentTime, String status, List petNames, List petIds, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public AppointmentResponse(Long appointmentId, Long customerId, String customerName, Long serviceId, String serviceName, LocalDate appointmentDate, LocalTime appointmentTime, String appointmentStatus, List petNames, List petIds, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.appointmentId = appointmentId; this.customerId = customerId; this.customerName = customerName; this.serviceId = serviceId; this.serviceName = serviceName; this.appointmentDate = appointmentDate; this.appointmentTime = appointmentTime; - this.status = status; + this.appointmentStatus = appointmentStatus; this.petNames = petNames; this.petIds = petIds; - this.notes = notes; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getAppointmentId() { + return appointmentId; } - public void setId(Long id) { - this.id = id; + public void setAppointmentId(Long appointmentId) { + this.appointmentId = appointmentId; } public Long getCustomerId() { @@ -96,12 +94,12 @@ public class AppointmentResponse { this.appointmentTime = appointmentTime; } - public String getStatus() { - return status; + public String getAppointmentStatus() { + return appointmentStatus; } - public void setStatus(String status) { - this.status = status; + public void setAppointmentStatus(String appointmentStatus) { + this.appointmentStatus = appointmentStatus; } public List getPetNames() { @@ -120,14 +118,6 @@ public class AppointmentResponse { this.petIds = petIds; } - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - public LocalDateTime getCreatedAt() { return createdAt; } @@ -149,28 +139,27 @@ public class AppointmentResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AppointmentResponse that = (AppointmentResponse) o; - return Objects.equals(id, that.id) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(serviceId, that.serviceId) && Objects.equals(serviceName, that.serviceName) && Objects.equals(appointmentDate, that.appointmentDate) && Objects.equals(appointmentTime, that.appointmentTime) && Objects.equals(status, that.status) && Objects.equals(petNames, that.petNames) && Objects.equals(petIds, that.petIds) && Objects.equals(notes, that.notes) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(appointmentId, that.appointmentId) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(serviceId, that.serviceId) && Objects.equals(serviceName, that.serviceName) && Objects.equals(appointmentDate, that.appointmentDate) && Objects.equals(appointmentTime, that.appointmentTime) && Objects.equals(appointmentStatus, that.appointmentStatus) && Objects.equals(petNames, that.petNames) && Objects.equals(petIds, that.petIds) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, customerId, customerName, serviceId, serviceName, appointmentDate, appointmentTime, status, petNames, petIds, notes, createdAt, updatedAt); + return Objects.hash(appointmentId, customerId, customerName, serviceId, serviceName, appointmentDate, appointmentTime, appointmentStatus, petNames, petIds, createdAt, updatedAt); } @Override public String toString() { return "AppointmentResponse{" + - "id=" + id + + "appointmentId=" + appointmentId + ", customerId=" + customerId + ", customerName='" + customerName + '\'' + ", serviceId=" + serviceId + ", serviceName='" + serviceName + '\'' + ", appointmentDate=" + appointmentDate + ", appointmentTime=" + appointmentTime + - ", status='" + status + '\'' + + ", appointmentStatus='" + appointmentStatus + '\'' + ", petNames=" + petNames + ", petIds=" + petIds + - ", notes='" + notes + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/auth/LoginResponse.java b/src/main/java/com/petshop/backend/dto/auth/LoginResponse.java index 11141df6..e3d01c11 100644 --- a/src/main/java/com/petshop/backend/dto/auth/LoginResponse.java +++ b/src/main/java/com/petshop/backend/dto/auth/LoginResponse.java @@ -5,16 +5,14 @@ import java.util.Objects; public class LoginResponse { private String token; private String username; - private String fullName; private String role; public LoginResponse() { } - public LoginResponse(String token, String username, String fullName, String role) { + public LoginResponse(String token, String username, String role) { this.token = token; this.username = username; - this.fullName = fullName; this.role = role; } @@ -34,14 +32,6 @@ public class LoginResponse { this.username = username; } - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - public String getRole() { return role; } @@ -55,12 +45,12 @@ public class LoginResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LoginResponse that = (LoginResponse) o; - return Objects.equals(token, that.token) && Objects.equals(username, that.username) && Objects.equals(fullName, that.fullName) && Objects.equals(role, that.role); + return Objects.equals(token, that.token) && Objects.equals(username, that.username) && Objects.equals(role, that.role); } @Override public int hashCode() { - return Objects.hash(token, username, fullName, role); + return Objects.hash(token, username, role); } @Override @@ -68,7 +58,6 @@ public class LoginResponse { return "LoginResponse{" + "token='" + token + '\'' + ", username='" + username + '\'' + - ", fullName='" + fullName + '\'' + ", role='" + role + '\'' + '}'; } diff --git a/src/main/java/com/petshop/backend/dto/auth/RegisterRequest.java b/src/main/java/com/petshop/backend/dto/auth/RegisterRequest.java deleted file mode 100644 index ae3f5a56..00000000 --- a/src/main/java/com/petshop/backend/dto/auth/RegisterRequest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.petshop.backend.dto.auth; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.NotBlank; -import java.util.Objects; - -public class RegisterRequest { - @NotBlank(message = "First name is required") - private String firstName; - - @NotBlank(message = "Last name is required") - private String lastName; - - @NotBlank(message = "Email is required") - @Email(message = "Email must be valid") - private String email; - - @NotBlank(message = "Phone is required") - private String phone; - - @NotBlank(message = "Password is required") - private String password; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RegisterRequest that = (RegisterRequest) o; - return Objects.equals(firstName, that.firstName) && - Objects.equals(lastName, that.lastName) && - Objects.equals(email, that.email) && - Objects.equals(phone, that.phone) && - Objects.equals(password, that.password); - } - - @Override - public int hashCode() { - return Objects.hash(firstName, lastName, email, phone, password); - } - - @Override - public String toString() { - return "RegisterRequest{" + - "firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - ", email='" + email + '\'' + - ", phone='" + phone + '\'' + - ", password='[PROTECTED]'" + - '}'; - } -} diff --git a/src/main/java/com/petshop/backend/dto/auth/UserInfoResponse.java b/src/main/java/com/petshop/backend/dto/auth/UserInfoResponse.java index a3142040..006727c9 100644 --- a/src/main/java/com/petshop/backend/dto/auth/UserInfoResponse.java +++ b/src/main/java/com/petshop/backend/dto/auth/UserInfoResponse.java @@ -5,18 +5,14 @@ import java.util.Objects; public class UserInfoResponse { private Long id; private String username; - private String fullName; - private String email; private String role; public UserInfoResponse() { } - public UserInfoResponse(Long id, String username, String fullName, String email, String role) { + public UserInfoResponse(Long id, String username, String role) { this.id = id; this.username = username; - this.fullName = fullName; - this.email = email; this.role = role; } @@ -36,22 +32,6 @@ public class UserInfoResponse { this.username = username; } - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - public String getRole() { return role; } @@ -65,12 +45,12 @@ public class UserInfoResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; UserInfoResponse that = (UserInfoResponse) o; - return Objects.equals(id, that.id) && Objects.equals(username, that.username) && Objects.equals(fullName, that.fullName) && Objects.equals(email, that.email) && Objects.equals(role, that.role); + return Objects.equals(id, that.id) && Objects.equals(username, that.username) && Objects.equals(role, that.role); } @Override public int hashCode() { - return Objects.hash(id, username, fullName, email, role); + return Objects.hash(id, username, role); } @Override @@ -78,8 +58,6 @@ public class UserInfoResponse { return "UserInfoResponse{" + "id=" + id + ", username='" + username + '\'' + - ", fullName='" + fullName + '\'' + - ", email='" + email + '\'' + ", role='" + role + '\'' + '}'; } diff --git a/src/main/java/com/petshop/backend/dto/category/CategoryRequest.java b/src/main/java/com/petshop/backend/dto/category/CategoryRequest.java index e73cca59..c012ae21 100644 --- a/src/main/java/com/petshop/backend/dto/category/CategoryRequest.java +++ b/src/main/java/com/petshop/backend/dto/category/CategoryRequest.java @@ -7,7 +7,7 @@ public class CategoryRequest { @NotBlank(message = "Category name is required") private String categoryName; - private String categoryDescription; + private String categoryType; public String getCategoryName() { return categoryName; @@ -17,12 +17,12 @@ public class CategoryRequest { this.categoryName = categoryName; } - public String getCategoryDescription() { - return categoryDescription; + public String getCategoryType() { + return categoryType; } - public void setCategoryDescription(String categoryDescription) { - this.categoryDescription = categoryDescription; + public void setCategoryType(String categoryType) { + this.categoryType = categoryType; } @Override @@ -31,19 +31,19 @@ public class CategoryRequest { if (o == null || getClass() != o.getClass()) return false; CategoryRequest that = (CategoryRequest) o; return Objects.equals(categoryName, that.categoryName) && - Objects.equals(categoryDescription, that.categoryDescription); + Objects.equals(categoryType, that.categoryType); } @Override public int hashCode() { - return Objects.hash(categoryName, categoryDescription); + return Objects.hash(categoryName, categoryType); } @Override public String toString() { return "CategoryRequest{" + "categoryName='" + categoryName + '\'' + - ", categoryDescription='" + categoryDescription + '\'' + + ", categoryType='" + categoryType + '\'' + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/category/CategoryResponse.java b/src/main/java/com/petshop/backend/dto/category/CategoryResponse.java index fe008c16..6d9e1569 100644 --- a/src/main/java/com/petshop/backend/dto/category/CategoryResponse.java +++ b/src/main/java/com/petshop/backend/dto/category/CategoryResponse.java @@ -4,29 +4,29 @@ import java.time.LocalDateTime; import java.util.Objects; public class CategoryResponse { - private Long id; + private Long categoryId; private String categoryName; - private String categoryDescription; + private String categoryType; private LocalDateTime createdAt; private LocalDateTime updatedAt; public CategoryResponse() { } - public CategoryResponse(Long id, String categoryName, String categoryDescription, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public CategoryResponse(Long categoryId, String categoryName, String categoryType, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.categoryId = categoryId; this.categoryName = categoryName; - this.categoryDescription = categoryDescription; + this.categoryType = categoryType; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getCategoryId() { + return categoryId; } - public void setId(Long id) { - this.id = id; + public void setCategoryId(Long categoryId) { + this.categoryId = categoryId; } public String getCategoryName() { @@ -37,12 +37,12 @@ public class CategoryResponse { this.categoryName = categoryName; } - public String getCategoryDescription() { - return categoryDescription; + public String getCategoryType() { + return categoryType; } - public void setCategoryDescription(String categoryDescription) { - this.categoryDescription = categoryDescription; + public void setCategoryType(String categoryType) { + this.categoryType = categoryType; } public LocalDateTime getCreatedAt() { @@ -66,20 +66,20 @@ public class CategoryResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CategoryResponse that = (CategoryResponse) o; - return Objects.equals(id, that.id) && Objects.equals(categoryName, that.categoryName) && Objects.equals(categoryDescription, that.categoryDescription) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(categoryId, that.categoryId) && Objects.equals(categoryName, that.categoryName) && Objects.equals(categoryType, that.categoryType) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, categoryName, categoryDescription, createdAt, updatedAt); + return Objects.hash(categoryId, categoryName, categoryType, createdAt, updatedAt); } @Override public String toString() { return "CategoryResponse{" + - "id=" + id + + "categoryId=" + categoryId + ", categoryName='" + categoryName + '\'' + - ", categoryDescription='" + categoryDescription + '\'' + + ", categoryType='" + categoryType + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/customer/CustomerRequest.java b/src/main/java/com/petshop/backend/dto/customer/CustomerRequest.java index 464c80b7..d982be81 100644 --- a/src/main/java/com/petshop/backend/dto/customer/CustomerRequest.java +++ b/src/main/java/com/petshop/backend/dto/customer/CustomerRequest.java @@ -5,45 +5,47 @@ import jakarta.validation.constraints.NotBlank; import java.util.Objects; public class CustomerRequest { - @NotBlank(message = "Customer name is required") - private String customerName; + @NotBlank(message = "First name is required") + private String firstName; + + @NotBlank(message = "Last name is required") + private String lastName; @Email(message = "Invalid email format") - private String customerEmail; + private String email; - private String customerPhone; - private String customerAddress; + private String phone; - public String getCustomerName() { - return customerName; + public String getFirstName() { + return firstName; } - public void setCustomerName(String customerName) { - this.customerName = customerName; + public void setFirstName(String firstName) { + this.firstName = firstName; } - public String getCustomerEmail() { - return customerEmail; + public String getLastName() { + return lastName; } - public void setCustomerEmail(String customerEmail) { - this.customerEmail = customerEmail; + public void setLastName(String lastName) { + this.lastName = lastName; } - public String getCustomerPhone() { - return customerPhone; + public String getEmail() { + return email; } - public void setCustomerPhone(String customerPhone) { - this.customerPhone = customerPhone; + public void setEmail(String email) { + this.email = email; } - public String getCustomerAddress() { - return customerAddress; + public String getPhone() { + return phone; } - public void setCustomerAddress(String customerAddress) { - this.customerAddress = customerAddress; + public void setPhone(String phone) { + this.phone = phone; } @Override @@ -51,24 +53,24 @@ public class CustomerRequest { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CustomerRequest that = (CustomerRequest) o; - return Objects.equals(customerName, that.customerName) && - Objects.equals(customerEmail, that.customerEmail) && - Objects.equals(customerPhone, that.customerPhone) && - Objects.equals(customerAddress, that.customerAddress); + return Objects.equals(firstName, that.firstName) && + Objects.equals(lastName, that.lastName) && + Objects.equals(email, that.email) && + Objects.equals(phone, that.phone); } @Override public int hashCode() { - return Objects.hash(customerName, customerEmail, customerPhone, customerAddress); + return Objects.hash(firstName, lastName, email, phone); } @Override public String toString() { return "CustomerRequest{" + - "customerName='" + customerName + '\'' + - ", customerEmail='" + customerEmail + '\'' + - ", customerPhone='" + customerPhone + '\'' + - ", customerAddress='" + customerAddress + '\'' + + "firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", email='" + email + '\'' + + ", phone='" + phone + '\'' + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/customer/CustomerResponse.java b/src/main/java/com/petshop/backend/dto/customer/CustomerResponse.java index 3e6be930..7b25f17a 100644 --- a/src/main/java/com/petshop/backend/dto/customer/CustomerResponse.java +++ b/src/main/java/com/petshop/backend/dto/customer/CustomerResponse.java @@ -4,65 +4,65 @@ import java.time.LocalDateTime; import java.util.Objects; public class CustomerResponse { - private Long id; - private String customerName; - private String customerEmail; - private String customerPhone; - private String customerAddress; + private Long customerId; + private String firstName; + private String lastName; + private String email; + private String phone; private LocalDateTime createdAt; private LocalDateTime updatedAt; public CustomerResponse() { } - public CustomerResponse(Long id, String customerName, String customerEmail, String customerPhone, String customerAddress, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.customerName = customerName; - this.customerEmail = customerEmail; - this.customerPhone = customerPhone; - this.customerAddress = customerAddress; + public CustomerResponse(Long customerId, String firstName, String lastName, String email, String phone, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.customerId = customerId; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.phone = phone; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getCustomerId() { + return customerId; } - public void setId(Long id) { - this.id = id; + public void setCustomerId(Long customerId) { + this.customerId = customerId; } - public String getCustomerName() { - return customerName; + public String getFirstName() { + return firstName; } - public void setCustomerName(String customerName) { - this.customerName = customerName; + public void setFirstName(String firstName) { + this.firstName = firstName; } - public String getCustomerEmail() { - return customerEmail; + public String getLastName() { + return lastName; } - public void setCustomerEmail(String customerEmail) { - this.customerEmail = customerEmail; + public void setLastName(String lastName) { + this.lastName = lastName; } - public String getCustomerPhone() { - return customerPhone; + public String getEmail() { + return email; } - public void setCustomerPhone(String customerPhone) { - this.customerPhone = customerPhone; + public void setEmail(String email) { + this.email = email; } - public String getCustomerAddress() { - return customerAddress; + public String getPhone() { + return phone; } - public void setCustomerAddress(String customerAddress) { - this.customerAddress = customerAddress; + public void setPhone(String phone) { + this.phone = phone; } public LocalDateTime getCreatedAt() { @@ -86,22 +86,22 @@ public class CustomerResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CustomerResponse that = (CustomerResponse) o; - return Objects.equals(id, that.id) && Objects.equals(customerName, that.customerName) && Objects.equals(customerEmail, that.customerEmail) && Objects.equals(customerPhone, that.customerPhone) && Objects.equals(customerAddress, that.customerAddress) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(customerId, that.customerId) && Objects.equals(firstName, that.firstName) && Objects.equals(lastName, that.lastName) && Objects.equals(email, that.email) && Objects.equals(phone, that.phone) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, customerName, customerEmail, customerPhone, customerAddress, createdAt, updatedAt); + return Objects.hash(customerId, firstName, lastName, email, phone, createdAt, updatedAt); } @Override public String toString() { return "CustomerResponse{" + - "id=" + id + - ", customerName='" + customerName + '\'' + - ", customerEmail='" + customerEmail + '\'' + - ", customerPhone='" + customerPhone + '\'' + - ", customerAddress='" + customerAddress + '\'' + + "customerId=" + customerId + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", email='" + email + '\'' + + ", phone='" + phone + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/inventory/InventoryRequest.java b/src/main/java/com/petshop/backend/dto/inventory/InventoryRequest.java index 5ecf211a..2dd953c6 100644 --- a/src/main/java/com/petshop/backend/dto/inventory/InventoryRequest.java +++ b/src/main/java/com/petshop/backend/dto/inventory/InventoryRequest.java @@ -8,15 +8,10 @@ public class InventoryRequest { @NotNull(message = "Product ID is required") private Long prodId; - private Long storeId; - @NotNull(message = "Quantity is required") @PositiveOrZero(message = "Quantity must be zero or positive") private Integer quantity; - @PositiveOrZero(message = "Reorder level must be zero or positive") - private Integer reorderLevel = 10; - public Long getProdId() { return prodId; } @@ -25,14 +20,6 @@ public class InventoryRequest { this.prodId = prodId; } - public Long getStoreId() { - return storeId; - } - - public void setStoreId(Long storeId) { - this.storeId = storeId; - } - public Integer getQuantity() { return quantity; } @@ -41,37 +28,25 @@ public class InventoryRequest { this.quantity = quantity; } - public Integer getReorderLevel() { - return reorderLevel; - } - - public void setReorderLevel(Integer reorderLevel) { - this.reorderLevel = reorderLevel; - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; InventoryRequest that = (InventoryRequest) o; return Objects.equals(prodId, that.prodId) && - Objects.equals(storeId, that.storeId) && - Objects.equals(quantity, that.quantity) && - Objects.equals(reorderLevel, that.reorderLevel); + Objects.equals(quantity, that.quantity); } @Override public int hashCode() { - return Objects.hash(prodId, storeId, quantity, reorderLevel); + return Objects.hash(prodId, quantity); } @Override public String toString() { return "InventoryRequest{" + "prodId=" + prodId + - ", storeId=" + storeId + ", quantity=" + quantity + - ", reorderLevel=" + reorderLevel + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/inventory/InventoryResponse.java b/src/main/java/com/petshop/backend/dto/inventory/InventoryResponse.java index cb618959..710dcbf4 100644 --- a/src/main/java/com/petshop/backend/dto/inventory/InventoryResponse.java +++ b/src/main/java/com/petshop/backend/dto/inventory/InventoryResponse.java @@ -4,49 +4,41 @@ import java.time.LocalDateTime; import java.util.Objects; public class InventoryResponse { - private Long id; - private Long productId; + private Long inventoryId; + private Long prodId; private String productName; private String categoryName; - private Long storeId; - private String storeName; private Integer quantity; - private Integer reorderLevel; - private LocalDateTime lastRestocked; private LocalDateTime createdAt; private LocalDateTime updatedAt; public InventoryResponse() { } - public InventoryResponse(Long id, Long productId, String productName, String categoryName, Long storeId, String storeName, Integer quantity, Integer reorderLevel, LocalDateTime lastRestocked, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.productId = productId; + public InventoryResponse(Long inventoryId, Long prodId, String productName, String categoryName, Integer quantity, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.inventoryId = inventoryId; + this.prodId = prodId; this.productName = productName; this.categoryName = categoryName; - this.storeId = storeId; - this.storeName = storeName; this.quantity = quantity; - this.reorderLevel = reorderLevel; - this.lastRestocked = lastRestocked; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getInventoryId() { + return inventoryId; } - public void setId(Long id) { - this.id = id; + public void setInventoryId(Long inventoryId) { + this.inventoryId = inventoryId; } - public Long getProductId() { - return productId; + public Long getProdId() { + return prodId; } - public void setProductId(Long productId) { - this.productId = productId; + public void setProdId(Long prodId) { + this.prodId = prodId; } public String getProductName() { @@ -65,22 +57,6 @@ public class InventoryResponse { this.categoryName = categoryName; } - public Long getStoreId() { - return storeId; - } - - public void setStoreId(Long storeId) { - this.storeId = storeId; - } - - public String getStoreName() { - return storeName; - } - - public void setStoreName(String storeName) { - this.storeName = storeName; - } - public Integer getQuantity() { return quantity; } @@ -89,22 +65,6 @@ public class InventoryResponse { this.quantity = quantity; } - public Integer getReorderLevel() { - return reorderLevel; - } - - public void setReorderLevel(Integer reorderLevel) { - this.reorderLevel = reorderLevel; - } - - public LocalDateTime getLastRestocked() { - return lastRestocked; - } - - public void setLastRestocked(LocalDateTime lastRestocked) { - this.lastRestocked = lastRestocked; - } - public LocalDateTime getCreatedAt() { return createdAt; } @@ -126,26 +86,22 @@ public class InventoryResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; InventoryResponse that = (InventoryResponse) o; - return Objects.equals(id, that.id) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(categoryName, that.categoryName) && Objects.equals(storeId, that.storeId) && Objects.equals(storeName, that.storeName) && Objects.equals(quantity, that.quantity) && Objects.equals(reorderLevel, that.reorderLevel) && Objects.equals(lastRestocked, that.lastRestocked) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(inventoryId, that.inventoryId) && Objects.equals(prodId, that.prodId) && Objects.equals(productName, that.productName) && Objects.equals(categoryName, that.categoryName) && Objects.equals(quantity, that.quantity) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, productId, productName, categoryName, storeId, storeName, quantity, reorderLevel, lastRestocked, createdAt, updatedAt); + return Objects.hash(inventoryId, prodId, productName, categoryName, quantity, createdAt, updatedAt); } @Override public String toString() { return "InventoryResponse{" + - "id=" + id + - ", productId=" + productId + + "inventoryId=" + inventoryId + + ", prodId=" + prodId + ", productName='" + productName + '\'' + ", categoryName='" + categoryName + '\'' + - ", storeId=" + storeId + - ", storeName='" + storeName + '\'' + ", quantity=" + quantity + - ", reorderLevel=" + reorderLevel + - ", lastRestocked=" + lastRestocked + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/pet/PetRequest.java b/src/main/java/com/petshop/backend/dto/pet/PetRequest.java index aeb0f0db..db3f71c9 100644 --- a/src/main/java/com/petshop/backend/dto/pet/PetRequest.java +++ b/src/main/java/com/petshop/backend/dto/pet/PetRequest.java @@ -1,6 +1,5 @@ package com.petshop.backend.dto.pet; -import com.petshop.backend.entity.Pet; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; @@ -20,7 +19,7 @@ public class PetRequest { private Integer petAge; @NotNull(message = "Status is required") - private Pet.PetStatus petStatus; + private String petStatus; private BigDecimal petPrice; @@ -56,11 +55,11 @@ public class PetRequest { this.petAge = petAge; } - public Pet.PetStatus getPetStatus() { + public String getPetStatus() { return petStatus; } - public void setPetStatus(Pet.PetStatus petStatus) { + public void setPetStatus(String petStatus) { this.petStatus = petStatus; } diff --git a/src/main/java/com/petshop/backend/dto/pet/PetResponse.java b/src/main/java/com/petshop/backend/dto/pet/PetResponse.java index 18e31381..f691361a 100644 --- a/src/main/java/com/petshop/backend/dto/pet/PetResponse.java +++ b/src/main/java/com/petshop/backend/dto/pet/PetResponse.java @@ -5,7 +5,7 @@ import java.time.LocalDateTime; import java.util.Objects; public class PetResponse { - private Long id; + private Long petId; private String petName; private String petSpecies; private String petBreed; @@ -18,8 +18,8 @@ public class PetResponse { public PetResponse() { } - public PetResponse(Long id, String petName, String petSpecies, String petBreed, Integer petAge, String petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public PetResponse(Long petId, String petName, String petSpecies, String petBreed, Integer petAge, String petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.petId = petId; this.petName = petName; this.petSpecies = petSpecies; this.petBreed = petBreed; @@ -30,12 +30,12 @@ public class PetResponse { this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getPetId() { + return petId; } - public void setId(Long id) { - this.id = id; + public void setPetId(Long petId) { + this.petId = petId; } public String getPetName() { @@ -107,18 +107,18 @@ public class PetResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PetResponse that = (PetResponse) o; - return Objects.equals(id, that.id) && Objects.equals(petName, that.petName) && Objects.equals(petSpecies, that.petSpecies) && Objects.equals(petBreed, that.petBreed) && Objects.equals(petAge, that.petAge) && Objects.equals(petStatus, that.petStatus) && Objects.equals(petPrice, that.petPrice) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(petId, that.petId) && Objects.equals(petName, that.petName) && Objects.equals(petSpecies, that.petSpecies) && Objects.equals(petBreed, that.petBreed) && Objects.equals(petAge, that.petAge) && Objects.equals(petStatus, that.petStatus) && Objects.equals(petPrice, that.petPrice) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, petName, petSpecies, petBreed, petAge, petStatus, petPrice, createdAt, updatedAt); + return Objects.hash(petId, petName, petSpecies, petBreed, petAge, petStatus, petPrice, createdAt, updatedAt); } @Override public String toString() { return "PetResponse{" + - "id=" + id + + "petId=" + petId + ", petName='" + petName + '\'' + ", petSpecies='" + petSpecies + '\'' + ", petBreed='" + petBreed + '\'' + diff --git a/src/main/java/com/petshop/backend/dto/product/ProductRequest.java b/src/main/java/com/petshop/backend/dto/product/ProductRequest.java index 3e44a803..71dd600f 100644 --- a/src/main/java/com/petshop/backend/dto/product/ProductRequest.java +++ b/src/main/java/com/petshop/backend/dto/product/ProductRequest.java @@ -19,8 +19,6 @@ public class ProductRequest { @Positive(message = "Price must be positive") private BigDecimal prodPrice; - private Boolean active = true; - public String getProdName() { return prodName; } @@ -53,14 +51,6 @@ public class ProductRequest { this.prodPrice = prodPrice; } - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -69,13 +59,12 @@ public class ProductRequest { return Objects.equals(prodName, that.prodName) && Objects.equals(categoryId, that.categoryId) && Objects.equals(prodDesc, that.prodDesc) && - Objects.equals(prodPrice, that.prodPrice) && - Objects.equals(active, that.active); + Objects.equals(prodPrice, that.prodPrice); } @Override public int hashCode() { - return Objects.hash(prodName, categoryId, prodDesc, prodPrice, active); + return Objects.hash(prodName, categoryId, prodDesc, prodPrice); } @Override @@ -85,7 +74,6 @@ public class ProductRequest { ", categoryId=" + categoryId + ", prodDesc='" + prodDesc + '\'' + ", prodPrice=" + prodPrice + - ", active=" + active + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/product/ProductResponse.java b/src/main/java/com/petshop/backend/dto/product/ProductResponse.java index d54632c4..96baa5ce 100644 --- a/src/main/java/com/petshop/backend/dto/product/ProductResponse.java +++ b/src/main/java/com/petshop/backend/dto/product/ProductResponse.java @@ -5,45 +5,43 @@ import java.time.LocalDateTime; import java.util.Objects; public class ProductResponse { - private Long id; - private String productName; + private Long prodId; + private String prodName; private Long categoryId; private String categoryName; - private String productDescription; - private BigDecimal productPrice; - private Boolean active; + private String prodDesc; + private BigDecimal prodPrice; private LocalDateTime createdAt; private LocalDateTime updatedAt; public ProductResponse() { } - public ProductResponse(Long id, String productName, Long categoryId, String categoryName, String productDescription, BigDecimal productPrice, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.productName = productName; + public ProductResponse(Long prodId, String prodName, Long categoryId, String categoryName, String prodDesc, BigDecimal prodPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.prodId = prodId; + this.prodName = prodName; this.categoryId = categoryId; this.categoryName = categoryName; - this.productDescription = productDescription; - this.productPrice = productPrice; - this.active = active; + this.prodDesc = prodDesc; + this.prodPrice = prodPrice; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getProdId() { + return prodId; } - public void setId(Long id) { - this.id = id; + public void setProdId(Long prodId) { + this.prodId = prodId; } - public String getProductName() { - return productName; + public String getProdName() { + return prodName; } - public void setProductName(String productName) { - this.productName = productName; + public void setProdName(String prodName) { + this.prodName = prodName; } public Long getCategoryId() { @@ -62,28 +60,20 @@ public class ProductResponse { this.categoryName = categoryName; } - public String getProductDescription() { - return productDescription; + public String getProdDesc() { + return prodDesc; } - public void setProductDescription(String productDescription) { - this.productDescription = productDescription; + public void setProdDesc(String prodDesc) { + this.prodDesc = prodDesc; } - public BigDecimal getProductPrice() { - return productPrice; + public BigDecimal getProdPrice() { + return prodPrice; } - public void setProductPrice(BigDecimal productPrice) { - this.productPrice = productPrice; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; + public void setProdPrice(BigDecimal prodPrice) { + this.prodPrice = prodPrice; } public LocalDateTime getCreatedAt() { @@ -107,24 +97,23 @@ public class ProductResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ProductResponse that = (ProductResponse) o; - return Objects.equals(id, that.id) && Objects.equals(productName, that.productName) && Objects.equals(categoryId, that.categoryId) && Objects.equals(categoryName, that.categoryName) && Objects.equals(productDescription, that.productDescription) && Objects.equals(productPrice, that.productPrice) && Objects.equals(active, that.active) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(prodId, that.prodId) && Objects.equals(prodName, that.prodName) && Objects.equals(categoryId, that.categoryId) && Objects.equals(categoryName, that.categoryName) && Objects.equals(prodDesc, that.prodDesc) && Objects.equals(prodPrice, that.prodPrice) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, productName, categoryId, categoryName, productDescription, productPrice, active, createdAt, updatedAt); + return Objects.hash(prodId, prodName, categoryId, categoryName, prodDesc, prodPrice, createdAt, updatedAt); } @Override public String toString() { return "ProductResponse{" + - "id=" + id + - ", productName='" + productName + '\'' + + "prodId=" + prodId + + ", prodName='" + prodName + '\'' + ", categoryId=" + categoryId + ", categoryName='" + categoryName + '\'' + - ", productDescription='" + productDescription + '\'' + - ", productPrice=" + productPrice + - ", active=" + active + + ", prodDesc='" + prodDesc + '\'' + + ", prodPrice=" + prodPrice + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierRequest.java b/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierRequest.java index 7854b37e..1bc05210 100644 --- a/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierRequest.java +++ b/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierRequest.java @@ -2,7 +2,6 @@ package com.petshop.backend.dto.productsupplier; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; -import jakarta.validation.constraints.PositiveOrZero; import java.math.BigDecimal; import java.util.Objects; @@ -13,14 +12,9 @@ public class ProductSupplierRequest { @NotNull(message = "Supplier ID is required") private Long supplierId; - @NotNull(message = "Cost price is required") - @Positive(message = "Cost price must be positive") - private BigDecimal costPrice; - - @PositiveOrZero(message = "Lead time must be zero or positive") - private Integer leadTimeDays; - - private Boolean isPreferred = false; + @NotNull(message = "Cost is required") + @Positive(message = "Cost must be positive") + private BigDecimal cost; public Long getProductId() { return productId; @@ -38,28 +32,12 @@ public class ProductSupplierRequest { this.supplierId = supplierId; } - public BigDecimal getCostPrice() { - return costPrice; + public BigDecimal getCost() { + return cost; } - public void setCostPrice(BigDecimal costPrice) { - this.costPrice = costPrice; - } - - public Integer getLeadTimeDays() { - return leadTimeDays; - } - - public void setLeadTimeDays(Integer leadTimeDays) { - this.leadTimeDays = leadTimeDays; - } - - public Boolean getIsPreferred() { - return isPreferred; - } - - public void setIsPreferred(Boolean isPreferred) { - this.isPreferred = isPreferred; + public void setCost(BigDecimal cost) { + this.cost = cost; } @Override @@ -69,14 +47,12 @@ public class ProductSupplierRequest { ProductSupplierRequest that = (ProductSupplierRequest) o; return Objects.equals(productId, that.productId) && Objects.equals(supplierId, that.supplierId) && - Objects.equals(costPrice, that.costPrice) && - Objects.equals(leadTimeDays, that.leadTimeDays) && - Objects.equals(isPreferred, that.isPreferred); + Objects.equals(cost, that.cost); } @Override public int hashCode() { - return Objects.hash(productId, supplierId, costPrice, leadTimeDays, isPreferred); + return Objects.hash(productId, supplierId, cost); } @Override @@ -84,9 +60,7 @@ public class ProductSupplierRequest { return "ProductSupplierRequest{" + "productId=" + productId + ", supplierId=" + supplierId + - ", costPrice=" + costPrice + - ", leadTimeDays=" + leadTimeDays + - ", isPreferred=" + isPreferred + + ", cost=" + cost + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierResponse.java b/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierResponse.java index 44cafe3c..4190dabb 100644 --- a/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierResponse.java +++ b/src/main/java/com/petshop/backend/dto/productsupplier/ProductSupplierResponse.java @@ -9,23 +9,19 @@ public class ProductSupplierResponse { private String productName; private Long supplierId; private String supplierName; - private BigDecimal costPrice; - private Integer leadTimeDays; - private Boolean isPreferred; + private BigDecimal cost; private LocalDateTime createdAt; private LocalDateTime updatedAt; public ProductSupplierResponse() { } - public ProductSupplierResponse(Long productId, String productName, Long supplierId, String supplierName, BigDecimal costPrice, Integer leadTimeDays, Boolean isPreferred, LocalDateTime createdAt, LocalDateTime updatedAt) { + public ProductSupplierResponse(Long productId, String productName, Long supplierId, String supplierName, BigDecimal cost, LocalDateTime createdAt, LocalDateTime updatedAt) { this.productId = productId; this.productName = productName; this.supplierId = supplierId; this.supplierName = supplierName; - this.costPrice = costPrice; - this.leadTimeDays = leadTimeDays; - this.isPreferred = isPreferred; + this.cost = cost; this.createdAt = createdAt; this.updatedAt = updatedAt; } @@ -62,28 +58,12 @@ public class ProductSupplierResponse { this.supplierName = supplierName; } - public BigDecimal getCostPrice() { - return costPrice; + public BigDecimal getCost() { + return cost; } - public void setCostPrice(BigDecimal costPrice) { - this.costPrice = costPrice; - } - - public Integer getLeadTimeDays() { - return leadTimeDays; - } - - public void setLeadTimeDays(Integer leadTimeDays) { - this.leadTimeDays = leadTimeDays; - } - - public Boolean getIsPreferred() { - return isPreferred; - } - - public void setIsPreferred(Boolean isPreferred) { - this.isPreferred = isPreferred; + public void setCost(BigDecimal cost) { + this.cost = cost; } public LocalDateTime getCreatedAt() { @@ -107,12 +87,12 @@ public class ProductSupplierResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ProductSupplierResponse that = (ProductSupplierResponse) o; - return Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(supplierId, that.supplierId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(costPrice, that.costPrice) && Objects.equals(leadTimeDays, that.leadTimeDays) && Objects.equals(isPreferred, that.isPreferred) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(supplierId, that.supplierId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(cost, that.cost) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(productId, productName, supplierId, supplierName, costPrice, leadTimeDays, isPreferred, createdAt, updatedAt); + return Objects.hash(productId, productName, supplierId, supplierName, cost, createdAt, updatedAt); } @Override @@ -122,9 +102,7 @@ public class ProductSupplierResponse { ", productName='" + productName + '\'' + ", supplierId=" + supplierId + ", supplierName='" + supplierName + '\'' + - ", costPrice=" + costPrice + - ", leadTimeDays=" + leadTimeDays + - ", isPreferred=" + isPreferred + + ", cost=" + cost + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/purchaseorder/PurchaseOrderResponse.java b/src/main/java/com/petshop/backend/dto/purchaseorder/PurchaseOrderResponse.java index 403aa274..bf575d9d 100644 --- a/src/main/java/com/petshop/backend/dto/purchaseorder/PurchaseOrderResponse.java +++ b/src/main/java/com/petshop/backend/dto/purchaseorder/PurchaseOrderResponse.java @@ -1,55 +1,45 @@ package com.petshop.backend.dto.purchaseorder; -import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.List; import java.util.Objects; public class PurchaseOrderResponse { - private Long id; - private Long supplierId; + private Long purchaseOrderId; + private Long supId; private String supplierName; private LocalDate orderDate; - private LocalDate expectedDelivery; private String status; - private BigDecimal totalAmount; - private String notes; - private List items; private LocalDateTime createdAt; private LocalDateTime updatedAt; public PurchaseOrderResponse() { } - public PurchaseOrderResponse(Long id, Long supplierId, String supplierName, LocalDate orderDate, LocalDate expectedDelivery, String status, BigDecimal totalAmount, String notes, List items, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.supplierId = supplierId; + public PurchaseOrderResponse(Long purchaseOrderId, Long supId, String supplierName, LocalDate orderDate, String status, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.purchaseOrderId = purchaseOrderId; + this.supId = supId; this.supplierName = supplierName; this.orderDate = orderDate; - this.expectedDelivery = expectedDelivery; this.status = status; - this.totalAmount = totalAmount; - this.notes = notes; - this.items = items; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getPurchaseOrderId() { + return purchaseOrderId; } - public void setId(Long id) { - this.id = id; + public void setPurchaseOrderId(Long purchaseOrderId) { + this.purchaseOrderId = purchaseOrderId; } - public Long getSupplierId() { - return supplierId; + public Long getSupId() { + return supId; } - public void setSupplierId(Long supplierId) { - this.supplierId = supplierId; + public void setSupId(Long supId) { + this.supId = supId; } public String getSupplierName() { @@ -68,14 +58,6 @@ public class PurchaseOrderResponse { this.orderDate = orderDate; } - public LocalDate getExpectedDelivery() { - return expectedDelivery; - } - - public void setExpectedDelivery(LocalDate expectedDelivery) { - this.expectedDelivery = expectedDelivery; - } - public String getStatus() { return status; } @@ -84,30 +66,6 @@ public class PurchaseOrderResponse { this.status = status; } - public BigDecimal getTotalAmount() { - return totalAmount; - } - - public void setTotalAmount(BigDecimal totalAmount) { - this.totalAmount = totalAmount; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - public LocalDateTime getCreatedAt() { return createdAt; } @@ -129,122 +87,24 @@ public class PurchaseOrderResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PurchaseOrderResponse that = (PurchaseOrderResponse) o; - return Objects.equals(id, that.id) && Objects.equals(supplierId, that.supplierId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(orderDate, that.orderDate) && Objects.equals(expectedDelivery, that.expectedDelivery) && Objects.equals(status, that.status) && Objects.equals(totalAmount, that.totalAmount) && Objects.equals(notes, that.notes) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(purchaseOrderId, that.purchaseOrderId) && Objects.equals(supId, that.supId) && Objects.equals(supplierName, that.supplierName) && Objects.equals(orderDate, that.orderDate) && Objects.equals(status, that.status) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, supplierId, supplierName, orderDate, expectedDelivery, status, totalAmount, notes, items, createdAt, updatedAt); + return Objects.hash(purchaseOrderId, supId, supplierName, orderDate, status, createdAt, updatedAt); } @Override public String toString() { return "PurchaseOrderResponse{" + - "id=" + id + - ", supplierId=" + supplierId + + "purchaseOrderId=" + purchaseOrderId + + ", supId=" + supId + ", supplierName='" + supplierName + '\'' + ", orderDate=" + orderDate + - ", expectedDelivery=" + expectedDelivery + ", status='" + status + '\'' + - ", totalAmount=" + totalAmount + - ", notes='" + notes + '\'' + - ", items=" + items + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; } - - public static class PurchaseOrderItemResponse { - private Long id; - private Long productId; - private String productName; - private Integer quantity; - private BigDecimal unitCost; - private BigDecimal subtotal; - - public PurchaseOrderItemResponse() { - } - - public PurchaseOrderItemResponse(Long id, Long productId, String productName, Integer quantity, BigDecimal unitCost, BigDecimal subtotal) { - this.id = id; - this.productId = productId; - this.productName = productName; - this.quantity = quantity; - this.unitCost = unitCost; - this.subtotal = subtotal; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getProductId() { - return productId; - } - - public void setProductId(Long productId) { - this.productId = productId; - } - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - public BigDecimal getUnitCost() { - return unitCost; - } - - public void setUnitCost(BigDecimal unitCost) { - this.unitCost = unitCost; - } - - public BigDecimal getSubtotal() { - return subtotal; - } - - public void setSubtotal(BigDecimal subtotal) { - this.subtotal = subtotal; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PurchaseOrderItemResponse that = (PurchaseOrderItemResponse) o; - return Objects.equals(id, that.id) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(unitCost, that.unitCost) && Objects.equals(subtotal, that.subtotal); - } - - @Override - public int hashCode() { - return Objects.hash(id, productId, productName, quantity, unitCost, subtotal); - } - - @Override - public String toString() { - return "PurchaseOrderItemResponse{" + - "id=" + id + - ", productId=" + productId + - ", productName='" + productName + '\'' + - ", quantity=" + quantity + - ", unitCost=" + unitCost + - ", subtotal=" + subtotal + - '}'; - } - } } diff --git a/src/main/java/com/petshop/backend/dto/refund/RefundItemRequest.java b/src/main/java/com/petshop/backend/dto/refund/RefundItemRequest.java deleted file mode 100644 index 5c28c3f3..00000000 --- a/src/main/java/com/petshop/backend/dto/refund/RefundItemRequest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.petshop.backend.dto.refund; - -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Positive; -import java.util.Objects; - -public class RefundItemRequest { - @NotNull(message = "Sale item ID is required") - private Long saleItemId; - - @NotNull(message = "Quantity is required") - @Positive(message = "Quantity must be positive") - private Integer quantity; - - public Long getSaleItemId() { - return saleItemId; - } - - public void setSaleItemId(Long saleItemId) { - this.saleItemId = saleItemId; - } - - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RefundItemRequest that = (RefundItemRequest) o; - return Objects.equals(saleItemId, that.saleItemId) && - Objects.equals(quantity, that.quantity); - } - - @Override - public int hashCode() { - return Objects.hash(saleItemId, quantity); - } - - @Override - public String toString() { - return "RefundItemRequest{" + - "saleItemId=" + saleItemId + - ", quantity=" + quantity + - '}'; - } -} diff --git a/src/main/java/com/petshop/backend/dto/refund/RefundRequest.java b/src/main/java/com/petshop/backend/dto/refund/RefundRequest.java deleted file mode 100644 index 154e838f..00000000 --- a/src/main/java/com/petshop/backend/dto/refund/RefundRequest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.petshop.backend.dto.refund; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotEmpty; -import java.util.List; -import java.util.Objects; - -public class RefundRequest { - @NotEmpty(message = "At least one item is required") - @Valid - private List items; - - private String refundReason; - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - public String getRefundReason() { - return refundReason; - } - - public void setRefundReason(String refundReason) { - this.refundReason = refundReason; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RefundRequest that = (RefundRequest) o; - return Objects.equals(items, that.items) && - Objects.equals(refundReason, that.refundReason); - } - - @Override - public int hashCode() { - return Objects.hash(items, refundReason); - } - - @Override - public String toString() { - return "RefundRequest{" + - "items=" + items + - ", refundReason='" + refundReason + '\'' + - '}'; - } -} diff --git a/src/main/java/com/petshop/backend/dto/refund/RefundResponse.java b/src/main/java/com/petshop/backend/dto/refund/RefundResponse.java deleted file mode 100644 index a502fb25..00000000 --- a/src/main/java/com/petshop/backend/dto/refund/RefundResponse.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.petshop.backend.dto.refund; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - -public class RefundResponse { - private Long id; - private Long saleId; - private LocalDateTime refundDate; - private BigDecimal refundAmount; - private String refundReason; - private Long processedBy; - private String processedByName; - private List items; - private LocalDateTime createdAt; - - public RefundResponse() { - } - - public RefundResponse(Long id, Long saleId, LocalDateTime refundDate, BigDecimal refundAmount, String refundReason, Long processedBy, String processedByName, List items, LocalDateTime createdAt) { - this.id = id; - this.saleId = saleId; - this.refundDate = refundDate; - this.refundAmount = refundAmount; - this.refundReason = refundReason; - this.processedBy = processedBy; - this.processedByName = processedByName; - this.items = items; - this.createdAt = createdAt; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getSaleId() { - return saleId; - } - - public void setSaleId(Long saleId) { - this.saleId = saleId; - } - - public LocalDateTime getRefundDate() { - return refundDate; - } - - public void setRefundDate(LocalDateTime refundDate) { - this.refundDate = refundDate; - } - - public BigDecimal getRefundAmount() { - return refundAmount; - } - - public void setRefundAmount(BigDecimal refundAmount) { - this.refundAmount = refundAmount; - } - - public String getRefundReason() { - return refundReason; - } - - public void setRefundReason(String refundReason) { - this.refundReason = refundReason; - } - - public Long getProcessedBy() { - return processedBy; - } - - public void setProcessedBy(Long processedBy) { - this.processedBy = processedBy; - } - - public String getProcessedByName() { - return processedByName; - } - - public void setProcessedByName(String processedByName) { - this.processedByName = processedByName; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - public LocalDateTime getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(LocalDateTime createdAt) { - this.createdAt = createdAt; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RefundResponse that = (RefundResponse) o; - return Objects.equals(id, that.id) && Objects.equals(saleId, that.saleId) && Objects.equals(refundDate, that.refundDate) && Objects.equals(refundAmount, that.refundAmount) && Objects.equals(refundReason, that.refundReason) && Objects.equals(processedBy, that.processedBy) && Objects.equals(processedByName, that.processedByName) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt); - } - - @Override - public int hashCode() { - return Objects.hash(id, saleId, refundDate, refundAmount, refundReason, processedBy, processedByName, items, createdAt); - } - - @Override - public String toString() { - return "RefundResponse{" + - "id=" + id + - ", saleId=" + saleId + - ", refundDate=" + refundDate + - ", refundAmount=" + refundAmount + - ", refundReason='" + refundReason + '\'' + - ", processedBy=" + processedBy + - ", processedByName='" + processedByName + '\'' + - ", items=" + items + - ", createdAt=" + createdAt + - '}'; - } - - public static class RefundItemResponse { - private Long id; - private Long saleItemId; - private Long productId; - private String productName; - private Integer quantity; - private BigDecimal refundAmount; - - public RefundItemResponse() { - } - - public RefundItemResponse(Long id, Long saleItemId, Long productId, String productName, Integer quantity, BigDecimal refundAmount) { - this.id = id; - this.saleItemId = saleItemId; - this.productId = productId; - this.productName = productName; - this.quantity = quantity; - this.refundAmount = refundAmount; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getSaleItemId() { - return saleItemId; - } - - public void setSaleItemId(Long saleItemId) { - this.saleItemId = saleItemId; - } - - public Long getProductId() { - return productId; - } - - public void setProductId(Long productId) { - this.productId = productId; - } - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - public BigDecimal getRefundAmount() { - return refundAmount; - } - - public void setRefundAmount(BigDecimal refundAmount) { - this.refundAmount = refundAmount; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RefundItemResponse that = (RefundItemResponse) o; - return Objects.equals(id, that.id) && Objects.equals(saleItemId, that.saleItemId) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(refundAmount, that.refundAmount); - } - - @Override - public int hashCode() { - return Objects.hash(id, saleItemId, productId, productName, quantity, refundAmount); - } - - @Override - public String toString() { - return "RefundItemResponse{" + - "id=" + id + - ", saleItemId=" + saleItemId + - ", productId=" + productId + - ", productName='" + productName + '\'' + - ", quantity=" + quantity + - ", refundAmount=" + refundAmount + - '}'; - } - } -} diff --git a/src/main/java/com/petshop/backend/dto/sale/SaleItemRequest.java b/src/main/java/com/petshop/backend/dto/sale/SaleItemRequest.java index 985aa0c4..94e094c3 100644 --- a/src/main/java/com/petshop/backend/dto/sale/SaleItemRequest.java +++ b/src/main/java/com/petshop/backend/dto/sale/SaleItemRequest.java @@ -6,18 +6,17 @@ import java.util.Objects; public class SaleItemRequest { @NotNull(message = "Product ID is required") - private Long productId; + private Long prodId; @NotNull(message = "Quantity is required") - @Positive(message = "Quantity must be positive") private Integer quantity; - public Long getProductId() { - return productId; + public Long getProdId() { + return prodId; } - public void setProductId(Long productId) { - this.productId = productId; + public void setProdId(Long prodId) { + this.prodId = prodId; } public Integer getQuantity() { @@ -33,19 +32,19 @@ public class SaleItemRequest { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SaleItemRequest that = (SaleItemRequest) o; - return Objects.equals(productId, that.productId) && + return Objects.equals(prodId, that.prodId) && Objects.equals(quantity, that.quantity); } @Override public int hashCode() { - return Objects.hash(productId, quantity); + return Objects.hash(prodId, quantity); } @Override public String toString() { return "SaleItemRequest{" + - "productId=" + productId + + "prodId=" + prodId + ", quantity=" + quantity + '}'; } diff --git a/src/main/java/com/petshop/backend/dto/sale/SaleRequest.java b/src/main/java/com/petshop/backend/dto/sale/SaleRequest.java index bece02f5..6ea9ff73 100644 --- a/src/main/java/com/petshop/backend/dto/sale/SaleRequest.java +++ b/src/main/java/com/petshop/backend/dto/sale/SaleRequest.java @@ -3,33 +3,22 @@ package com.petshop.backend.dto.sale; import jakarta.validation.Valid; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; -import java.math.BigDecimal; import java.util.List; import java.util.Objects; public class SaleRequest { - private Long customerId; - @NotNull(message = "Store ID is required") private Long storeId; private String paymentMethod; - private BigDecimal tax = BigDecimal.ZERO; - @NotEmpty(message = "At least one item is required") @Valid private List items; - private String notes; + private Boolean isRefund = false; - public Long getCustomerId() { - return customerId; - } - - public void setCustomerId(Long customerId) { - this.customerId = customerId; - } + private Long originalSaleId; public Long getStoreId() { return storeId; @@ -47,14 +36,6 @@ public class SaleRequest { this.paymentMethod = paymentMethod; } - public BigDecimal getTax() { - return tax; - } - - public void setTax(BigDecimal tax) { - this.tax = tax; - } - public List getItems() { return items; } @@ -63,12 +44,20 @@ public class SaleRequest { this.items = items; } - public String getNotes() { - return notes; + public Boolean getIsRefund() { + return isRefund; } - public void setNotes(String notes) { - this.notes = notes; + public void setIsRefund(Boolean isRefund) { + this.isRefund = isRefund; + } + + public Long getOriginalSaleId() { + return originalSaleId; + } + + public void setOriginalSaleId(Long originalSaleId) { + this.originalSaleId = originalSaleId; } @Override @@ -76,28 +65,26 @@ public class SaleRequest { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SaleRequest that = (SaleRequest) o; - return Objects.equals(customerId, that.customerId) && - Objects.equals(storeId, that.storeId) && + return Objects.equals(storeId, that.storeId) && Objects.equals(paymentMethod, that.paymentMethod) && - Objects.equals(tax, that.tax) && Objects.equals(items, that.items) && - Objects.equals(notes, that.notes); + Objects.equals(isRefund, that.isRefund) && + Objects.equals(originalSaleId, that.originalSaleId); } @Override public int hashCode() { - return Objects.hash(customerId, storeId, paymentMethod, tax, items, notes); + return Objects.hash(storeId, paymentMethod, items, isRefund, originalSaleId); } @Override public String toString() { return "SaleRequest{" + - "customerId=" + customerId + - ", storeId=" + storeId + + "storeId=" + storeId + ", paymentMethod='" + paymentMethod + '\'' + - ", tax=" + tax + ", items=" + items + - ", notes='" + notes + '\'' + + ", isRefund=" + isRefund + + ", originalSaleId=" + originalSaleId + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/sale/SaleResponse.java b/src/main/java/com/petshop/backend/dto/sale/SaleResponse.java index b8634308..969b28d3 100644 --- a/src/main/java/com/petshop/backend/dto/sale/SaleResponse.java +++ b/src/main/java/com/petshop/backend/dto/sale/SaleResponse.java @@ -6,49 +6,43 @@ import java.util.List; import java.util.Objects; public class SaleResponse { - private Long id; + private Long saleId; private LocalDateTime saleDate; private Long employeeId; private String employeeName; - private Long customerId; - private String customerName; private Long storeId; private String storeName; - private BigDecimal subtotal; - private BigDecimal tax; - private BigDecimal total; + private BigDecimal totalAmount; private String paymentMethod; - private String notes; + private Boolean isRefund; + private Long originalSaleId; private List items; private LocalDateTime createdAt; public SaleResponse() { } - public SaleResponse(Long id, LocalDateTime saleDate, Long employeeId, String employeeName, Long customerId, String customerName, Long storeId, String storeName, BigDecimal subtotal, BigDecimal tax, BigDecimal total, String paymentMethod, String notes, List items, LocalDateTime createdAt) { - this.id = id; + public SaleResponse(Long saleId, LocalDateTime saleDate, Long employeeId, String employeeName, Long storeId, String storeName, BigDecimal totalAmount, String paymentMethod, Boolean isRefund, Long originalSaleId, List items, LocalDateTime createdAt) { + this.saleId = saleId; this.saleDate = saleDate; this.employeeId = employeeId; this.employeeName = employeeName; - this.customerId = customerId; - this.customerName = customerName; this.storeId = storeId; this.storeName = storeName; - this.subtotal = subtotal; - this.tax = tax; - this.total = total; + this.totalAmount = totalAmount; this.paymentMethod = paymentMethod; - this.notes = notes; + this.isRefund = isRefund; + this.originalSaleId = originalSaleId; this.items = items; this.createdAt = createdAt; } - public Long getId() { - return id; + public Long getSaleId() { + return saleId; } - public void setId(Long id) { - this.id = id; + public void setSaleId(Long saleId) { + this.saleId = saleId; } public LocalDateTime getSaleDate() { @@ -75,22 +69,6 @@ public class SaleResponse { this.employeeName = employeeName; } - public Long getCustomerId() { - return customerId; - } - - public void setCustomerId(Long customerId) { - this.customerId = customerId; - } - - public String getCustomerName() { - return customerName; - } - - public void setCustomerName(String customerName) { - this.customerName = customerName; - } - public Long getStoreId() { return storeId; } @@ -107,28 +85,12 @@ public class SaleResponse { this.storeName = storeName; } - public BigDecimal getSubtotal() { - return subtotal; + public BigDecimal getTotalAmount() { + return totalAmount; } - public void setSubtotal(BigDecimal subtotal) { - this.subtotal = subtotal; - } - - public BigDecimal getTax() { - return tax; - } - - public void setTax(BigDecimal tax) { - this.tax = tax; - } - - public BigDecimal getTotal() { - return total; - } - - public void setTotal(BigDecimal total) { - this.total = total; + public void setTotalAmount(BigDecimal totalAmount) { + this.totalAmount = totalAmount; } public String getPaymentMethod() { @@ -139,12 +101,20 @@ public class SaleResponse { this.paymentMethod = paymentMethod; } - public String getNotes() { - return notes; + public Boolean getIsRefund() { + return isRefund; } - public void setNotes(String notes) { - this.notes = notes; + public void setIsRefund(Boolean isRefund) { + this.isRefund = isRefund; + } + + public Long getOriginalSaleId() { + return originalSaleId; + } + + public void setOriginalSaleId(Long originalSaleId) { + this.originalSaleId = originalSaleId; } public List getItems() { @@ -168,69 +138,64 @@ public class SaleResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SaleResponse that = (SaleResponse) o; - return Objects.equals(id, that.id) && Objects.equals(saleDate, that.saleDate) && Objects.equals(employeeId, that.employeeId) && Objects.equals(employeeName, that.employeeName) && Objects.equals(customerId, that.customerId) && Objects.equals(customerName, that.customerName) && Objects.equals(storeId, that.storeId) && Objects.equals(storeName, that.storeName) && Objects.equals(subtotal, that.subtotal) && Objects.equals(tax, that.tax) && Objects.equals(total, that.total) && Objects.equals(paymentMethod, that.paymentMethod) && Objects.equals(notes, that.notes) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt); + return Objects.equals(saleId, that.saleId) && Objects.equals(saleDate, that.saleDate) && Objects.equals(employeeId, that.employeeId) && Objects.equals(employeeName, that.employeeName) && Objects.equals(storeId, that.storeId) && Objects.equals(storeName, that.storeName) && Objects.equals(totalAmount, that.totalAmount) && Objects.equals(paymentMethod, that.paymentMethod) && Objects.equals(isRefund, that.isRefund) && Objects.equals(originalSaleId, that.originalSaleId) && Objects.equals(items, that.items) && Objects.equals(createdAt, that.createdAt); } @Override public int hashCode() { - return Objects.hash(id, saleDate, employeeId, employeeName, customerId, customerName, storeId, storeName, subtotal, tax, total, paymentMethod, notes, items, createdAt); + return Objects.hash(saleId, saleDate, employeeId, employeeName, storeId, storeName, totalAmount, paymentMethod, isRefund, originalSaleId, items, createdAt); } @Override public String toString() { return "SaleResponse{" + - "id=" + id + + "saleId=" + saleId + ", saleDate=" + saleDate + ", employeeId=" + employeeId + ", employeeName='" + employeeName + '\'' + - ", customerId=" + customerId + - ", customerName='" + customerName + '\'' + ", storeId=" + storeId + ", storeName='" + storeName + '\'' + - ", subtotal=" + subtotal + - ", tax=" + tax + - ", total=" + total + + ", totalAmount=" + totalAmount + ", paymentMethod='" + paymentMethod + '\'' + - ", notes='" + notes + '\'' + + ", isRefund=" + isRefund + + ", originalSaleId=" + originalSaleId + ", items=" + items + ", createdAt=" + createdAt + '}'; } public static class SaleItemResponse { - private Long id; - private Long productId; + private Long saleItemId; + private Long prodId; private String productName; private Integer quantity; private BigDecimal unitPrice; - private BigDecimal subtotal; public SaleItemResponse() { } - public SaleItemResponse(Long id, Long productId, String productName, Integer quantity, BigDecimal unitPrice, BigDecimal subtotal) { - this.id = id; - this.productId = productId; + public SaleItemResponse(Long saleItemId, Long prodId, String productName, Integer quantity, BigDecimal unitPrice) { + this.saleItemId = saleItemId; + this.prodId = prodId; this.productName = productName; this.quantity = quantity; this.unitPrice = unitPrice; - this.subtotal = subtotal; } - public Long getId() { - return id; + public Long getSaleItemId() { + return saleItemId; } - public void setId(Long id) { - this.id = id; + public void setSaleItemId(Long saleItemId) { + this.saleItemId = saleItemId; } - public Long getProductId() { - return productId; + public Long getProdId() { + return prodId; } - public void setProductId(Long productId) { - this.productId = productId; + public void setProdId(Long prodId) { + this.prodId = prodId; } public String getProductName() { @@ -257,36 +222,27 @@ public class SaleResponse { this.unitPrice = unitPrice; } - public BigDecimal getSubtotal() { - return subtotal; - } - - public void setSubtotal(BigDecimal subtotal) { - this.subtotal = subtotal; - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SaleItemResponse that = (SaleItemResponse) o; - return Objects.equals(id, that.id) && Objects.equals(productId, that.productId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(unitPrice, that.unitPrice) && Objects.equals(subtotal, that.subtotal); + return Objects.equals(saleItemId, that.saleItemId) && Objects.equals(prodId, that.prodId) && Objects.equals(productName, that.productName) && Objects.equals(quantity, that.quantity) && Objects.equals(unitPrice, that.unitPrice); } @Override public int hashCode() { - return Objects.hash(id, productId, productName, quantity, unitPrice, subtotal); + return Objects.hash(saleItemId, prodId, productName, quantity, unitPrice); } @Override public String toString() { return "SaleItemResponse{" + - "id=" + id + - ", productId=" + productId + + "saleItemId=" + saleItemId + + ", prodId=" + prodId + ", productName='" + productName + '\'' + ", quantity=" + quantity + ", unitPrice=" + unitPrice + - ", subtotal=" + subtotal + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/service/ServiceRequest.java b/src/main/java/com/petshop/backend/dto/service/ServiceRequest.java index 123d704e..6b4550ec 100644 --- a/src/main/java/com/petshop/backend/dto/service/ServiceRequest.java +++ b/src/main/java/com/petshop/backend/dto/service/ServiceRequest.java @@ -10,16 +10,14 @@ public class ServiceRequest { @NotBlank(message = "Service name is required") private String serviceName; - private String serviceDescription; + private String serviceDesc; @NotNull(message = "Service price is required") @Positive(message = "Price must be positive") private BigDecimal servicePrice; @Positive(message = "Duration must be positive") - private Integer serviceDurationMinutes; - - private Boolean active = true; + private Integer serviceDuration; public String getServiceName() { return serviceName; @@ -29,12 +27,12 @@ public class ServiceRequest { this.serviceName = serviceName; } - public String getServiceDescription() { - return serviceDescription; + public String getServiceDesc() { + return serviceDesc; } - public void setServiceDescription(String serviceDescription) { - this.serviceDescription = serviceDescription; + public void setServiceDesc(String serviceDesc) { + this.serviceDesc = serviceDesc; } public BigDecimal getServicePrice() { @@ -45,20 +43,12 @@ public class ServiceRequest { this.servicePrice = servicePrice; } - public Integer getServiceDurationMinutes() { - return serviceDurationMinutes; + public Integer getServiceDuration() { + return serviceDuration; } - public void setServiceDurationMinutes(Integer serviceDurationMinutes) { - this.serviceDurationMinutes = serviceDurationMinutes; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; + public void setServiceDuration(Integer serviceDuration) { + this.serviceDuration = serviceDuration; } @Override @@ -67,25 +57,23 @@ public class ServiceRequest { if (o == null || getClass() != o.getClass()) return false; ServiceRequest that = (ServiceRequest) o; return Objects.equals(serviceName, that.serviceName) && - Objects.equals(serviceDescription, that.serviceDescription) && + Objects.equals(serviceDesc, that.serviceDesc) && Objects.equals(servicePrice, that.servicePrice) && - Objects.equals(serviceDurationMinutes, that.serviceDurationMinutes) && - Objects.equals(active, that.active); + Objects.equals(serviceDuration, that.serviceDuration); } @Override public int hashCode() { - return Objects.hash(serviceName, serviceDescription, servicePrice, serviceDurationMinutes, active); + return Objects.hash(serviceName, serviceDesc, servicePrice, serviceDuration); } @Override public String toString() { return "ServiceRequest{" + "serviceName='" + serviceName + '\'' + - ", serviceDescription='" + serviceDescription + '\'' + + ", serviceDesc='" + serviceDesc + '\'' + ", servicePrice=" + servicePrice + - ", serviceDurationMinutes=" + serviceDurationMinutes + - ", active=" + active + + ", serviceDuration=" + serviceDuration + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/service/ServiceResponse.java b/src/main/java/com/petshop/backend/dto/service/ServiceResponse.java index fd7e12ad..53a2be5b 100644 --- a/src/main/java/com/petshop/backend/dto/service/ServiceResponse.java +++ b/src/main/java/com/petshop/backend/dto/service/ServiceResponse.java @@ -5,35 +5,33 @@ import java.time.LocalDateTime; import java.util.Objects; public class ServiceResponse { - private Long id; + private Long serviceId; private String serviceName; - private String serviceDescription; + private String serviceDesc; private BigDecimal servicePrice; - private Integer serviceDurationMinutes; - private Boolean active; + private Integer serviceDuration; private LocalDateTime createdAt; private LocalDateTime updatedAt; public ServiceResponse() { } - public ServiceResponse(Long id, String serviceName, String serviceDescription, BigDecimal servicePrice, Integer serviceDurationMinutes, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public ServiceResponse(Long serviceId, String serviceName, String serviceDesc, BigDecimal servicePrice, Integer serviceDuration, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.serviceId = serviceId; this.serviceName = serviceName; - this.serviceDescription = serviceDescription; + this.serviceDesc = serviceDesc; this.servicePrice = servicePrice; - this.serviceDurationMinutes = serviceDurationMinutes; - this.active = active; + this.serviceDuration = serviceDuration; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getServiceId() { + return serviceId; } - public void setId(Long id) { - this.id = id; + public void setServiceId(Long serviceId) { + this.serviceId = serviceId; } public String getServiceName() { @@ -44,12 +42,12 @@ public class ServiceResponse { this.serviceName = serviceName; } - public String getServiceDescription() { - return serviceDescription; + public String getServiceDesc() { + return serviceDesc; } - public void setServiceDescription(String serviceDescription) { - this.serviceDescription = serviceDescription; + public void setServiceDesc(String serviceDesc) { + this.serviceDesc = serviceDesc; } public BigDecimal getServicePrice() { @@ -60,20 +58,12 @@ public class ServiceResponse { this.servicePrice = servicePrice; } - public Integer getServiceDurationMinutes() { - return serviceDurationMinutes; + public Integer getServiceDuration() { + return serviceDuration; } - public void setServiceDurationMinutes(Integer serviceDurationMinutes) { - this.serviceDurationMinutes = serviceDurationMinutes; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; + public void setServiceDuration(Integer serviceDuration) { + this.serviceDuration = serviceDuration; } public LocalDateTime getCreatedAt() { @@ -97,23 +87,22 @@ public class ServiceResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ServiceResponse that = (ServiceResponse) o; - return Objects.equals(id, that.id) && Objects.equals(serviceName, that.serviceName) && Objects.equals(serviceDescription, that.serviceDescription) && Objects.equals(servicePrice, that.servicePrice) && Objects.equals(serviceDurationMinutes, that.serviceDurationMinutes) && Objects.equals(active, that.active) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(serviceId, that.serviceId) && Objects.equals(serviceName, that.serviceName) && Objects.equals(serviceDesc, that.serviceDesc) && Objects.equals(servicePrice, that.servicePrice) && Objects.equals(serviceDuration, that.serviceDuration) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, serviceName, serviceDescription, servicePrice, serviceDurationMinutes, active, createdAt, updatedAt); + return Objects.hash(serviceId, serviceName, serviceDesc, servicePrice, serviceDuration, createdAt, updatedAt); } @Override public String toString() { return "ServiceResponse{" + - "id=" + id + + "serviceId=" + serviceId + ", serviceName='" + serviceName + '\'' + - ", serviceDescription='" + serviceDescription + '\'' + + ", serviceDesc='" + serviceDesc + '\'' + ", servicePrice=" + servicePrice + - ", serviceDurationMinutes=" + serviceDurationMinutes + - ", active=" + active + + ", serviceDuration=" + serviceDuration + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/dto/store/StoreResponse.java b/src/main/java/com/petshop/backend/dto/store/StoreResponse.java index 6af1e702..e6fd563e 100644 --- a/src/main/java/com/petshop/backend/dto/store/StoreResponse.java +++ b/src/main/java/com/petshop/backend/dto/store/StoreResponse.java @@ -4,27 +4,31 @@ import java.time.LocalDateTime; import java.util.Objects; public class StoreResponse { - private Long id; + private Long storeId; private String storeName; - private String storeLocation; + private String address; + private String phone; + private String email; private LocalDateTime createdAt; public StoreResponse() { } - public StoreResponse(Long id, String storeName, String storeLocation, LocalDateTime createdAt) { - this.id = id; + public StoreResponse(Long storeId, String storeName, String address, String phone, String email, LocalDateTime createdAt) { + this.storeId = storeId; this.storeName = storeName; - this.storeLocation = storeLocation; + this.address = address; + this.phone = phone; + this.email = email; this.createdAt = createdAt; } - public Long getId() { - return id; + public Long getStoreId() { + return storeId; } - public void setId(Long id) { - this.id = id; + public void setStoreId(Long storeId) { + this.storeId = storeId; } public String getStoreName() { @@ -35,12 +39,28 @@ public class StoreResponse { this.storeName = storeName; } - public String getStoreLocation() { - return storeLocation; + public String getAddress() { + return address; } - public void setStoreLocation(String storeLocation) { - this.storeLocation = storeLocation; + public void setAddress(String address) { + this.address = address; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; } public LocalDateTime getCreatedAt() { @@ -56,20 +76,22 @@ public class StoreResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StoreResponse that = (StoreResponse) o; - return Objects.equals(id, that.id) && Objects.equals(storeName, that.storeName) && Objects.equals(storeLocation, that.storeLocation) && Objects.equals(createdAt, that.createdAt); + return Objects.equals(storeId, that.storeId); } @Override public int hashCode() { - return Objects.hash(id, storeName, storeLocation, createdAt); + return Objects.hash(storeId); } @Override public String toString() { return "StoreResponse{" + - "id=" + id + + "storeId=" + storeId + ", storeName='" + storeName + '\'' + - ", storeLocation='" + storeLocation + '\'' + + ", address='" + address + '\'' + + ", phone='" + phone + '\'' + + ", email='" + email + '\'' + ", createdAt=" + createdAt + '}'; } diff --git a/src/main/java/com/petshop/backend/dto/supplier/SupplierRequest.java b/src/main/java/com/petshop/backend/dto/supplier/SupplierRequest.java index f7881ffa..b7ae7efb 100644 --- a/src/main/java/com/petshop/backend/dto/supplier/SupplierRequest.java +++ b/src/main/java/com/petshop/backend/dto/supplier/SupplierRequest.java @@ -5,32 +5,40 @@ import jakarta.validation.constraints.NotBlank; import java.util.Objects; public class SupplierRequest { - @NotBlank(message = "Supplier name is required") - private String supName; + @NotBlank(message = "Supplier company is required") + private String supCompany; - private String supContact; + private String supContactFirstName; + + private String supContactLastName; @Email(message = "Invalid email format") private String supEmail; private String supPhone; - private String supAddress; - private Boolean active = true; - public String getSupName() { - return supName; + public String getSupCompany() { + return supCompany; } - public void setSupName(String supName) { - this.supName = supName; + public void setSupCompany(String supCompany) { + this.supCompany = supCompany; } - public String getSupContact() { - return supContact; + public String getSupContactFirstName() { + return supContactFirstName; } - public void setSupContact(String supContact) { - this.supContact = supContact; + public void setSupContactFirstName(String supContactFirstName) { + this.supContactFirstName = supContactFirstName; + } + + public String getSupContactLastName() { + return supContactLastName; + } + + public void setSupContactLastName(String supContactLastName) { + this.supContactLastName = supContactLastName; } public String getSupEmail() { @@ -49,49 +57,31 @@ public class SupplierRequest { this.supPhone = supPhone; } - public String getSupAddress() { - return supAddress; - } - - public void setSupAddress(String supAddress) { - this.supAddress = supAddress; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SupplierRequest that = (SupplierRequest) o; - return Objects.equals(supName, that.supName) && - Objects.equals(supContact, that.supContact) && + return Objects.equals(supCompany, that.supCompany) && + Objects.equals(supContactFirstName, that.supContactFirstName) && + Objects.equals(supContactLastName, that.supContactLastName) && Objects.equals(supEmail, that.supEmail) && - Objects.equals(supPhone, that.supPhone) && - Objects.equals(supAddress, that.supAddress) && - Objects.equals(active, that.active); + Objects.equals(supPhone, that.supPhone); } @Override public int hashCode() { - return Objects.hash(supName, supContact, supEmail, supPhone, supAddress, active); + return Objects.hash(supCompany, supContactFirstName, supContactLastName, supEmail, supPhone); } @Override public String toString() { return "SupplierRequest{" + - "supName='" + supName + '\'' + - ", supContact='" + supContact + '\'' + + "supCompany='" + supCompany + '\'' + + ", supContactFirstName='" + supContactFirstName + '\'' + + ", supContactLastName='" + supContactLastName + '\'' + ", supEmail='" + supEmail + '\'' + ", supPhone='" + supPhone + '\'' + - ", supAddress='" + supAddress + '\'' + - ", active=" + active + '}'; } } diff --git a/src/main/java/com/petshop/backend/dto/supplier/SupplierResponse.java b/src/main/java/com/petshop/backend/dto/supplier/SupplierResponse.java index 348b7f81..d23b4a2b 100644 --- a/src/main/java/com/petshop/backend/dto/supplier/SupplierResponse.java +++ b/src/main/java/com/petshop/backend/dto/supplier/SupplierResponse.java @@ -4,85 +4,75 @@ import java.time.LocalDateTime; import java.util.Objects; public class SupplierResponse { - private Long id; - private String supplierName; - private String supplierContact; - private String supplierEmail; - private String supplierPhone; - private String supplierAddress; - private Boolean active; + private Long supId; + private String supCompany; + private String supContactFirstName; + private String supContactLastName; + private String supEmail; + private String supPhone; private LocalDateTime createdAt; private LocalDateTime updatedAt; public SupplierResponse() { } - public SupplierResponse(Long id, String supplierName, String supplierContact, String supplierEmail, String supplierPhone, String supplierAddress, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.supplierName = supplierName; - this.supplierContact = supplierContact; - this.supplierEmail = supplierEmail; - this.supplierPhone = supplierPhone; - this.supplierAddress = supplierAddress; - this.active = active; + public SupplierResponse(Long supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.supId = supId; + this.supCompany = supCompany; + this.supContactFirstName = supContactFirstName; + this.supContactLastName = supContactLastName; + this.supEmail = supEmail; + this.supPhone = supPhone; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getSupId() { + return supId; } - public void setId(Long id) { - this.id = id; + public void setSupId(Long supId) { + this.supId = supId; } - public String getSupplierName() { - return supplierName; + public String getSupCompany() { + return supCompany; } - public void setSupplierName(String supplierName) { - this.supplierName = supplierName; + public void setSupCompany(String supCompany) { + this.supCompany = supCompany; } - public String getSupplierContact() { - return supplierContact; + public String getSupContactFirstName() { + return supContactFirstName; } - public void setSupplierContact(String supplierContact) { - this.supplierContact = supplierContact; + public void setSupContactFirstName(String supContactFirstName) { + this.supContactFirstName = supContactFirstName; } - public String getSupplierEmail() { - return supplierEmail; + public String getSupContactLastName() { + return supContactLastName; } - public void setSupplierEmail(String supplierEmail) { - this.supplierEmail = supplierEmail; + public void setSupContactLastName(String supContactLastName) { + this.supContactLastName = supContactLastName; } - public String getSupplierPhone() { - return supplierPhone; + public String getSupEmail() { + return supEmail; } - public void setSupplierPhone(String supplierPhone) { - this.supplierPhone = supplierPhone; + public void setSupEmail(String supEmail) { + this.supEmail = supEmail; } - public String getSupplierAddress() { - return supplierAddress; + public String getSupPhone() { + return supPhone; } - public void setSupplierAddress(String supplierAddress) { - this.supplierAddress = supplierAddress; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; + public void setSupPhone(String supPhone) { + this.supPhone = supPhone; } public LocalDateTime getCreatedAt() { @@ -106,24 +96,23 @@ public class SupplierResponse { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SupplierResponse that = (SupplierResponse) o; - return Objects.equals(id, that.id) && Objects.equals(supplierName, that.supplierName) && Objects.equals(supplierContact, that.supplierContact) && Objects.equals(supplierEmail, that.supplierEmail) && Objects.equals(supplierPhone, that.supplierPhone) && Objects.equals(supplierAddress, that.supplierAddress) && Objects.equals(active, that.active) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); + return Objects.equals(supId, that.supId) && Objects.equals(supCompany, that.supCompany) && Objects.equals(supContactFirstName, that.supContactFirstName) && Objects.equals(supContactLastName, that.supContactLastName) && Objects.equals(supEmail, that.supEmail) && Objects.equals(supPhone, that.supPhone) && Objects.equals(createdAt, that.createdAt) && Objects.equals(updatedAt, that.updatedAt); } @Override public int hashCode() { - return Objects.hash(id, supplierName, supplierContact, supplierEmail, supplierPhone, supplierAddress, active, createdAt, updatedAt); + return Objects.hash(supId, supCompany, supContactFirstName, supContactLastName, supEmail, supPhone, createdAt, updatedAt); } @Override public String toString() { return "SupplierResponse{" + - "id=" + id + - ", supplierName='" + supplierName + '\'' + - ", supplierContact='" + supplierContact + '\'' + - ", supplierEmail='" + supplierEmail + '\'' + - ", supplierPhone='" + supplierPhone + '\'' + - ", supplierAddress='" + supplierAddress + '\'' + - ", active=" + active + + "supId=" + supId + + ", supCompany='" + supCompany + '\'' + + ", supContactFirstName='" + supContactFirstName + '\'' + + ", supContactLastName='" + supContactLastName + '\'' + + ", supEmail='" + supEmail + '\'' + + ", supPhone='" + supPhone + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/ActivityLog.java b/src/main/java/com/petshop/backend/entity/ActivityLog.java new file mode 100644 index 00000000..211f75de --- /dev/null +++ b/src/main/java/com/petshop/backend/entity/ActivityLog.java @@ -0,0 +1,90 @@ +package com.petshop.backend.entity; + +import jakarta.persistence.*; + +import java.time.LocalDateTime; +import java.util.Objects; + +@Entity +@Table(name = "activityLog") +public class ActivityLog { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long logId; + + @ManyToOne + @JoinColumn(name = "employeeId", nullable = false) + private Employee employee; + + @Column(nullable = false, columnDefinition = "TEXT") + private String activity; + + @Column(nullable = false) + private LocalDateTime logTimestamp = LocalDateTime.now(); + + public ActivityLog() { + } + + public ActivityLog(Long logId, Employee employee, String activity, LocalDateTime logTimestamp) { + this.logId = logId; + this.employee = employee; + this.activity = activity; + this.logTimestamp = logTimestamp; + } + + public Long getLogId() { + return logId; + } + + public void setLogId(Long logId) { + this.logId = logId; + } + + public Employee getEmployee() { + return employee; + } + + public void setEmployee(Employee employee) { + this.employee = employee; + } + + public String getActivity() { + return activity; + } + + public void setActivity(String activity) { + this.activity = activity; + } + + public LocalDateTime getLogTimestamp() { + return logTimestamp; + } + + public void setLogTimestamp(LocalDateTime logTimestamp) { + this.logTimestamp = logTimestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ActivityLog that = (ActivityLog) o; + return Objects.equals(logId, that.logId); + } + + @Override + public int hashCode() { + return Objects.hash(logId); + } + + @Override + public String toString() { + return "ActivityLog{" + + "logId=" + logId + + ", employee=" + employee + + ", activity='" + activity + '\'' + + ", logTimestamp=" + logTimestamp + + '}'; + } +} diff --git a/src/main/java/com/petshop/backend/entity/Adoption.java b/src/main/java/com/petshop/backend/entity/Adoption.java index da005d5f..84912ba9 100644 --- a/src/main/java/com/petshop/backend/entity/Adoption.java +++ b/src/main/java/com/petshop/backend/entity/Adoption.java @@ -10,29 +10,26 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "adoptions") +@Table(name = "adoption") public class Adoption { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long adoptionId; @ManyToOne - @JoinColumn(name = "pet_id", nullable = false) + @JoinColumn(name = "petId", nullable = false) private Pet pet; @ManyToOne - @JoinColumn(name = "customer_id", nullable = false) + @JoinColumn(name = "customerId", nullable = false) private Customer customer; - @Column(name = "adoption_date", nullable = false) + @Column(nullable = false) private LocalDate adoptionDate; - @Column(name = "adoption_fee", nullable = false, precision = 10, scale = 2) - private BigDecimal adoptionFee; - - @Column(columnDefinition = "TEXT") - private String notes; + @Column(nullable = false, length = 20) + private String adoptionStatus; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -45,23 +42,22 @@ public class Adoption { public Adoption() { } - public Adoption(Long id, Pet pet, Customer customer, LocalDate adoptionDate, BigDecimal adoptionFee, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public Adoption(Long adoptionId, Pet pet, Customer customer, LocalDate adoptionDate, String adoptionStatus, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.adoptionId = adoptionId; this.pet = pet; this.customer = customer; this.adoptionDate = adoptionDate; - this.adoptionFee = adoptionFee; - this.notes = notes; + this.adoptionStatus = adoptionStatus; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getAdoptionId() { + return adoptionId; } - public void setId(Long id) { - this.id = id; + public void setAdoptionId(Long adoptionId) { + this.adoptionId = adoptionId; } public Pet getPet() { @@ -88,20 +84,12 @@ public class Adoption { this.adoptionDate = adoptionDate; } - public BigDecimal getAdoptionFee() { - return adoptionFee; + public String getAdoptionStatus() { + return adoptionStatus; } - public void setAdoptionFee(BigDecimal adoptionFee) { - this.adoptionFee = adoptionFee; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; + public void setAdoptionStatus(String adoptionStatus) { + this.adoptionStatus = adoptionStatus; } public LocalDateTime getCreatedAt() { @@ -125,23 +113,22 @@ public class Adoption { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Adoption adoption = (Adoption) o; - return Objects.equals(id, adoption.id); + return Objects.equals(adoptionId, adoption.adoptionId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(adoptionId); } @Override public String toString() { return "Adoption{" + - "id=" + id + + "adoptionId=" + adoptionId + ", pet=" + pet + ", customer=" + customer + ", adoptionDate=" + adoptionDate + - ", adoptionFee=" + adoptionFee + - ", notes='" + notes + '\'' + + ", adoptionStatus='" + adoptionStatus + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/Appointment.java b/src/main/java/com/petshop/backend/entity/Appointment.java index 358c137b..c31a94ff 100644 --- a/src/main/java/com/petshop/backend/entity/Appointment.java +++ b/src/main/java/com/petshop/backend/entity/Appointment.java @@ -12,39 +12,35 @@ import java.util.Objects; import java.util.Set; @Entity -@Table(name = "appointments") +@Table(name = "appointment") public class Appointment { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long appointmentId; @ManyToOne - @JoinColumn(name = "customer_id", nullable = false) + @JoinColumn(name = "customerId", nullable = false) private Customer customer; @ManyToOne - @JoinColumn(name = "service_id", nullable = false) + @JoinColumn(name = "serviceId", nullable = false) private Service service; - @Column(name = "appointment_date", nullable = false) + @Column(nullable = false) private LocalDate appointmentDate; - @Column(name = "appointment_time", nullable = false) + @Column(nullable = false) private LocalTime appointmentTime; - @Enumerated(EnumType.STRING) - @Column(nullable = false) - private AppointmentStatus status = AppointmentStatus.Scheduled; - - @Column(columnDefinition = "TEXT") - private String notes; + @Column(nullable = false, length = 20) + private String appointmentStatus; @ManyToMany @JoinTable( - name = "appointment_pets", - joinColumns = @JoinColumn(name = "appointment_id"), - inverseJoinColumns = @JoinColumn(name = "pet_id") + name = "appointmentPet", + joinColumns = @JoinColumn(name = "appointmentId"), + inverseJoinColumns = @JoinColumn(name = "petId") ) private Set pets = new HashSet<>(); @@ -56,32 +52,27 @@ public class Appointment { @Column(name = "updated_at") private LocalDateTime updatedAt; - public enum AppointmentStatus { - Scheduled, Completed, Cancelled - } - public Appointment() { } - public Appointment(Long id, Customer customer, Service service, LocalDate appointmentDate, LocalTime appointmentTime, AppointmentStatus status, String notes, Set pets, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public Appointment(Long appointmentId, Customer customer, Service service, LocalDate appointmentDate, LocalTime appointmentTime, String appointmentStatus, Set pets, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.appointmentId = appointmentId; this.customer = customer; this.service = service; this.appointmentDate = appointmentDate; this.appointmentTime = appointmentTime; - this.status = status; - this.notes = notes; + this.appointmentStatus = appointmentStatus; this.pets = pets; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getAppointmentId() { + return appointmentId; } - public void setId(Long id) { - this.id = id; + public void setAppointmentId(Long appointmentId) { + this.appointmentId = appointmentId; } public Customer getCustomer() { @@ -116,20 +107,12 @@ public class Appointment { this.appointmentTime = appointmentTime; } - public AppointmentStatus getStatus() { - return status; + public String getAppointmentStatus() { + return appointmentStatus; } - public void setStatus(AppointmentStatus status) { - this.status = status; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; + public void setAppointmentStatus(String appointmentStatus) { + this.appointmentStatus = appointmentStatus; } public Set getPets() { @@ -161,24 +144,23 @@ public class Appointment { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Appointment that = (Appointment) o; - return Objects.equals(id, that.id); + return Objects.equals(appointmentId, that.appointmentId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(appointmentId); } @Override public String toString() { return "Appointment{" + - "id=" + id + + "appointmentId=" + appointmentId + ", customer=" + customer + ", service=" + service + ", appointmentDate=" + appointmentDate + ", appointmentTime=" + appointmentTime + - ", status=" + status + - ", notes='" + notes + '\'' + + ", appointmentStatus='" + appointmentStatus + '\'' + ", pets=" + pets + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + diff --git a/src/main/java/com/petshop/backend/entity/Category.java b/src/main/java/com/petshop/backend/entity/Category.java index 47a9963a..ee79207e 100644 --- a/src/main/java/com/petshop/backend/entity/Category.java +++ b/src/main/java/com/petshop/backend/entity/Category.java @@ -8,18 +8,18 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "categories") +@Table(name = "category") public class Category { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long categoryId; - @Column(name = "category_name", nullable = false, unique = true, length = 100) + @Column(nullable = false, length = 100) private String categoryName; - @Column(name = "category_description", columnDefinition = "TEXT") - private String categoryDescription; + @Column(nullable = false, length = 50) + private String categoryType; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -32,20 +32,20 @@ public class Category { public Category() { } - public Category(Long id, String categoryName, String categoryDescription, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public Category(Long categoryId, String categoryName, String categoryType, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.categoryId = categoryId; this.categoryName = categoryName; - this.categoryDescription = categoryDescription; + this.categoryType = categoryType; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getCategoryId() { + return categoryId; } - public void setId(Long id) { - this.id = id; + public void setCategoryId(Long categoryId) { + this.categoryId = categoryId; } public String getCategoryName() { @@ -56,12 +56,12 @@ public class Category { this.categoryName = categoryName; } - public String getCategoryDescription() { - return categoryDescription; + public String getCategoryType() { + return categoryType; } - public void setCategoryDescription(String categoryDescription) { - this.categoryDescription = categoryDescription; + public void setCategoryType(String categoryType) { + this.categoryType = categoryType; } public LocalDateTime getCreatedAt() { @@ -85,20 +85,20 @@ public class Category { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Category category = (Category) o; - return Objects.equals(id, category.id); + return Objects.equals(categoryId, category.categoryId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(categoryId); } @Override public String toString() { return "Category{" + - "id=" + id + + "categoryId=" + categoryId + ", categoryName='" + categoryName + '\'' + - ", categoryDescription='" + categoryDescription + '\'' + + ", categoryType='" + categoryType + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/Customer.java b/src/main/java/com/petshop/backend/entity/Customer.java index b0b319a6..661f9d80 100644 --- a/src/main/java/com/petshop/backend/entity/Customer.java +++ b/src/main/java/com/petshop/backend/entity/Customer.java @@ -8,24 +8,24 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "customers") +@Table(name = "customer") public class Customer { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long customerId; - @Column(name = "customer_name", nullable = false, length = 100) - private String customerName; + @Column(nullable = false, length = 50) + private String firstName; - @Column(name = "customer_email", length = 100) - private String customerEmail; + @Column(nullable = false, length = 50) + private String lastName; - @Column(name = "customer_phone", length = 20) - private String customerPhone; + @Column(nullable = false, length = 100) + private String email; - @Column(name = "customer_address", columnDefinition = "TEXT") - private String customerAddress; + @Column(nullable = false, length = 20) + private String phone; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -38,54 +38,54 @@ public class Customer { public Customer() { } - public Customer(Long id, String customerName, String customerEmail, String customerPhone, String customerAddress, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.customerName = customerName; - this.customerEmail = customerEmail; - this.customerPhone = customerPhone; - this.customerAddress = customerAddress; + public Customer(Long customerId, String firstName, String lastName, String email, String phone, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.customerId = customerId; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.phone = phone; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getCustomerId() { + return customerId; } - public void setId(Long id) { - this.id = id; + public void setCustomerId(Long customerId) { + this.customerId = customerId; } - public String getCustomerName() { - return customerName; + public String getFirstName() { + return firstName; } - public void setCustomerName(String customerName) { - this.customerName = customerName; + public void setFirstName(String firstName) { + this.firstName = firstName; } - public String getCustomerEmail() { - return customerEmail; + public String getLastName() { + return lastName; } - public void setCustomerEmail(String customerEmail) { - this.customerEmail = customerEmail; + public void setLastName(String lastName) { + this.lastName = lastName; } - public String getCustomerPhone() { - return customerPhone; + public String getEmail() { + return email; } - public void setCustomerPhone(String customerPhone) { - this.customerPhone = customerPhone; + public void setEmail(String email) { + this.email = email; } - public String getCustomerAddress() { - return customerAddress; + public String getPhone() { + return phone; } - public void setCustomerAddress(String customerAddress) { - this.customerAddress = customerAddress; + public void setPhone(String phone) { + this.phone = phone; } public LocalDateTime getCreatedAt() { @@ -109,22 +109,22 @@ public class Customer { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Customer customer = (Customer) o; - return Objects.equals(id, customer.id); + return Objects.equals(customerId, customer.customerId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(customerId); } @Override public String toString() { return "Customer{" + - "id=" + id + - ", customerName='" + customerName + '\'' + - ", customerEmail='" + customerEmail + '\'' + - ", customerPhone='" + customerPhone + '\'' + - ", customerAddress='" + customerAddress + '\'' + + "customerId=" + customerId + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", email='" + email + '\'' + + ", phone='" + phone + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/Employee.java b/src/main/java/com/petshop/backend/entity/Employee.java new file mode 100644 index 00000000..573a446f --- /dev/null +++ b/src/main/java/com/petshop/backend/entity/Employee.java @@ -0,0 +1,158 @@ +package com.petshop.backend.entity; + +import jakarta.persistence.*; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; + +import java.time.LocalDateTime; +import java.util.Objects; + +@Entity +@Table(name = "employee") +public class Employee { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long employeeId; + + @Column(nullable = false, length = 50) + private String firstName; + + @Column(nullable = false, length = 50) + private String lastName; + + @Column(nullable = false, length = 100) + private String email; + + @Column(nullable = false, length = 20) + private String phone; + + @Column(nullable = false, length = 50) + private String role; + + @Column(nullable = false) + private Boolean isActive = true; + + @CreationTimestamp + @Column(name = "created_at", updatable = false) + private LocalDateTime createdAt; + + @UpdateTimestamp + @Column(name = "updated_at") + private LocalDateTime updatedAt; + + public Employee() { + } + + public Employee(Long employeeId, String firstName, String lastName, String email, String phone, String role, Boolean isActive, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.employeeId = employeeId; + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.phone = phone; + this.role = role; + this.isActive = isActive; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public Long getEmployeeId() { + return employeeId; + } + + public void setEmployeeId(Long employeeId) { + this.employeeId = employeeId; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(LocalDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Employee employee = (Employee) o; + return Objects.equals(employeeId, employee.employeeId); + } + + @Override + public int hashCode() { + return Objects.hash(employeeId); + } + + @Override + public String toString() { + return "Employee{" + + "employeeId=" + employeeId + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", email='" + email + '\'' + + ", phone='" + phone + '\'' + + ", role='" + role + '\'' + + ", isActive=" + isActive + + ", createdAt=" + createdAt + + ", updatedAt=" + updatedAt + + '}'; + } +} diff --git a/src/main/java/com/petshop/backend/entity/EmployeeStore.java b/src/main/java/com/petshop/backend/entity/EmployeeStore.java new file mode 100644 index 00000000..daa2a2e2 --- /dev/null +++ b/src/main/java/com/petshop/backend/entity/EmployeeStore.java @@ -0,0 +1,117 @@ +package com.petshop.backend.entity; + +import jakarta.persistence.*; + +import java.io.Serializable; +import java.util.Objects; + +@Entity +@Table(name = "employeeStore") +@IdClass(EmployeeStore.EmployeeStoreId.class) +public class EmployeeStore { + + @Id + @ManyToOne + @JoinColumn(name = "employeeId", nullable = false) + private Employee employee; + + @Id + @ManyToOne + @JoinColumn(name = "storeId", nullable = false) + private StoreLocation store; + + public EmployeeStore() { + } + + public EmployeeStore(Employee employee, StoreLocation store) { + this.employee = employee; + this.store = store; + } + + public Employee getEmployee() { + return employee; + } + + public void setEmployee(Employee employee) { + this.employee = employee; + } + + public StoreLocation getStore() { + return store; + } + + public void setStore(StoreLocation store) { + this.store = store; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EmployeeStore that = (EmployeeStore) o; + return Objects.equals(employee, that.employee) && Objects.equals(store, that.store); + } + + @Override + public int hashCode() { + return Objects.hash(employee, store); + } + + @Override + public String toString() { + return "EmployeeStore{" + + "employee=" + employee + + ", store=" + store + + '}'; + } + + public static class EmployeeStoreId implements Serializable { + private Long employee; + private Long store; + + public EmployeeStoreId() { + } + + public EmployeeStoreId(Long employee, Long store) { + this.employee = employee; + this.store = store; + } + + public Long getEmployee() { + return employee; + } + + public void setEmployee(Long employee) { + this.employee = employee; + } + + public Long getStore() { + return store; + } + + public void setStore(Long store) { + this.store = store; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EmployeeStoreId that = (EmployeeStoreId) o; + return Objects.equals(employee, that.employee) && Objects.equals(store, that.store); + } + + @Override + public int hashCode() { + return Objects.hash(employee, store); + } + + @Override + public String toString() { + return "EmployeeStoreId{" + + "employee=" + employee + + ", store=" + store + + '}'; + } + } +} diff --git a/src/main/java/com/petshop/backend/entity/Inventory.java b/src/main/java/com/petshop/backend/entity/Inventory.java index 4b167c91..07b93501 100644 --- a/src/main/java/com/petshop/backend/entity/Inventory.java +++ b/src/main/java/com/petshop/backend/entity/Inventory.java @@ -8,32 +8,20 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "inventory", uniqueConstraints = { - @UniqueConstraint(name = "unique_product_store", columnNames = {"product_id", "store_id"}) -}) +@Table(name = "inventory") public class Inventory { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long inventoryId; @ManyToOne - @JoinColumn(name = "product_id", nullable = false) + @JoinColumn(name = "prodId", nullable = false) private Product product; - @ManyToOne - @JoinColumn(name = "store_id", nullable = true) - private Store store; - @Column(nullable = false) private Integer quantity = 0; - @Column(name = "reorder_level") - private Integer reorderLevel = 10; - - @Column(name = "last_restocked") - private LocalDateTime lastRestocked; - @CreationTimestamp @Column(name = "created_at", updatable = false) private LocalDateTime createdAt; @@ -45,23 +33,20 @@ public class Inventory { public Inventory() { } - public Inventory(Long id, Product product, Store store, Integer quantity, Integer reorderLevel, LocalDateTime lastRestocked, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public Inventory(Long inventoryId, Product product, Integer quantity, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.inventoryId = inventoryId; this.product = product; - this.store = store; this.quantity = quantity; - this.reorderLevel = reorderLevel; - this.lastRestocked = lastRestocked; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getInventoryId() { + return inventoryId; } - public void setId(Long id) { - this.id = id; + public void setInventoryId(Long inventoryId) { + this.inventoryId = inventoryId; } public Product getProduct() { @@ -72,14 +57,6 @@ public class Inventory { this.product = product; } - public Store getStore() { - return store; - } - - public void setStore(Store store) { - this.store = store; - } - public Integer getQuantity() { return quantity; } @@ -88,22 +65,6 @@ public class Inventory { this.quantity = quantity; } - public Integer getReorderLevel() { - return reorderLevel; - } - - public void setReorderLevel(Integer reorderLevel) { - this.reorderLevel = reorderLevel; - } - - public LocalDateTime getLastRestocked() { - return lastRestocked; - } - - public void setLastRestocked(LocalDateTime lastRestocked) { - this.lastRestocked = lastRestocked; - } - public LocalDateTime getCreatedAt() { return createdAt; } @@ -125,23 +86,20 @@ public class Inventory { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Inventory inventory = (Inventory) o; - return Objects.equals(id, inventory.id); + return Objects.equals(inventoryId, inventory.inventoryId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(inventoryId); } @Override public String toString() { return "Inventory{" + - "id=" + id + + "inventoryId=" + inventoryId + ", product=" + product + - ", store=" + store + ", quantity=" + quantity + - ", reorderLevel=" + reorderLevel + - ", lastRestocked=" + lastRestocked + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/Pet.java b/src/main/java/com/petshop/backend/entity/Pet.java index 61abe2c0..cbbb1f90 100644 --- a/src/main/java/com/petshop/backend/entity/Pet.java +++ b/src/main/java/com/petshop/backend/entity/Pet.java @@ -9,30 +9,29 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "pets") +@Table(name = "pet") public class Pet { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long petId; - @Column(name = "pet_name", nullable = false, length = 100) + @Column(nullable = false, length = 50) private String petName; - @Column(name = "pet_species", nullable = false, length = 50) + @Column(nullable = false, length = 50) private String petSpecies; - @Column(name = "pet_breed", length = 50) + @Column(nullable = false, length = 50) private String petBreed; - @Column(name = "pet_age") + @Column(nullable = false) private Integer petAge; - @Enumerated(EnumType.STRING) - @Column(name = "pet_status", nullable = false) - private PetStatus petStatus = PetStatus.AVAILABLE; + @Column(nullable = false, length = 20) + private String petStatus; - @Column(name = "pet_price", precision = 10, scale = 2) + @Column(nullable = false, precision = 10, scale = 2) private BigDecimal petPrice; @CreationTimestamp @@ -43,15 +42,11 @@ public class Pet { @Column(name = "updated_at") private LocalDateTime updatedAt; - public enum PetStatus { - AVAILABLE, ADOPTED, UNDER_CARE - } - public Pet() { } - public Pet(Long id, String petName, String petSpecies, String petBreed, Integer petAge, PetStatus petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public Pet(Long petId, String petName, String petSpecies, String petBreed, Integer petAge, String petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.petId = petId; this.petName = petName; this.petSpecies = petSpecies; this.petBreed = petBreed; @@ -62,12 +57,12 @@ public class Pet { this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getPetId() { + return petId; } - public void setId(Long id) { - this.id = id; + public void setPetId(Long petId) { + this.petId = petId; } public String getPetName() { @@ -102,11 +97,11 @@ public class Pet { this.petAge = petAge; } - public PetStatus getPetStatus() { + public String getPetStatus() { return petStatus; } - public void setPetStatus(PetStatus petStatus) { + public void setPetStatus(String petStatus) { this.petStatus = petStatus; } @@ -139,23 +134,23 @@ public class Pet { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Pet pet = (Pet) o; - return Objects.equals(id, pet.id); + return Objects.equals(petId, pet.petId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(petId); } @Override public String toString() { return "Pet{" + - "id=" + id + + "petId=" + petId + ", petName='" + petName + '\'' + ", petSpecies='" + petSpecies + '\'' + ", petBreed='" + petBreed + '\'' + ", petAge=" + petAge + - ", petStatus=" + petStatus + + ", petStatus='" + petStatus + '\'' + ", petPrice=" + petPrice + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + diff --git a/src/main/java/com/petshop/backend/entity/Product.java b/src/main/java/com/petshop/backend/entity/Product.java index 2a3e0dd9..9eb9c2d6 100644 --- a/src/main/java/com/petshop/backend/entity/Product.java +++ b/src/main/java/com/petshop/backend/entity/Product.java @@ -9,28 +9,25 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "products") +@Table(name = "product") public class Product { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long prodId; - @Column(name = "product_name", nullable = false, length = 100) - private String productName; + @Column(nullable = false, length = 100) + private String prodName; @ManyToOne - @JoinColumn(name = "category_id", nullable = false) + @JoinColumn(name = "categoryId", nullable = false) private Category category; - @Column(name = "product_description", columnDefinition = "TEXT") - private String productDescription; + @Column(columnDefinition = "TEXT") + private String prodDesc; - @Column(name = "product_price", nullable = false, precision = 10, scale = 2) - private BigDecimal productPrice; - - @Column(nullable = false) - private Boolean active = true; + @Column(nullable = false, precision = 10, scale = 2) + private BigDecimal prodPrice; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -43,31 +40,30 @@ public class Product { public Product() { } - public Product(Long id, String productName, Category category, String productDescription, BigDecimal productPrice, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.productName = productName; + public Product(Long prodId, String prodName, Category category, String prodDesc, BigDecimal prodPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.prodId = prodId; + this.prodName = prodName; this.category = category; - this.productDescription = productDescription; - this.productPrice = productPrice; - this.active = active; + this.prodDesc = prodDesc; + this.prodPrice = prodPrice; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getProdId() { + return prodId; } - public void setId(Long id) { - this.id = id; + public void setProdId(Long prodId) { + this.prodId = prodId; } - public String getProductName() { - return productName; + public String getProdName() { + return prodName; } - public void setProductName(String productName) { - this.productName = productName; + public void setProdName(String prodName) { + this.prodName = prodName; } public Category getCategory() { @@ -78,28 +74,20 @@ public class Product { this.category = category; } - public String getProductDescription() { - return productDescription; + public String getProdDesc() { + return prodDesc; } - public void setProductDescription(String productDescription) { - this.productDescription = productDescription; + public void setProdDesc(String prodDesc) { + this.prodDesc = prodDesc; } - public BigDecimal getProductPrice() { - return productPrice; + public BigDecimal getProdPrice() { + return prodPrice; } - public void setProductPrice(BigDecimal productPrice) { - this.productPrice = productPrice; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; + public void setProdPrice(BigDecimal prodPrice) { + this.prodPrice = prodPrice; } public LocalDateTime getCreatedAt() { @@ -123,23 +111,22 @@ public class Product { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Product product = (Product) o; - return Objects.equals(id, product.id); + return Objects.equals(prodId, product.prodId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(prodId); } @Override public String toString() { return "Product{" + - "id=" + id + - ", productName='" + productName + '\'' + + "prodId=" + prodId + + ", prodName='" + prodName + '\'' + ", category=" + category + - ", productDescription='" + productDescription + '\'' + - ", productPrice=" + productPrice + - ", active=" + active + + ", prodDesc='" + prodDesc + '\'' + + ", prodPrice=" + prodPrice + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/ProductSupplier.java b/src/main/java/com/petshop/backend/entity/ProductSupplier.java index b9758404..95aa6017 100644 --- a/src/main/java/com/petshop/backend/entity/ProductSupplier.java +++ b/src/main/java/com/petshop/backend/entity/ProductSupplier.java @@ -10,28 +10,22 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "product_suppliers") +@Table(name = "productSupplier") @IdClass(ProductSupplier.ProductSupplierId.class) public class ProductSupplier { @Id @ManyToOne - @JoinColumn(name = "product_id", nullable = false) + @JoinColumn(name = "prodId", nullable = false) private Product product; @Id @ManyToOne - @JoinColumn(name = "supplier_id", nullable = false) + @JoinColumn(name = "supId", nullable = false) private Supplier supplier; - @Column(name = "cost_price", nullable = false, precision = 10, scale = 2) - private BigDecimal costPrice; - - @Column(name = "lead_time_days") - private Integer leadTimeDays; - - @Column(name = "is_preferred") - private Boolean isPreferred = false; + @Column(nullable = false, precision = 10, scale = 2) + private BigDecimal cost; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -44,12 +38,10 @@ public class ProductSupplier { public ProductSupplier() { } - public ProductSupplier(Product product, Supplier supplier, BigDecimal costPrice, Integer leadTimeDays, Boolean isPreferred, LocalDateTime createdAt, LocalDateTime updatedAt) { + public ProductSupplier(Product product, Supplier supplier, BigDecimal cost, LocalDateTime createdAt, LocalDateTime updatedAt) { this.product = product; this.supplier = supplier; - this.costPrice = costPrice; - this.leadTimeDays = leadTimeDays; - this.isPreferred = isPreferred; + this.cost = cost; this.createdAt = createdAt; this.updatedAt = updatedAt; } @@ -70,28 +62,12 @@ public class ProductSupplier { this.supplier = supplier; } - public BigDecimal getCostPrice() { - return costPrice; + public BigDecimal getCost() { + return cost; } - public void setCostPrice(BigDecimal costPrice) { - this.costPrice = costPrice; - } - - public Integer getLeadTimeDays() { - return leadTimeDays; - } - - public void setLeadTimeDays(Integer leadTimeDays) { - this.leadTimeDays = leadTimeDays; - } - - public Boolean getIsPreferred() { - return isPreferred; - } - - public void setIsPreferred(Boolean isPreferred) { - this.isPreferred = isPreferred; + public void setCost(BigDecimal cost) { + this.cost = cost; } public LocalDateTime getCreatedAt() { @@ -128,9 +104,7 @@ public class ProductSupplier { return "ProductSupplier{" + "product=" + product + ", supplier=" + supplier + - ", costPrice=" + costPrice + - ", leadTimeDays=" + leadTimeDays + - ", isPreferred=" + isPreferred + + ", cost=" + cost + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/PurchaseOrder.java b/src/main/java/com/petshop/backend/entity/PurchaseOrder.java index 3a63683f..76fc9a9d 100644 --- a/src/main/java/com/petshop/backend/entity/PurchaseOrder.java +++ b/src/main/java/com/petshop/backend/entity/PurchaseOrder.java @@ -12,35 +12,22 @@ import java.util.List; import java.util.Objects; @Entity -@Table(name = "purchase_orders") +@Table(name = "purchaseOrder") public class PurchaseOrder { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long purchaseOrderId; @ManyToOne - @JoinColumn(name = "supplier_id", nullable = false) + @JoinColumn(name = "supId", nullable = false) private Supplier supplier; - @Column(name = "order_date", nullable = false) + @Column(nullable = false) private LocalDate orderDate; - @Column(name = "expected_delivery") - private LocalDate expectedDelivery; - - @Enumerated(EnumType.STRING) - @Column(nullable = false) - private OrderStatus status = OrderStatus.Pending; - - @Column(name = "total_amount", nullable = false, precision = 10, scale = 2) - private BigDecimal totalAmount; - - @Column(columnDefinition = "TEXT") - private String notes; - - @OneToMany(mappedBy = "purchaseOrder", cascade = CascadeType.ALL) - private List items = new ArrayList<>(); + @Column(nullable = false, length = 50) + private String status; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -50,32 +37,24 @@ public class PurchaseOrder { @Column(name = "updated_at") private LocalDateTime updatedAt; - public enum OrderStatus { - Pending, Delivered, Cancelled - } - public PurchaseOrder() { } - public PurchaseOrder(Long id, Supplier supplier, LocalDate orderDate, LocalDate expectedDelivery, OrderStatus status, BigDecimal totalAmount, String notes, List items, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public PurchaseOrder(Long purchaseOrderId, Supplier supplier, LocalDate orderDate, String status, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.purchaseOrderId = purchaseOrderId; this.supplier = supplier; this.orderDate = orderDate; - this.expectedDelivery = expectedDelivery; this.status = status; - this.totalAmount = totalAmount; - this.notes = notes; - this.items = items; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getPurchaseOrderId() { + return purchaseOrderId; } - public void setId(Long id) { - this.id = id; + public void setPurchaseOrderId(Long purchaseOrderId) { + this.purchaseOrderId = purchaseOrderId; } public Supplier getSupplier() { @@ -94,46 +73,14 @@ public class PurchaseOrder { this.orderDate = orderDate; } - public LocalDate getExpectedDelivery() { - return expectedDelivery; - } - - public void setExpectedDelivery(LocalDate expectedDelivery) { - this.expectedDelivery = expectedDelivery; - } - - public OrderStatus getStatus() { + public String getStatus() { return status; } - public void setStatus(OrderStatus status) { + public void setStatus(String status) { this.status = status; } - public BigDecimal getTotalAmount() { - return totalAmount; - } - - public void setTotalAmount(BigDecimal totalAmount) { - this.totalAmount = totalAmount; - } - - public String getNotes() { - return notes; - } - - public void setNotes(String notes) { - this.notes = notes; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - public LocalDateTime getCreatedAt() { return createdAt; } @@ -155,25 +102,21 @@ public class PurchaseOrder { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PurchaseOrder that = (PurchaseOrder) o; - return Objects.equals(id, that.id); + return Objects.equals(purchaseOrderId, that.purchaseOrderId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(purchaseOrderId); } @Override public String toString() { return "PurchaseOrder{" + - "id=" + id + + "purchaseOrderId=" + purchaseOrderId + ", supplier=" + supplier + ", orderDate=" + orderDate + - ", expectedDelivery=" + expectedDelivery + - ", status=" + status + - ", totalAmount=" + totalAmount + - ", notes='" + notes + '\'' + - ", items=" + items + + ", status='" + status + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/PurchaseOrderItem.java b/src/main/java/com/petshop/backend/entity/PurchaseOrderItem.java deleted file mode 100644 index 6278d3f9..00000000 --- a/src/main/java/com/petshop/backend/entity/PurchaseOrderItem.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.petshop.backend.entity; - -import jakarta.persistence.*; - -import java.math.BigDecimal; -import java.util.Objects; - -@Entity -@Table(name = "purchase_order_items") -public class PurchaseOrderItem { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne - @JoinColumn(name = "purchase_order_id", nullable = false) - private PurchaseOrder purchaseOrder; - - @ManyToOne - @JoinColumn(name = "product_id", nullable = false) - private Product product; - - @Column(nullable = false) - private Integer quantity; - - @Column(name = "unit_cost", nullable = false, precision = 10, scale = 2) - private BigDecimal unitCost; - - @Column(nullable = false, precision = 10, scale = 2) - private BigDecimal subtotal; - - public PurchaseOrderItem() { - } - - public PurchaseOrderItem(Long id, PurchaseOrder purchaseOrder, Product product, Integer quantity, BigDecimal unitCost, BigDecimal subtotal) { - this.id = id; - this.purchaseOrder = purchaseOrder; - this.product = product; - this.quantity = quantity; - this.unitCost = unitCost; - this.subtotal = subtotal; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public PurchaseOrder getPurchaseOrder() { - return purchaseOrder; - } - - public void setPurchaseOrder(PurchaseOrder purchaseOrder) { - this.purchaseOrder = purchaseOrder; - } - - public Product getProduct() { - return product; - } - - public void setProduct(Product product) { - this.product = product; - } - - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - public BigDecimal getUnitCost() { - return unitCost; - } - - public void setUnitCost(BigDecimal unitCost) { - this.unitCost = unitCost; - } - - public BigDecimal getSubtotal() { - return subtotal; - } - - public void setSubtotal(BigDecimal subtotal) { - this.subtotal = subtotal; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PurchaseOrderItem that = (PurchaseOrderItem) o; - return Objects.equals(id, that.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - return "PurchaseOrderItem{" + - "id=" + id + - ", purchaseOrder=" + purchaseOrder + - ", product=" + product + - ", quantity=" + quantity + - ", unitCost=" + unitCost + - ", subtotal=" + subtotal + - '}'; - } -} diff --git a/src/main/java/com/petshop/backend/entity/Refund.java b/src/main/java/com/petshop/backend/entity/Refund.java deleted file mode 100644 index 8fe89c9a..00000000 --- a/src/main/java/com/petshop/backend/entity/Refund.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.petshop.backend.entity; - -import jakarta.persistence.*; -import org.hibernate.annotations.CreationTimestamp; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -@Entity -@Table(name = "refunds") -public class Refund { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne - @JoinColumn(name = "sale_id", nullable = false) - private Sale sale; - - @Column(name = "refund_date", nullable = false) - private LocalDateTime refundDate = LocalDateTime.now(); - - @Column(name = "refund_amount", nullable = false, precision = 10, scale = 2) - private BigDecimal refundAmount; - - @Column(name = "refund_reason", columnDefinition = "TEXT") - private String refundReason; - - @ManyToOne - @JoinColumn(name = "processed_by", nullable = false) - private User processedBy; - - @OneToMany(mappedBy = "refund", cascade = CascadeType.ALL) - private List items = new ArrayList<>(); - - @CreationTimestamp - @Column(name = "created_at", updatable = false) - private LocalDateTime createdAt; - - public Refund() { - } - - public Refund(Long id, Sale sale, LocalDateTime refundDate, BigDecimal refundAmount, String refundReason, User processedBy, List items, LocalDateTime createdAt) { - this.id = id; - this.sale = sale; - this.refundDate = refundDate; - this.refundAmount = refundAmount; - this.refundReason = refundReason; - this.processedBy = processedBy; - this.items = items; - this.createdAt = createdAt; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Sale getSale() { - return sale; - } - - public void setSale(Sale sale) { - this.sale = sale; - } - - public LocalDateTime getRefundDate() { - return refundDate; - } - - public void setRefundDate(LocalDateTime refundDate) { - this.refundDate = refundDate; - } - - public BigDecimal getRefundAmount() { - return refundAmount; - } - - public void setRefundAmount(BigDecimal refundAmount) { - this.refundAmount = refundAmount; - } - - public String getRefundReason() { - return refundReason; - } - - public void setRefundReason(String refundReason) { - this.refundReason = refundReason; - } - - public User getProcessedBy() { - return processedBy; - } - - public void setProcessedBy(User processedBy) { - this.processedBy = processedBy; - } - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - public LocalDateTime getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(LocalDateTime createdAt) { - this.createdAt = createdAt; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Refund refund = (Refund) o; - return Objects.equals(id, refund.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - return "Refund{" + - "id=" + id + - ", sale=" + sale + - ", refundDate=" + refundDate + - ", refundAmount=" + refundAmount + - ", refundReason='" + refundReason + '\'' + - ", processedBy=" + processedBy + - ", items=" + items + - ", createdAt=" + createdAt + - '}'; - } -} diff --git a/src/main/java/com/petshop/backend/entity/RefundItem.java b/src/main/java/com/petshop/backend/entity/RefundItem.java deleted file mode 100644 index 1724679a..00000000 --- a/src/main/java/com/petshop/backend/entity/RefundItem.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.petshop.backend.entity; - -import jakarta.persistence.*; - -import java.math.BigDecimal; -import java.util.Objects; - -@Entity -@Table(name = "refund_items") -public class RefundItem { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne - @JoinColumn(name = "refund_id", nullable = false) - private Refund refund; - - @ManyToOne - @JoinColumn(name = "sale_item_id", nullable = false) - private SaleItem saleItem; - - @Column(nullable = false) - private Integer quantity; - - @Column(name = "refund_amount", nullable = false, precision = 10, scale = 2) - private BigDecimal refundAmount; - - public RefundItem() { - } - - public RefundItem(Long id, Refund refund, SaleItem saleItem, Integer quantity, BigDecimal refundAmount) { - this.id = id; - this.refund = refund; - this.saleItem = saleItem; - this.quantity = quantity; - this.refundAmount = refundAmount; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Refund getRefund() { - return refund; - } - - public void setRefund(Refund refund) { - this.refund = refund; - } - - public SaleItem getSaleItem() { - return saleItem; - } - - public void setSaleItem(SaleItem saleItem) { - this.saleItem = saleItem; - } - - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - public BigDecimal getRefundAmount() { - return refundAmount; - } - - public void setRefundAmount(BigDecimal refundAmount) { - this.refundAmount = refundAmount; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RefundItem that = (RefundItem) o; - return Objects.equals(id, that.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - return "RefundItem{" + - "id=" + id + - ", refund=" + refund + - ", saleItem=" + saleItem + - ", quantity=" + quantity + - ", refundAmount=" + refundAmount + - '}'; - } -} diff --git a/src/main/java/com/petshop/backend/entity/Sale.java b/src/main/java/com/petshop/backend/entity/Sale.java index fc1e8765..7f844c39 100644 --- a/src/main/java/com/petshop/backend/entity/Sale.java +++ b/src/main/java/com/petshop/backend/entity/Sale.java @@ -2,6 +2,7 @@ package com.petshop.backend.entity; import jakarta.persistence.*; import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -10,42 +11,36 @@ import java.util.List; import java.util.Objects; @Entity -@Table(name = "sales") +@Table(name = "sale") public class Sale { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long saleId; - @Column(name = "sale_date", nullable = false) + @Column(nullable = false) private LocalDateTime saleDate = LocalDateTime.now(); @ManyToOne - @JoinColumn(name = "employee_id", nullable = false) - private User employee; + @JoinColumn(name = "employeeId", nullable = false) + private Employee employee; @ManyToOne - @JoinColumn(name = "customer_id") - private Customer customer; - - @ManyToOne - @JoinColumn(name = "store_id") - private Store store; + @JoinColumn(name = "storeId", nullable = false) + private StoreLocation store; @Column(nullable = false, precision = 10, scale = 2) - private BigDecimal subtotal; + private BigDecimal totalAmount; - @Column(nullable = false, precision = 10, scale = 2) - private BigDecimal tax = BigDecimal.ZERO; - - @Column(nullable = false, precision = 10, scale = 2) - private BigDecimal total; - - @Column(name = "payment_method", length = 50) + @Column(nullable = false, length = 50) private String paymentMethod; - @Column(columnDefinition = "TEXT") - private String notes; + @Column(nullable = false) + private Boolean isRefund = false; + + @ManyToOne + @JoinColumn(name = "originalSaleId") + private Sale originalSale; @OneToMany(mappedBy = "sale", cascade = CascadeType.ALL) private List items = new ArrayList<>(); @@ -54,30 +49,33 @@ public class Sale { @Column(name = "created_at", updatable = false) private LocalDateTime createdAt; + @UpdateTimestamp + @Column(name = "updated_at") + private LocalDateTime updatedAt; + public Sale() { } - public Sale(Long id, LocalDateTime saleDate, User employee, Customer customer, Store store, BigDecimal subtotal, BigDecimal tax, BigDecimal total, String paymentMethod, String notes, List items, LocalDateTime createdAt) { - this.id = id; + public Sale(Long saleId, LocalDateTime saleDate, Employee employee, StoreLocation store, BigDecimal totalAmount, String paymentMethod, Boolean isRefund, Sale originalSale, List items, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.saleId = saleId; this.saleDate = saleDate; this.employee = employee; - this.customer = customer; this.store = store; - this.subtotal = subtotal; - this.tax = tax; - this.total = total; + this.totalAmount = totalAmount; this.paymentMethod = paymentMethod; - this.notes = notes; + this.isRefund = isRefund; + this.originalSale = originalSale; this.items = items; this.createdAt = createdAt; + this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getSaleId() { + return saleId; } - public void setId(Long id) { - this.id = id; + public void setSaleId(Long saleId) { + this.saleId = saleId; } public LocalDateTime getSaleDate() { @@ -88,52 +86,28 @@ public class Sale { this.saleDate = saleDate; } - public User getEmployee() { + public Employee getEmployee() { return employee; } - public void setEmployee(User employee) { + public void setEmployee(Employee employee) { this.employee = employee; } - public Customer getCustomer() { - return customer; - } - - public void setCustomer(Customer customer) { - this.customer = customer; - } - - public Store getStore() { + public StoreLocation getStore() { return store; } - public void setStore(Store store) { + public void setStore(StoreLocation store) { this.store = store; } - public BigDecimal getSubtotal() { - return subtotal; + public BigDecimal getTotalAmount() { + return totalAmount; } - public void setSubtotal(BigDecimal subtotal) { - this.subtotal = subtotal; - } - - public BigDecimal getTax() { - return tax; - } - - public void setTax(BigDecimal tax) { - this.tax = tax; - } - - public BigDecimal getTotal() { - return total; - } - - public void setTotal(BigDecimal total) { - this.total = total; + public void setTotalAmount(BigDecimal totalAmount) { + this.totalAmount = totalAmount; } public String getPaymentMethod() { @@ -144,12 +118,20 @@ public class Sale { this.paymentMethod = paymentMethod; } - public String getNotes() { - return notes; + public Boolean getIsRefund() { + return isRefund; } - public void setNotes(String notes) { - this.notes = notes; + public void setIsRefund(Boolean isRefund) { + this.isRefund = isRefund; + } + + public Sale getOriginalSale() { + return originalSale; + } + + public void setOriginalSale(Sale originalSale) { + this.originalSale = originalSale; } public List getItems() { @@ -168,34 +150,41 @@ public class Sale { this.createdAt = createdAt; } + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(LocalDateTime updatedAt) { + this.updatedAt = updatedAt; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Sale sale = (Sale) o; - return Objects.equals(id, sale.id); + return Objects.equals(saleId, sale.saleId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(saleId); } @Override public String toString() { return "Sale{" + - "id=" + id + + "saleId=" + saleId + ", saleDate=" + saleDate + ", employee=" + employee + - ", customer=" + customer + ", store=" + store + - ", subtotal=" + subtotal + - ", tax=" + tax + - ", total=" + total + + ", totalAmount=" + totalAmount + ", paymentMethod='" + paymentMethod + '\'' + - ", notes='" + notes + '\'' + + ", isRefund=" + isRefund + + ", originalSale=" + originalSale + ", items=" + items + ", createdAt=" + createdAt + + ", updatedAt=" + updatedAt + '}'; } } diff --git a/src/main/java/com/petshop/backend/entity/SaleItem.java b/src/main/java/com/petshop/backend/entity/SaleItem.java index 5b883f4c..b80ab370 100644 --- a/src/main/java/com/petshop/backend/entity/SaleItem.java +++ b/src/main/java/com/petshop/backend/entity/SaleItem.java @@ -1,53 +1,62 @@ package com.petshop.backend.entity; import jakarta.persistence.*; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "sale_items") +@Table(name = "saleItem") public class SaleItem { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long saleItemId; @ManyToOne - @JoinColumn(name = "sale_id", nullable = false) + @JoinColumn(name = "saleId", nullable = false) private Sale sale; @ManyToOne - @JoinColumn(name = "product_id", nullable = false) + @JoinColumn(name = "prodId", nullable = false) private Product product; @Column(nullable = false) private Integer quantity; - @Column(name = "unit_price", nullable = false, precision = 10, scale = 2) + @Column(nullable = false, precision = 10, scale = 2) private BigDecimal unitPrice; - @Column(nullable = false, precision = 10, scale = 2) - private BigDecimal subtotal; + @CreationTimestamp + @Column(name = "created_at", updatable = false) + private LocalDateTime createdAt; + + @UpdateTimestamp + @Column(name = "updated_at") + private LocalDateTime updatedAt; public SaleItem() { } - public SaleItem(Long id, Sale sale, Product product, Integer quantity, BigDecimal unitPrice, BigDecimal subtotal) { - this.id = id; + public SaleItem(Long saleItemId, Sale sale, Product product, Integer quantity, BigDecimal unitPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.saleItemId = saleItemId; this.sale = sale; this.product = product; this.quantity = quantity; this.unitPrice = unitPrice; - this.subtotal = subtotal; + this.createdAt = createdAt; + this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getSaleItemId() { + return saleItemId; } - public void setId(Long id) { - this.id = id; + public void setSaleItemId(Long saleItemId) { + this.saleItemId = saleItemId; } public Sale getSale() { @@ -82,12 +91,20 @@ public class SaleItem { this.unitPrice = unitPrice; } - public BigDecimal getSubtotal() { - return subtotal; + public LocalDateTime getCreatedAt() { + return createdAt; } - public void setSubtotal(BigDecimal subtotal) { - this.subtotal = subtotal; + public void setCreatedAt(LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(LocalDateTime updatedAt) { + this.updatedAt = updatedAt; } @Override @@ -95,23 +112,24 @@ public class SaleItem { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SaleItem saleItem = (SaleItem) o; - return Objects.equals(id, saleItem.id); + return Objects.equals(saleItemId, saleItem.saleItemId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(saleItemId); } @Override public String toString() { return "SaleItem{" + - "id=" + id + + "saleItemId=" + saleItemId + ", sale=" + sale + ", product=" + product + ", quantity=" + quantity + ", unitPrice=" + unitPrice + - ", subtotal=" + subtotal + + ", createdAt=" + createdAt + + ", updatedAt=" + updatedAt + '}'; } } diff --git a/src/main/java/com/petshop/backend/entity/Service.java b/src/main/java/com/petshop/backend/entity/Service.java index e3148cd9..a73387c8 100644 --- a/src/main/java/com/petshop/backend/entity/Service.java +++ b/src/main/java/com/petshop/backend/entity/Service.java @@ -9,27 +9,24 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "services") +@Table(name = "service") public class Service { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long serviceId; - @Column(name = "service_name", nullable = false, length = 100) + @Column(nullable = false, length = 100) private String serviceName; - @Column(name = "service_description", columnDefinition = "TEXT") - private String serviceDescription; + @Column(columnDefinition = "TEXT") + private String serviceDesc; - @Column(name = "service_price", nullable = false, precision = 10, scale = 2) + @Column(nullable = false, precision = 10, scale = 2) private BigDecimal servicePrice; - @Column(name = "service_duration_minutes") - private Integer serviceDurationMinutes; - @Column(nullable = false) - private Boolean active = true; + private Integer serviceDuration; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -42,23 +39,22 @@ public class Service { public Service() { } - public Service(Long id, String serviceName, String serviceDescription, BigDecimal servicePrice, Integer serviceDurationMinutes, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; + public Service(Long serviceId, String serviceName, String serviceDesc, BigDecimal servicePrice, Integer serviceDuration, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.serviceId = serviceId; this.serviceName = serviceName; - this.serviceDescription = serviceDescription; + this.serviceDesc = serviceDesc; this.servicePrice = servicePrice; - this.serviceDurationMinutes = serviceDurationMinutes; - this.active = active; + this.serviceDuration = serviceDuration; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getServiceId() { + return serviceId; } - public void setId(Long id) { - this.id = id; + public void setServiceId(Long serviceId) { + this.serviceId = serviceId; } public String getServiceName() { @@ -69,12 +65,12 @@ public class Service { this.serviceName = serviceName; } - public String getServiceDescription() { - return serviceDescription; + public String getServiceDesc() { + return serviceDesc; } - public void setServiceDescription(String serviceDescription) { - this.serviceDescription = serviceDescription; + public void setServiceDesc(String serviceDesc) { + this.serviceDesc = serviceDesc; } public BigDecimal getServicePrice() { @@ -85,20 +81,12 @@ public class Service { this.servicePrice = servicePrice; } - public Integer getServiceDurationMinutes() { - return serviceDurationMinutes; + public Integer getServiceDuration() { + return serviceDuration; } - public void setServiceDurationMinutes(Integer serviceDurationMinutes) { - this.serviceDurationMinutes = serviceDurationMinutes; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; + public void setServiceDuration(Integer serviceDuration) { + this.serviceDuration = serviceDuration; } public LocalDateTime getCreatedAt() { @@ -122,23 +110,22 @@ public class Service { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Service service = (Service) o; - return Objects.equals(id, service.id); + return Objects.equals(serviceId, service.serviceId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(serviceId); } @Override public String toString() { return "Service{" + - "id=" + id + + "serviceId=" + serviceId + ", serviceName='" + serviceName + '\'' + - ", serviceDescription='" + serviceDescription + '\'' + + ", serviceDesc='" + serviceDesc + '\'' + ", servicePrice=" + servicePrice + - ", serviceDurationMinutes=" + serviceDurationMinutes + - ", active=" + active + + ", serviceDuration=" + serviceDuration + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/Store.java b/src/main/java/com/petshop/backend/entity/Store.java deleted file mode 100644 index 35861c87..00000000 --- a/src/main/java/com/petshop/backend/entity/Store.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.petshop.backend.entity; - -import jakarta.persistence.*; -import org.hibernate.annotations.CreationTimestamp; - -import java.time.LocalDateTime; -import java.util.Objects; - -@Entity -@Table(name = "stores") -public class Store { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "store_name", nullable = false, length = 100) - private String storeName; - - @Column(name = "store_location", length = 200) - private String storeLocation; - - @CreationTimestamp - @Column(name = "created_at", updatable = false) - private LocalDateTime createdAt; - - public Store() { - } - - public Store(Long id, String storeName, String storeLocation, LocalDateTime createdAt) { - this.id = id; - this.storeName = storeName; - this.storeLocation = storeLocation; - this.createdAt = createdAt; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getStoreName() { - return storeName; - } - - public void setStoreName(String storeName) { - this.storeName = storeName; - } - - public String getStoreLocation() { - return storeLocation; - } - - public void setStoreLocation(String storeLocation) { - this.storeLocation = storeLocation; - } - - public LocalDateTime getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(LocalDateTime createdAt) { - this.createdAt = createdAt; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Store store = (Store) o; - return Objects.equals(id, store.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - return "Store{" + - "id=" + id + - ", storeName='" + storeName + '\'' + - ", storeLocation='" + storeLocation + '\'' + - ", createdAt=" + createdAt + - '}'; - } -} diff --git a/src/main/java/com/petshop/backend/entity/StoreLocation.java b/src/main/java/com/petshop/backend/entity/StoreLocation.java new file mode 100644 index 00000000..6b1a2ced --- /dev/null +++ b/src/main/java/com/petshop/backend/entity/StoreLocation.java @@ -0,0 +1,132 @@ +package com.petshop.backend.entity; + +import jakarta.persistence.*; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; + +import java.time.LocalDateTime; +import java.util.Objects; + +@Entity +@Table(name = "storeLocation") +public class StoreLocation { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long storeId; + + @Column(nullable = false, length = 100) + private String storeName; + + @Column(nullable = false, length = 255) + private String address; + + @Column(nullable = false, length = 20) + private String phone; + + @Column(nullable = false, length = 100) + private String email; + + @CreationTimestamp + @Column(name = "created_at", updatable = false) + private LocalDateTime createdAt; + + @UpdateTimestamp + @Column(name = "updated_at") + private LocalDateTime updatedAt; + + public StoreLocation() { + } + + public StoreLocation(Long storeId, String storeName, String address, String phone, String email, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.storeId = storeId; + this.storeName = storeName; + this.address = address; + this.phone = phone; + this.email = email; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public Long getStoreId() { + return storeId; + } + + public void setStoreId(Long storeId) { + this.storeId = storeId; + } + + public String getStoreName() { + return storeName; + } + + public void setStoreName(String storeName) { + this.storeName = storeName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + public LocalDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(LocalDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StoreLocation that = (StoreLocation) o; + return Objects.equals(storeId, that.storeId); + } + + @Override + public int hashCode() { + return Objects.hash(storeId); + } + + @Override + public String toString() { + return "StoreLocation{" + + "storeId=" + storeId + + ", storeName='" + storeName + '\'' + + ", address='" + address + '\'' + + ", phone='" + phone + '\'' + + ", email='" + email + '\'' + + ", createdAt=" + createdAt + + ", updatedAt=" + updatedAt + + '}'; + } +} diff --git a/src/main/java/com/petshop/backend/entity/Supplier.java b/src/main/java/com/petshop/backend/entity/Supplier.java index c0279738..5dc35f17 100644 --- a/src/main/java/com/petshop/backend/entity/Supplier.java +++ b/src/main/java/com/petshop/backend/entity/Supplier.java @@ -8,30 +8,27 @@ import java.time.LocalDateTime; import java.util.Objects; @Entity -@Table(name = "suppliers") +@Table(name = "supplier") public class Supplier { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Long supId; - @Column(name = "supplier_name", nullable = false, length = 100) - private String supplierName; + @Column(nullable = false, length = 100) + private String supCompany; - @Column(name = "supplier_contact", length = 100) - private String supplierContact; + @Column(nullable = false, length = 50) + private String supContactFirstName; - @Column(name = "supplier_email", length = 100) - private String supplierEmail; + @Column(nullable = false, length = 50) + private String supContactLastName; - @Column(name = "supplier_phone", length = 20) - private String supplierPhone; + @Column(nullable = false, length = 100) + private String supEmail; - @Column(name = "supplier_address", columnDefinition = "TEXT") - private String supplierAddress; - - @Column(nullable = false) - private Boolean active = true; + @Column(nullable = false, length = 20) + private String supPhone; @CreationTimestamp @Column(name = "created_at", updatable = false) @@ -44,72 +41,63 @@ public class Supplier { public Supplier() { } - public Supplier(Long id, String supplierName, String supplierContact, String supplierEmail, String supplierPhone, String supplierAddress, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { - this.id = id; - this.supplierName = supplierName; - this.supplierContact = supplierContact; - this.supplierEmail = supplierEmail; - this.supplierPhone = supplierPhone; - this.supplierAddress = supplierAddress; - this.active = active; + public Supplier(Long supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone, LocalDateTime createdAt, LocalDateTime updatedAt) { + this.supId = supId; + this.supCompany = supCompany; + this.supContactFirstName = supContactFirstName; + this.supContactLastName = supContactLastName; + this.supEmail = supEmail; + this.supPhone = supPhone; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public Long getId() { - return id; + public Long getSupId() { + return supId; } - public void setId(Long id) { - this.id = id; + public void setSupId(Long supId) { + this.supId = supId; } - public String getSupplierName() { - return supplierName; + public String getSupCompany() { + return supCompany; } - public void setSupplierName(String supplierName) { - this.supplierName = supplierName; + public void setSupCompany(String supCompany) { + this.supCompany = supCompany; } - public String getSupplierContact() { - return supplierContact; + public String getSupContactFirstName() { + return supContactFirstName; } - public void setSupplierContact(String supplierContact) { - this.supplierContact = supplierContact; + public void setSupContactFirstName(String supContactFirstName) { + this.supContactFirstName = supContactFirstName; } - public String getSupplierEmail() { - return supplierEmail; + public String getSupContactLastName() { + return supContactLastName; } - public void setSupplierEmail(String supplierEmail) { - this.supplierEmail = supplierEmail; + public void setSupContactLastName(String supContactLastName) { + this.supContactLastName = supContactLastName; } - public String getSupplierPhone() { - return supplierPhone; + public String getSupEmail() { + return supEmail; } - public void setSupplierPhone(String supplierPhone) { - this.supplierPhone = supplierPhone; + public void setSupEmail(String supEmail) { + this.supEmail = supEmail; } - public String getSupplierAddress() { - return supplierAddress; + public String getSupPhone() { + return supPhone; } - public void setSupplierAddress(String supplierAddress) { - this.supplierAddress = supplierAddress; - } - - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; + public void setSupPhone(String supPhone) { + this.supPhone = supPhone; } public LocalDateTime getCreatedAt() { @@ -133,24 +121,23 @@ public class Supplier { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Supplier supplier = (Supplier) o; - return Objects.equals(id, supplier.id); + return Objects.equals(supId, supplier.supId); } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(supId); } @Override public String toString() { return "Supplier{" + - "id=" + id + - ", supplierName='" + supplierName + '\'' + - ", supplierContact='" + supplierContact + '\'' + - ", supplierEmail='" + supplierEmail + '\'' + - ", supplierPhone='" + supplierPhone + '\'' + - ", supplierAddress='" + supplierAddress + '\'' + - ", active=" + active + + "supId=" + supId + + ", supCompany='" + supCompany + '\'' + + ", supContactFirstName='" + supContactFirstName + '\'' + + ", supContactLastName='" + supContactLastName + '\'' + + ", supEmail='" + supEmail + '\'' + + ", supPhone='" + supPhone + '\'' + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/entity/User.java b/src/main/java/com/petshop/backend/entity/User.java index 729e782a..a8c42d8f 100644 --- a/src/main/java/com/petshop/backend/entity/User.java +++ b/src/main/java/com/petshop/backend/entity/User.java @@ -21,19 +21,10 @@ public class User { @Column(nullable = false) private String password; - @Column(name = "full_name", nullable = false, length = 100) - private String fullName; - - @Column(length = 100) - private String email; - @Enumerated(EnumType.STRING) - @Column(nullable = false) + @Column(nullable = false, length = 20, columnDefinition = "VARCHAR(20)") private Role role; - @Column(nullable = false) - private Boolean active = true; - @CreationTimestamp @Column(name = "created_at", updatable = false) private LocalDateTime createdAt; @@ -43,20 +34,17 @@ public class User { private LocalDateTime updatedAt; public enum Role { - STAFF, ADMIN, CUSTOMER + STAFF, ADMIN } public User() { } - public User(Long id, String username, String password, String fullName, String email, Role role, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { + public User(Long id, String username, String password, Role role, LocalDateTime createdAt, LocalDateTime updatedAt) { this.id = id; this.username = username; this.password = password; - this.fullName = fullName; - this.email = email; this.role = role; - this.active = active; this.createdAt = createdAt; this.updatedAt = updatedAt; } @@ -85,22 +73,6 @@ public class User { this.password = password; } - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - public Role getRole() { return role; } @@ -109,14 +81,6 @@ public class User { this.role = role; } - public Boolean getActive() { - return active; - } - - public void setActive(Boolean active) { - this.active = active; - } - public LocalDateTime getCreatedAt() { return createdAt; } @@ -152,10 +116,7 @@ public class User { "id=" + id + ", username='" + username + '\'' + ", password='" + password + '\'' + - ", fullName='" + fullName + '\'' + - ", email='" + email + '\'' + ", role=" + role + - ", active=" + active + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt + '}'; diff --git a/src/main/java/com/petshop/backend/repository/ActivityLogRepository.java b/src/main/java/com/petshop/backend/repository/ActivityLogRepository.java new file mode 100644 index 00000000..5c5db4c5 --- /dev/null +++ b/src/main/java/com/petshop/backend/repository/ActivityLogRepository.java @@ -0,0 +1,9 @@ +package com.petshop.backend.repository; + +import com.petshop.backend.entity.ActivityLog; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ActivityLogRepository extends JpaRepository { +} diff --git a/src/main/java/com/petshop/backend/repository/AdoptionRepository.java b/src/main/java/com/petshop/backend/repository/AdoptionRepository.java index 92bf2cb2..3dd488d6 100644 --- a/src/main/java/com/petshop/backend/repository/AdoptionRepository.java +++ b/src/main/java/com/petshop/backend/repository/AdoptionRepository.java @@ -12,7 +12,8 @@ import org.springframework.stereotype.Repository; public interface AdoptionRepository extends JpaRepository { @Query("SELECT a FROM Adoption a WHERE " + - "LOWER(a.customer.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(a.customer.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(a.customer.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(a.pet.petName) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchAdoptions(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/AppointmentRepository.java b/src/main/java/com/petshop/backend/repository/AppointmentRepository.java index 4040d08c..779bee9a 100644 --- a/src/main/java/com/petshop/backend/repository/AppointmentRepository.java +++ b/src/main/java/com/petshop/backend/repository/AppointmentRepository.java @@ -18,11 +18,12 @@ public interface AppointmentRepository extends JpaRepository @Query("SELECT a FROM Appointment a WHERE a.appointmentDate = :date AND a.appointmentTime = :time") List findByDateAndTime(@Param("date") LocalDate date, @Param("time") LocalTime time); - @Query("SELECT a FROM Appointment a WHERE a.service.id = :serviceId AND a.appointmentDate = :date AND a.status != 'Cancelled'") + @Query("SELECT a FROM Appointment a WHERE a.service.serviceId = :serviceId AND a.appointmentDate = :date AND a.appointmentStatus != 'Cancelled'") List findByServiceAndDate(@Param("serviceId") Long serviceId, @Param("date") LocalDate date); @Query("SELECT DISTINCT a FROM Appointment a LEFT JOIN a.pets p WHERE " + - "LOWER(a.customer.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(a.customer.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(a.customer.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(a.service.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchAppointments(@Param("q") String query, Pageable pageable); diff --git a/src/main/java/com/petshop/backend/repository/CategoryRepository.java b/src/main/java/com/petshop/backend/repository/CategoryRepository.java index ae20d6a0..ceb30e53 100644 --- a/src/main/java/com/petshop/backend/repository/CategoryRepository.java +++ b/src/main/java/com/petshop/backend/repository/CategoryRepository.java @@ -17,6 +17,6 @@ public interface CategoryRepository extends JpaRepository { @Query("SELECT c FROM Category c WHERE " + "LOWER(c.categoryName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(c.categoryDescription) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(c.categoryType) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchCategories(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/CustomerRepository.java b/src/main/java/com/petshop/backend/repository/CustomerRepository.java index a0bebc69..a1885993 100644 --- a/src/main/java/com/petshop/backend/repository/CustomerRepository.java +++ b/src/main/java/com/petshop/backend/repository/CustomerRepository.java @@ -12,8 +12,9 @@ import org.springframework.stereotype.Repository; public interface CustomerRepository extends JpaRepository { @Query("SELECT c FROM Customer c WHERE " + - "LOWER(c.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(c.customerEmail) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(c.customerPhone) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(c.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(c.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(c.email) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(c.phone) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchCustomers(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/RefundRepository.java b/src/main/java/com/petshop/backend/repository/EmployeeRepository.java similarity index 58% rename from src/main/java/com/petshop/backend/repository/RefundRepository.java rename to src/main/java/com/petshop/backend/repository/EmployeeRepository.java index 8378b672..4c5aa9d8 100644 --- a/src/main/java/com/petshop/backend/repository/RefundRepository.java +++ b/src/main/java/com/petshop/backend/repository/EmployeeRepository.java @@ -1,9 +1,9 @@ package com.petshop.backend.repository; -import com.petshop.backend.entity.Refund; +import com.petshop.backend.entity.Employee; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface RefundRepository extends JpaRepository { +public interface EmployeeRepository extends JpaRepository { } diff --git a/src/main/java/com/petshop/backend/repository/InventoryRepository.java b/src/main/java/com/petshop/backend/repository/InventoryRepository.java index e7e4d673..0e9d358c 100644 --- a/src/main/java/com/petshop/backend/repository/InventoryRepository.java +++ b/src/main/java/com/petshop/backend/repository/InventoryRepository.java @@ -13,11 +13,11 @@ import java.util.Optional; @Repository public interface InventoryRepository extends JpaRepository { - @Query("SELECT i FROM Inventory i WHERE i.product.id = :productId AND i.store.id = :storeId") - Optional findByProductIdAndStoreId(@Param("productId") Long productId, @Param("storeId") Long storeId); + @Query("SELECT i FROM Inventory i WHERE i.product.prodId = :productId") + Optional findByProductId(@Param("productId") Long productId); @Query("SELECT i FROM Inventory i WHERE " + - "LOWER(i.product.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(i.store.storeName) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(i.product.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(i.product.category.categoryName) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchInventory(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/ProductRepository.java b/src/main/java/com/petshop/backend/repository/ProductRepository.java index 896602e9..94f7fb81 100644 --- a/src/main/java/com/petshop/backend/repository/ProductRepository.java +++ b/src/main/java/com/petshop/backend/repository/ProductRepository.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository; public interface ProductRepository extends JpaRepository { @Query("SELECT p FROM Product p WHERE " + - "LOWER(p.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(p.productDescription) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(p.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(p.prodDesc) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchProducts(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/ProductSupplierRepository.java b/src/main/java/com/petshop/backend/repository/ProductSupplierRepository.java index 8b5e8720..46e87945 100644 --- a/src/main/java/com/petshop/backend/repository/ProductSupplierRepository.java +++ b/src/main/java/com/petshop/backend/repository/ProductSupplierRepository.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository; public interface ProductSupplierRepository extends JpaRepository { @Query("SELECT ps FROM ProductSupplier ps WHERE " + - "LOWER(ps.product.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(ps.supplier.supplierName) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(ps.product.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(ps.supplier.supCompany) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchProductSuppliers(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/PurchaseOrderRepository.java b/src/main/java/com/petshop/backend/repository/PurchaseOrderRepository.java index e6087bef..d3b445c4 100644 --- a/src/main/java/com/petshop/backend/repository/PurchaseOrderRepository.java +++ b/src/main/java/com/petshop/backend/repository/PurchaseOrderRepository.java @@ -12,7 +12,6 @@ import org.springframework.stereotype.Repository; public interface PurchaseOrderRepository extends JpaRepository { @Query("SELECT po FROM PurchaseOrder po WHERE " + - "LOWER(po.supplier.supplierName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(po.notes) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(po.supplier.supCompany) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchPurchaseOrders(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/SaleRepository.java b/src/main/java/com/petshop/backend/repository/SaleRepository.java index 9d5392a5..56b31289 100644 --- a/src/main/java/com/petshop/backend/repository/SaleRepository.java +++ b/src/main/java/com/petshop/backend/repository/SaleRepository.java @@ -12,8 +12,8 @@ import org.springframework.stereotype.Repository; public interface SaleRepository extends JpaRepository { @Query("SELECT s FROM Sale s WHERE " + - "LOWER(s.customer.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(s.employee.fullName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(s.employee.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(s.employee.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(s.store.storeName) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchSales(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/ServiceRepository.java b/src/main/java/com/petshop/backend/repository/ServiceRepository.java index a6c0a084..7b057856 100644 --- a/src/main/java/com/petshop/backend/repository/ServiceRepository.java +++ b/src/main/java/com/petshop/backend/repository/ServiceRepository.java @@ -13,6 +13,6 @@ public interface ServiceRepository extends JpaRepository { @Query("SELECT s FROM Service s WHERE " + "LOWER(s.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(s.serviceDescription) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(s.serviceDesc) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchServices(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/StoreRepository.java b/src/main/java/com/petshop/backend/repository/StoreRepository.java index 0c855389..5ee3758b 100644 --- a/src/main/java/com/petshop/backend/repository/StoreRepository.java +++ b/src/main/java/com/petshop/backend/repository/StoreRepository.java @@ -1,6 +1,6 @@ package com.petshop.backend.repository; -import com.petshop.backend.entity.Store; +import com.petshop.backend.entity.StoreLocation; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -9,10 +9,10 @@ import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository -public interface StoreRepository extends JpaRepository { +public interface StoreRepository extends JpaRepository { - @Query("SELECT s FROM Store s WHERE " + + @Query("SELECT s FROM StoreLocation s WHERE " + "LOWER(s.storeName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(s.storeLocation) LIKE LOWER(CONCAT('%', :q, '%'))") - Page searchStores(@Param("q") String query, Pageable pageable); + "LOWER(s.address) LIKE LOWER(CONCAT('%', :q, '%'))") + Page searchStores(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/SupplierRepository.java b/src/main/java/com/petshop/backend/repository/SupplierRepository.java index 443455b8..c7dd2307 100644 --- a/src/main/java/com/petshop/backend/repository/SupplierRepository.java +++ b/src/main/java/com/petshop/backend/repository/SupplierRepository.java @@ -12,7 +12,8 @@ import org.springframework.stereotype.Repository; public interface SupplierRepository extends JpaRepository { @Query("SELECT s FROM Supplier s WHERE " + - "LOWER(s.supplierName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(s.supplierContact) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(s.supCompany) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(s.supContactFirstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + + "LOWER(s.supContactLastName) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchSuppliers(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/repository/UserRepository.java b/src/main/java/com/petshop/backend/repository/UserRepository.java index 486d8f1a..187d73c4 100644 --- a/src/main/java/com/petshop/backend/repository/UserRepository.java +++ b/src/main/java/com/petshop/backend/repository/UserRepository.java @@ -16,8 +16,6 @@ public interface UserRepository extends JpaRepository { boolean existsByUsername(String username); @Query("SELECT u FROM User u WHERE " + - "LOWER(u.username) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(u.fullName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + - "LOWER(u.email) LIKE LOWER(CONCAT('%', :q, '%'))") + "LOWER(u.username) LIKE LOWER(CONCAT('%', :q, '%'))") Page searchUsers(@Param("q") String query, Pageable pageable); } diff --git a/src/main/java/com/petshop/backend/security/SecurityConfig.java b/src/main/java/com/petshop/backend/security/SecurityConfig.java index e1ce42c4..dadf9d93 100644 --- a/src/main/java/com/petshop/backend/security/SecurityConfig.java +++ b/src/main/java/com/petshop/backend/security/SecurityConfig.java @@ -36,7 +36,7 @@ public class SecurityConfig { http .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(auth -> auth - .requestMatchers("/api/v1/auth/login", "/api/v1/auth/register").permitAll() + .requestMatchers("/api/v1/auth/login").permitAll() .requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/swagger-ui.html").permitAll() .requestMatchers(HttpMethod.GET, "/api/v1/dropdowns/suppliers").hasRole("ADMIN") .requestMatchers("/api/v1/inventory/**").hasRole("ADMIN") diff --git a/src/main/java/com/petshop/backend/security/UserDetailsServiceImpl.java b/src/main/java/com/petshop/backend/security/UserDetailsServiceImpl.java index d2bdcfff..06c3870b 100644 --- a/src/main/java/com/petshop/backend/security/UserDetailsServiceImpl.java +++ b/src/main/java/com/petshop/backend/security/UserDetailsServiceImpl.java @@ -24,10 +24,6 @@ public class UserDetailsServiceImpl implements UserDetailsService { User user = userRepository.findByUsername(username) .orElseThrow(() -> new UsernameNotFoundException("User not found: " + username)); - if (!user.getActive()) { - throw new UsernameNotFoundException("User is inactive: " + username); - } - return new org.springframework.security.core.userdetails.User( user.getUsername(), user.getPassword(), diff --git a/src/main/java/com/petshop/backend/service/AdoptionService.java b/src/main/java/com/petshop/backend/service/AdoptionService.java index d5ecc890..fea336cd 100644 --- a/src/main/java/com/petshop/backend/service/AdoptionService.java +++ b/src/main/java/com/petshop/backend/service/AdoptionService.java @@ -56,8 +56,7 @@ public class AdoptionService { adoption.setPet(pet); adoption.setCustomer(customer); adoption.setAdoptionDate(request.getAdoptionDate()); - adoption.setAdoptionFee(request.getAdoptionFee()); - adoption.setNotes(request.getNotes()); + adoption.setAdoptionStatus(request.getAdoptionStatus()); adoption = adoptionRepository.save(adoption); return mapToResponse(adoption); @@ -77,8 +76,7 @@ public class AdoptionService { adoption.setPet(pet); adoption.setCustomer(customer); adoption.setAdoptionDate(request.getAdoptionDate()); - adoption.setAdoptionFee(request.getAdoptionFee()); - adoption.setNotes(request.getNotes()); + adoption.setAdoptionStatus(request.getAdoptionStatus()); adoption = adoptionRepository.save(adoption); return mapToResponse(adoption); @@ -99,14 +97,13 @@ public class AdoptionService { private AdoptionResponse mapToResponse(Adoption adoption) { return new AdoptionResponse( - adoption.getId(), - adoption.getPet().getId(), + adoption.getAdoptionId(), + adoption.getPet().getPetId(), adoption.getPet().getPetName(), - adoption.getCustomer().getId(), - adoption.getCustomer().getCustomerName(), + adoption.getCustomer().getCustomerId(), + adoption.getCustomer().getFirstName() + " " + adoption.getCustomer().getLastName(), adoption.getAdoptionDate(), - adoption.getAdoptionFee(), - adoption.getNotes(), + adoption.getAdoptionStatus(), adoption.getCreatedAt(), adoption.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/AnalyticsService.java b/src/main/java/com/petshop/backend/service/AnalyticsService.java index 47e27d17..18c9c9b8 100644 --- a/src/main/java/com/petshop/backend/service/AnalyticsService.java +++ b/src/main/java/com/petshop/backend/service/AnalyticsService.java @@ -3,11 +3,9 @@ package com.petshop.backend.service; import com.petshop.backend.dto.analytics.DashboardResponse; import com.petshop.backend.entity.Inventory; import com.petshop.backend.entity.Product; -import com.petshop.backend.entity.Refund; import com.petshop.backend.entity.Sale; import com.petshop.backend.repository.InventoryRepository; import com.petshop.backend.repository.ProductRepository; -import com.petshop.backend.repository.RefundRepository; import com.petshop.backend.repository.SaleRepository; import org.springframework.stereotype.Service; @@ -22,14 +20,12 @@ import java.util.stream.Collectors; public class AnalyticsService { private final SaleRepository saleRepository; - private final RefundRepository refundRepository; private final InventoryRepository inventoryRepository; private final ProductRepository productRepository; - public AnalyticsService(SaleRepository saleRepository, RefundRepository refundRepository, + public AnalyticsService(SaleRepository saleRepository, InventoryRepository inventoryRepository, ProductRepository productRepository) { this.saleRepository = saleRepository; - this.refundRepository = refundRepository; this.inventoryRepository = inventoryRepository; this.productRepository = productRepository; } @@ -41,11 +37,7 @@ public class AnalyticsService { .filter(sale -> sale.getSaleDate().isAfter(startDate)) .collect(Collectors.toList()); - List refunds = refundRepository.findAll().stream() - .filter(refund -> refund.getRefundDate().isAfter(startDate)) - .collect(Collectors.toList()); - - DashboardResponse.SalesSummary salesSummary = calculateSalesSummary(sales, refunds); + DashboardResponse.SalesSummary salesSummary = calculateSalesSummary(sales); DashboardResponse.InventorySummary inventorySummary = calculateInventorySummary(); List topProducts = calculateTopProducts(sales, top); List dailySales = calculateDailySales(sales, days); @@ -53,18 +45,24 @@ public class AnalyticsService { return new DashboardResponse(salesSummary, inventorySummary, topProducts, dailySales); } - private DashboardResponse.SalesSummary calculateSalesSummary(List sales, List refunds) { + private DashboardResponse.SalesSummary calculateSalesSummary(List sales) { BigDecimal totalRevenue = sales.stream() - .map(Sale::getTotal) + .filter(sale -> !sale.getIsRefund()) + .map(Sale::getTotalAmount) .reduce(BigDecimal.ZERO, BigDecimal::add); - Long totalSales = (long) sales.size(); + Long totalSales = sales.stream() + .filter(sale -> !sale.getIsRefund()) + .count(); - BigDecimal totalRefunds = refunds.stream() - .map(Refund::getRefundAmount) + BigDecimal totalRefunds = sales.stream() + .filter(Sale::getIsRefund) + .map(Sale::getTotalAmount) .reduce(BigDecimal.ZERO, BigDecimal::add); - Long totalRefundCount = (long) refunds.size(); + Long totalRefundCount = sales.stream() + .filter(Sale::getIsRefund) + .count(); return new DashboardResponse.SalesSummary(totalRevenue, totalSales, totalRefunds, totalRefundCount); } @@ -75,14 +73,14 @@ public class AnalyticsService { Long totalProducts = productRepository.count(); Long lowStockProducts = allInventory.stream() - .filter(inv -> inv.getQuantity() > 0 && inv.getQuantity() <= inv.getReorderLevel()) - .map(inv -> inv.getProduct().getId()) + .filter(inv -> inv.getQuantity() > 0 && inv.getQuantity() <= 10) + .map(inv -> inv.getProduct().getProdId()) .distinct() .count(); Long outOfStockProducts = allInventory.stream() .filter(inv -> inv.getQuantity() == 0) - .map(inv -> inv.getProduct().getId()) + .map(inv -> inv.getProduct().getProdId()) .distinct() .count(); @@ -94,10 +92,10 @@ public class AnalyticsService { for (Sale sale : sales) { for (var item : sale.getItems()) { - Long productId = item.getProduct().getId(); - String productName = item.getProduct().getProductName(); + Long productId = item.getProduct().getProdId(); + String productName = item.getProduct().getProdName(); Long quantitySold = Long.valueOf(item.getQuantity()); - BigDecimal revenue = item.getSubtotal(); + BigDecimal revenue = item.getUnitPrice().multiply(BigDecimal.valueOf(item.getQuantity())); productSalesMap.compute(productId, (key, existing) -> { if (existing == null) { @@ -131,7 +129,7 @@ public class AnalyticsService { LocalDate saleDate = sale.getSaleDate().toLocalDate(); if (dailySalesMap.containsKey(saleDate)) { DashboardResponse.DailySales dailySale = dailySalesMap.get(saleDate); - dailySale.setRevenue(dailySale.getRevenue().add(sale.getTotal())); + dailySale.setRevenue(dailySale.getRevenue().add(sale.getTotalAmount())); dailySale.setSalesCount(dailySale.getSalesCount() + 1); } } diff --git a/src/main/java/com/petshop/backend/service/AppointmentService.java b/src/main/java/com/petshop/backend/service/AppointmentService.java index 8cc52b2c..1fae451c 100644 --- a/src/main/java/com/petshop/backend/service/AppointmentService.java +++ b/src/main/java/com/petshop/backend/service/AppointmentService.java @@ -70,9 +70,8 @@ public class AppointmentService { appointment.setService(service); appointment.setAppointmentDate(request.getAppointmentDate()); appointment.setAppointmentTime(request.getAppointmentTime()); - appointment.setStatus(request.getStatus()); + appointment.setAppointmentStatus(request.getAppointmentStatus()); appointment.setPets(pets); - appointment.setNotes(request.getNotes()); appointment = appointmentRepository.save(appointment); return mapToResponse(appointment); @@ -95,9 +94,8 @@ public class AppointmentService { appointment.setService(service); appointment.setAppointmentDate(request.getAppointmentDate()); appointment.setAppointmentTime(request.getAppointmentTime()); - appointment.setStatus(request.getStatus()); + appointment.setAppointmentStatus(request.getAppointmentStatus()); appointment.setPets(pets); - appointment.setNotes(request.getNotes()); appointment = appointmentRepository.save(appointment); return mapToResponse(appointment); @@ -156,21 +154,20 @@ public class AppointmentService { .collect(Collectors.toList()); List petIds = appointment.getPets().stream() - .map(Pet::getId) + .map(Pet::getPetId) .collect(Collectors.toList()); return new AppointmentResponse( - appointment.getId(), - appointment.getCustomer().getId(), - appointment.getCustomer().getCustomerName(), - appointment.getService().getId(), + appointment.getAppointmentId(), + appointment.getCustomer().getCustomerId(), + appointment.getCustomer().getFirstName() + " " + appointment.getCustomer().getLastName(), + appointment.getService().getServiceId(), appointment.getService().getServiceName(), appointment.getAppointmentDate(), appointment.getAppointmentTime(), - appointment.getStatus() != null ? appointment.getStatus().toString() : null, + appointment.getAppointmentStatus(), petNames, petIds, - appointment.getNotes(), appointment.getCreatedAt(), appointment.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/CategoryService.java b/src/main/java/com/petshop/backend/service/CategoryService.java index b575a8eb..3da87dd0 100644 --- a/src/main/java/com/petshop/backend/service/CategoryService.java +++ b/src/main/java/com/petshop/backend/service/CategoryService.java @@ -40,7 +40,7 @@ public class CategoryService { public CategoryResponse createCategory(CategoryRequest request) { Category category = new Category(); category.setCategoryName(request.getCategoryName()); - category.setCategoryDescription(request.getCategoryDescription()); + category.setCategoryType(request.getCategoryType()); category = categoryRepository.save(category); return mapToResponse(category); @@ -52,7 +52,7 @@ public class CategoryService { .orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + id)); category.setCategoryName(request.getCategoryName()); - category.setCategoryDescription(request.getCategoryDescription()); + category.setCategoryType(request.getCategoryType()); category = categoryRepository.save(category); return mapToResponse(category); @@ -73,9 +73,9 @@ public class CategoryService { private CategoryResponse mapToResponse(Category category) { return new CategoryResponse( - category.getId(), + category.getCategoryId(), category.getCategoryName(), - category.getCategoryDescription(), + category.getCategoryType(), category.getCreatedAt(), category.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/CustomerService.java b/src/main/java/com/petshop/backend/service/CustomerService.java index 7b826a72..47fa3c4c 100644 --- a/src/main/java/com/petshop/backend/service/CustomerService.java +++ b/src/main/java/com/petshop/backend/service/CustomerService.java @@ -39,10 +39,10 @@ public class CustomerService { @Transactional public CustomerResponse createCustomer(CustomerRequest request) { Customer customer = new Customer(); - customer.setCustomerName(request.getCustomerName()); - customer.setCustomerEmail(request.getCustomerEmail()); - customer.setCustomerPhone(request.getCustomerPhone()); - customer.setCustomerAddress(request.getCustomerAddress()); + customer.setFirstName(request.getFirstName()); + customer.setLastName(request.getLastName()); + customer.setEmail(request.getEmail()); + customer.setPhone(request.getPhone()); customer = customerRepository.save(customer); return mapToResponse(customer); @@ -53,10 +53,10 @@ public class CustomerService { Customer customer = customerRepository.findById(id) .orElseThrow(() -> new ResourceNotFoundException("Customer not found with id: " + id)); - customer.setCustomerName(request.getCustomerName()); - customer.setCustomerEmail(request.getCustomerEmail()); - customer.setCustomerPhone(request.getCustomerPhone()); - customer.setCustomerAddress(request.getCustomerAddress()); + customer.setFirstName(request.getFirstName()); + customer.setLastName(request.getLastName()); + customer.setEmail(request.getEmail()); + customer.setPhone(request.getPhone()); customer = customerRepository.save(customer); return mapToResponse(customer); @@ -77,11 +77,11 @@ public class CustomerService { private CustomerResponse mapToResponse(Customer customer) { return new CustomerResponse( - customer.getId(), - customer.getCustomerName(), - customer.getCustomerEmail(), - customer.getCustomerPhone(), - customer.getCustomerAddress(), + customer.getCustomerId(), + customer.getFirstName(), + customer.getLastName(), + customer.getEmail(), + customer.getPhone(), customer.getCreatedAt(), customer.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/InventoryService.java b/src/main/java/com/petshop/backend/service/InventoryService.java index c601cf1a..ee63aea7 100644 --- a/src/main/java/com/petshop/backend/service/InventoryService.java +++ b/src/main/java/com/petshop/backend/service/InventoryService.java @@ -5,29 +5,23 @@ import com.petshop.backend.dto.inventory.InventoryRequest; import com.petshop.backend.dto.inventory.InventoryResponse; import com.petshop.backend.entity.Inventory; import com.petshop.backend.entity.Product; -import com.petshop.backend.entity.Store; import com.petshop.backend.exception.ResourceNotFoundException; import com.petshop.backend.repository.InventoryRepository; import com.petshop.backend.repository.ProductRepository; -import com.petshop.backend.repository.StoreRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; - @Service public class InventoryService { private final InventoryRepository inventoryRepository; private final ProductRepository productRepository; - private final StoreRepository storeRepository; - public InventoryService(InventoryRepository inventoryRepository, ProductRepository productRepository, StoreRepository storeRepository) { + public InventoryService(InventoryRepository inventoryRepository, ProductRepository productRepository) { this.inventoryRepository = inventoryRepository; this.productRepository = productRepository; - this.storeRepository = storeRepository; } public Page getAllInventory(String query, Pageable pageable) { @@ -51,18 +45,9 @@ public class InventoryService { Product product = productRepository.findById(request.getProdId()) .orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + request.getProdId())); - Store store = null; - if (request.getStoreId() != null) { - store = storeRepository.findById(request.getStoreId()) - .orElseThrow(() -> new ResourceNotFoundException("Store not found with id: " + request.getStoreId())); - } - Inventory inventory = new Inventory(); inventory.setProduct(product); - inventory.setStore(store); inventory.setQuantity(request.getQuantity()); - inventory.setReorderLevel(request.getReorderLevel()); - inventory.setLastRestocked(LocalDateTime.now()); inventory = inventoryRepository.save(inventory); return mapToResponse(inventory); @@ -76,17 +61,8 @@ public class InventoryService { Product product = productRepository.findById(request.getProdId()) .orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + request.getProdId())); - Store store = null; - if (request.getStoreId() != null) { - store = storeRepository.findById(request.getStoreId()) - .orElseThrow(() -> new ResourceNotFoundException("Store not found with id: " + request.getStoreId())); - } - inventory.setProduct(product); - inventory.setStore(store); inventory.setQuantity(request.getQuantity()); - inventory.setReorderLevel(request.getReorderLevel()); - inventory.setLastRestocked(LocalDateTime.now()); inventory = inventoryRepository.save(inventory); return mapToResponse(inventory); @@ -107,15 +83,11 @@ public class InventoryService { private InventoryResponse mapToResponse(Inventory inventory) { return new InventoryResponse( - inventory.getId(), - inventory.getProduct().getId(), - inventory.getProduct().getProductName(), + inventory.getInventoryId(), + inventory.getProduct().getProdId(), + inventory.getProduct().getProdName(), inventory.getProduct().getCategory().getCategoryName(), - inventory.getStore() != null ? inventory.getStore().getId() : null, - inventory.getStore() != null ? inventory.getStore().getStoreName() : null, inventory.getQuantity(), - inventory.getReorderLevel(), - inventory.getLastRestocked(), inventory.getCreatedAt(), inventory.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/PetService.java b/src/main/java/com/petshop/backend/service/PetService.java index 3c40a161..b59d589b 100644 --- a/src/main/java/com/petshop/backend/service/PetService.java +++ b/src/main/java/com/petshop/backend/service/PetService.java @@ -81,12 +81,12 @@ public class PetService { private PetResponse mapToResponse(Pet pet) { return new PetResponse( - pet.getId(), + pet.getPetId(), pet.getPetName(), pet.getPetSpecies(), pet.getPetBreed(), pet.getPetAge(), - pet.getPetStatus() != null ? pet.getPetStatus().toString() : null, + pet.getPetStatus(), pet.getPetPrice(), pet.getCreatedAt(), pet.getUpdatedAt() diff --git a/src/main/java/com/petshop/backend/service/ProductService.java b/src/main/java/com/petshop/backend/service/ProductService.java index 26f13320..b907e38f 100644 --- a/src/main/java/com/petshop/backend/service/ProductService.java +++ b/src/main/java/com/petshop/backend/service/ProductService.java @@ -46,11 +46,10 @@ public class ProductService { .orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId())); Product product = new Product(); - product.setProductName(request.getProdName()); + product.setProdName(request.getProdName()); product.setCategory(category); - product.setProductDescription(request.getProdDesc()); - product.setProductPrice(request.getProdPrice()); - product.setActive(request.getActive() != null ? request.getActive() : true); + product.setProdDesc(request.getProdDesc()); + product.setProdPrice(request.getProdPrice()); product = productRepository.save(product); return mapToResponse(product); @@ -64,11 +63,10 @@ public class ProductService { Category category = categoryRepository.findById(request.getCategoryId()) .orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId())); - product.setProductName(request.getProdName()); + product.setProdName(request.getProdName()); product.setCategory(category); - product.setProductDescription(request.getProdDesc()); - product.setProductPrice(request.getProdPrice()); - product.setActive(request.getActive() != null ? request.getActive() : true); + product.setProdDesc(request.getProdDesc()); + product.setProdPrice(request.getProdPrice()); product = productRepository.save(product); return mapToResponse(product); @@ -89,13 +87,12 @@ public class ProductService { private ProductResponse mapToResponse(Product product) { return new ProductResponse( - product.getId(), - product.getProductName(), - product.getCategory().getId(), + product.getProdId(), + product.getProdName(), + product.getCategory().getCategoryId(), product.getCategory().getCategoryName(), - product.getProductDescription(), - product.getProductPrice(), - product.getActive(), + product.getProdDesc(), + product.getProdPrice(), product.getCreatedAt(), product.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/ProductSupplierService.java b/src/main/java/com/petshop/backend/service/ProductSupplierService.java index 2e60b3e4..7e3677a9 100644 --- a/src/main/java/com/petshop/backend/service/ProductSupplierService.java +++ b/src/main/java/com/petshop/backend/service/ProductSupplierService.java @@ -57,9 +57,7 @@ public class ProductSupplierService { ProductSupplier productSupplier = new ProductSupplier(); productSupplier.setProduct(product); productSupplier.setSupplier(supplier); - productSupplier.setCostPrice(request.getCostPrice()); - productSupplier.setLeadTimeDays(request.getLeadTimeDays()); - productSupplier.setIsPreferred(request.getIsPreferred()); + productSupplier.setCost(request.getCost()); productSupplier = productSupplierRepository.save(productSupplier); return mapToResponse(productSupplier); @@ -72,9 +70,7 @@ public class ProductSupplierService { .orElseThrow(() -> new ResourceNotFoundException( "ProductSupplier not found with productId: " + productId + " and supplierId: " + supplierId)); - productSupplier.setCostPrice(request.getCostPrice()); - productSupplier.setLeadTimeDays(request.getLeadTimeDays()); - productSupplier.setIsPreferred(request.getIsPreferred()); + productSupplier.setCost(request.getCost()); productSupplier = productSupplierRepository.save(productSupplier); return mapToResponse(productSupplier); @@ -101,13 +97,11 @@ public class ProductSupplierService { private ProductSupplierResponse mapToResponse(ProductSupplier productSupplier) { return new ProductSupplierResponse( - productSupplier.getProduct().getId(), - productSupplier.getProduct().getProductName(), - productSupplier.getSupplier().getId(), - productSupplier.getSupplier().getSupplierName(), - productSupplier.getCostPrice(), - productSupplier.getLeadTimeDays(), - productSupplier.getIsPreferred(), + productSupplier.getProduct().getProdId(), + productSupplier.getProduct().getProdName(), + productSupplier.getSupplier().getSupId(), + productSupplier.getSupplier().getSupCompany(), + productSupplier.getCost(), productSupplier.getCreatedAt(), productSupplier.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/PurchaseOrderService.java b/src/main/java/com/petshop/backend/service/PurchaseOrderService.java index efda04d6..97286a9c 100644 --- a/src/main/java/com/petshop/backend/service/PurchaseOrderService.java +++ b/src/main/java/com/petshop/backend/service/PurchaseOrderService.java @@ -1,18 +1,13 @@ package com.petshop.backend.service; import com.petshop.backend.dto.purchaseorder.PurchaseOrderResponse; -import com.petshop.backend.dto.purchaseorder.PurchaseOrderResponse.PurchaseOrderItemResponse; import com.petshop.backend.entity.PurchaseOrder; -import com.petshop.backend.entity.PurchaseOrderItem; import com.petshop.backend.exception.ResourceNotFoundException; import com.petshop.backend.repository.PurchaseOrderRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.stream.Collectors; - @Service public class PurchaseOrderService { @@ -39,33 +34,14 @@ public class PurchaseOrderService { } private PurchaseOrderResponse mapToResponse(PurchaseOrder purchaseOrder) { - List items = purchaseOrder.getItems().stream() - .map(this::mapItemToResponse) - .collect(Collectors.toList()); - return new PurchaseOrderResponse( - purchaseOrder.getId(), - purchaseOrder.getSupplier().getId(), - purchaseOrder.getSupplier().getSupplierName(), + purchaseOrder.getPurchaseOrderId(), + purchaseOrder.getSupplier().getSupId(), + purchaseOrder.getSupplier().getSupCompany(), purchaseOrder.getOrderDate(), - purchaseOrder.getExpectedDelivery(), - purchaseOrder.getStatus().toString(), - purchaseOrder.getTotalAmount(), - purchaseOrder.getNotes(), - items, + purchaseOrder.getStatus(), purchaseOrder.getCreatedAt(), purchaseOrder.getUpdatedAt() ); } - - private PurchaseOrderItemResponse mapItemToResponse(PurchaseOrderItem item) { - return new PurchaseOrderItemResponse( - item.getId(), - item.getProduct().getId(), - item.getProduct().getProductName(), - item.getQuantity(), - item.getUnitCost(), - item.getSubtotal() - ); - } } diff --git a/src/main/java/com/petshop/backend/service/RefundService.java b/src/main/java/com/petshop/backend/service/RefundService.java deleted file mode 100644 index ae378996..00000000 --- a/src/main/java/com/petshop/backend/service/RefundService.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.petshop.backend.service; - -import com.petshop.backend.dto.refund.RefundRequest; -import com.petshop.backend.dto.refund.RefundResponse; -import com.petshop.backend.entity.*; -import com.petshop.backend.exception.BusinessException; -import com.petshop.backend.exception.ResourceNotFoundException; -import com.petshop.backend.repository.*; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -@Service -public class RefundService { - - private final RefundRepository refundRepository; - private final SaleRepository saleRepository; - private final SaleItemRepository saleItemRepository; - private final InventoryRepository inventoryRepository; - private final UserRepository userRepository; - - public RefundService(RefundRepository refundRepository, SaleRepository saleRepository, SaleItemRepository saleItemRepository, InventoryRepository inventoryRepository, UserRepository userRepository) { - this.refundRepository = refundRepository; - this.saleRepository = saleRepository; - this.saleItemRepository = saleItemRepository; - this.inventoryRepository = inventoryRepository; - this.userRepository = userRepository; - } - - @Transactional - public RefundResponse createRefund(Long saleId, RefundRequest request) { - String username = SecurityContextHolder.getContext().getAuthentication().getName(); - User processedBy = userRepository.findByUsername(username) - .orElseThrow(() -> new ResourceNotFoundException("User not found: " + username)); - - Sale sale = saleRepository.findById(saleId) - .orElseThrow(() -> new ResourceNotFoundException("Sale not found with id: " + saleId)); - - Refund refund = new Refund(); - refund.setSale(sale); - refund.setRefundDate(LocalDateTime.now()); - refund.setRefundReason(request.getRefundReason()); - refund.setProcessedBy(processedBy); - - BigDecimal totalRefundAmount = BigDecimal.ZERO; - List refundItems = new ArrayList<>(); - - for (var itemRequest : request.getItems()) { - SaleItem saleItem = saleItemRepository.findById(itemRequest.getSaleItemId()) - .orElseThrow(() -> new ResourceNotFoundException("Sale item not found with id: " + itemRequest.getSaleItemId())); - - if (!saleItem.getSale().getId().equals(saleId)) { - throw new BusinessException("Sale item " + itemRequest.getSaleItemId() + " does not belong to sale " + saleId); - } - - if (itemRequest.getQuantity() > saleItem.getQuantity()) { - throw new BusinessException("Refund quantity (" + itemRequest.getQuantity() + - ") exceeds original sale quantity (" + saleItem.getQuantity() + ") for product: " + saleItem.getProduct().getProductName()); - } - - Inventory inventory = inventoryRepository.findByProductIdAndStoreId( - saleItem.getProduct().getId(), - sale.getStore().getId()) - .orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " + - saleItem.getProduct().getId() + " at store " + sale.getStore().getId())); - - inventory.setQuantity(inventory.getQuantity() + itemRequest.getQuantity()); - inventory.setLastRestocked(LocalDateTime.now()); - inventoryRepository.save(inventory); - - BigDecimal itemRefundAmount = saleItem.getUnitPrice().multiply(BigDecimal.valueOf(itemRequest.getQuantity())); - - RefundItem refundItem = new RefundItem(); - refundItem.setRefund(refund); - refundItem.setSaleItem(saleItem); - refundItem.setQuantity(itemRequest.getQuantity()); - refundItem.setRefundAmount(itemRefundAmount); - - refundItems.add(refundItem); - totalRefundAmount = totalRefundAmount.add(itemRefundAmount); - } - - refund.setRefundAmount(totalRefundAmount); - refund.setItems(refundItems); - - Refund savedRefund = refundRepository.save(refund); - return mapToResponse(savedRefund); - } - - private RefundResponse mapToResponse(Refund refund) { - RefundResponse response = new RefundResponse(); - response.setId(refund.getId()); - response.setSaleId(refund.getSale().getId()); - response.setRefundDate(refund.getRefundDate()); - response.setRefundAmount(refund.getRefundAmount()); - response.setRefundReason(refund.getRefundReason()); - response.setProcessedBy(refund.getProcessedBy().getId()); - response.setProcessedByName(refund.getProcessedBy().getFullName()); - response.setCreatedAt(refund.getCreatedAt()); - - List itemResponses = new ArrayList<>(); - for (RefundItem item : refund.getItems()) { - RefundResponse.RefundItemResponse itemResponse = new RefundResponse.RefundItemResponse(); - itemResponse.setId(item.getId()); - itemResponse.setSaleItemId(item.getSaleItem().getId()); - itemResponse.setProductId(item.getSaleItem().getProduct().getId()); - itemResponse.setProductName(item.getSaleItem().getProduct().getProductName()); - itemResponse.setQuantity(item.getQuantity()); - itemResponse.setRefundAmount(item.getRefundAmount()); - itemResponses.add(itemResponse); - } - response.setItems(itemResponses); - - return response; - } -} diff --git a/src/main/java/com/petshop/backend/service/SaleService.java b/src/main/java/com/petshop/backend/service/SaleService.java index 698a6c66..65b62f3e 100644 --- a/src/main/java/com/petshop/backend/service/SaleService.java +++ b/src/main/java/com/petshop/backend/service/SaleService.java @@ -22,18 +22,16 @@ public class SaleService { private final SaleRepository saleRepository; private final ProductRepository productRepository; - private final CustomerRepository customerRepository; private final StoreRepository storeRepository; private final InventoryRepository inventoryRepository; - private final UserRepository userRepository; + private final EmployeeRepository employeeRepository; - public SaleService(SaleRepository saleRepository, ProductRepository productRepository, CustomerRepository customerRepository, StoreRepository storeRepository, InventoryRepository inventoryRepository, UserRepository userRepository) { + public SaleService(SaleRepository saleRepository, ProductRepository productRepository, StoreRepository storeRepository, InventoryRepository inventoryRepository, EmployeeRepository employeeRepository) { this.saleRepository = saleRepository; this.productRepository = productRepository; - this.customerRepository = customerRepository; this.storeRepository = storeRepository; this.inventoryRepository = inventoryRepository; - this.userRepository = userRepository; + this.employeeRepository = employeeRepository; } public Page getAllSales(String query, Pageable pageable) { @@ -54,62 +52,58 @@ public class SaleService { @Transactional public SaleResponse createSale(SaleRequest request) { - String username = SecurityContextHolder.getContext().getAuthentication().getName(); - User employee = userRepository.findByUsername(username) - .orElseThrow(() -> new ResourceNotFoundException("User not found: " + username)); + Employee employee = employeeRepository.findAll().stream() + .findFirst() + .orElseThrow(() -> new ResourceNotFoundException("No employees found")); - Store store = storeRepository.findById(request.getStoreId()) + StoreLocation store = storeRepository.findById(request.getStoreId()) .orElseThrow(() -> new ResourceNotFoundException("Store not found with id: " + request.getStoreId())); - Customer customer = null; - if (request.getCustomerId() != null) { - customer = customerRepository.findById(request.getCustomerId()) - .orElseThrow(() -> new ResourceNotFoundException("Customer not found with id: " + request.getCustomerId())); - } - Sale sale = new Sale(); sale.setSaleDate(LocalDateTime.now()); sale.setEmployee(employee); - sale.setCustomer(customer); sale.setStore(store); sale.setPaymentMethod(request.getPaymentMethod()); - sale.setTax(request.getTax()); - sale.setNotes(request.getNotes()); + sale.setIsRefund(request.getIsRefund() != null ? request.getIsRefund() : false); - BigDecimal subtotal = BigDecimal.ZERO; + if (sale.getIsRefund() && request.getOriginalSaleId() != null) { + Sale originalSale = saleRepository.findById(request.getOriginalSaleId()) + .orElseThrow(() -> new ResourceNotFoundException("Original sale not found with id: " + request.getOriginalSaleId())); + sale.setOriginalSale(originalSale); + } + + BigDecimal totalAmount = BigDecimal.ZERO; List saleItems = new ArrayList<>(); for (var itemRequest : request.getItems()) { - Product product = productRepository.findById(itemRequest.getProductId()) - .orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + itemRequest.getProductId())); + Product product = productRepository.findById(itemRequest.getProdId()) + .orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + itemRequest.getProdId())); - Inventory inventory = inventoryRepository.findByProductIdAndStoreId(itemRequest.getProductId(), request.getStoreId()) - .orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " + itemRequest.getProductId() + " at store " + request.getStoreId())); + Inventory inventory = inventoryRepository.findByProductId(itemRequest.getProdId()) + .orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " + itemRequest.getProdId())); if (inventory.getQuantity() < itemRequest.getQuantity()) { - throw new BusinessException("Insufficient stock for product: " + product.getProductName() + + throw new BusinessException("Insufficient stock for product: " + product.getProdName() + ". Available: " + inventory.getQuantity() + ", requested: " + itemRequest.getQuantity()); } inventory.setQuantity(inventory.getQuantity() - itemRequest.getQuantity()); inventoryRepository.save(inventory); - BigDecimal unitPrice = product.getProductPrice(); - BigDecimal itemSubtotal = unitPrice.multiply(BigDecimal.valueOf(itemRequest.getQuantity())); + BigDecimal unitPrice = product.getProdPrice(); + BigDecimal itemTotal = unitPrice.multiply(BigDecimal.valueOf(itemRequest.getQuantity())); SaleItem saleItem = new SaleItem(); saleItem.setSale(sale); saleItem.setProduct(product); saleItem.setQuantity(itemRequest.getQuantity()); saleItem.setUnitPrice(unitPrice); - saleItem.setSubtotal(itemSubtotal); saleItems.add(saleItem); - subtotal = subtotal.add(itemSubtotal); + totalAmount = totalAmount.add(itemTotal); } - sale.setSubtotal(subtotal); - sale.setTotal(subtotal.add(sale.getTax())); + sale.setTotalAmount(totalAmount); sale.setItems(saleItems); Sale savedSale = saleRepository.save(sale); @@ -118,37 +112,32 @@ public class SaleService { private SaleResponse mapToResponse(Sale sale) { SaleResponse response = new SaleResponse(); - response.setId(sale.getId()); + response.setSaleId(sale.getSaleId()); response.setSaleDate(sale.getSaleDate()); - response.setEmployeeId(sale.getEmployee().getId()); - response.setEmployeeName(sale.getEmployee().getFullName()); - - if (sale.getCustomer() != null) { - response.setCustomerId(sale.getCustomer().getId()); - response.setCustomerName(sale.getCustomer().getCustomerName()); - } + response.setEmployeeId(sale.getEmployee().getEmployeeId()); + response.setEmployeeName(sale.getEmployee().getFirstName() + " " + sale.getEmployee().getLastName()); if (sale.getStore() != null) { - response.setStoreId(sale.getStore().getId()); + response.setStoreId(sale.getStore().getStoreId()); response.setStoreName(sale.getStore().getStoreName()); } - response.setSubtotal(sale.getSubtotal()); - response.setTax(sale.getTax()); - response.setTotal(sale.getTotal()); + response.setTotalAmount(sale.getTotalAmount()); response.setPaymentMethod(sale.getPaymentMethod()); - response.setNotes(sale.getNotes()); + response.setIsRefund(sale.getIsRefund()); + if (sale.getOriginalSale() != null) { + response.setOriginalSaleId(sale.getOriginalSale().getSaleId()); + } response.setCreatedAt(sale.getCreatedAt()); List itemResponses = new ArrayList<>(); for (SaleItem item : sale.getItems()) { SaleResponse.SaleItemResponse itemResponse = new SaleResponse.SaleItemResponse(); - itemResponse.setId(item.getId()); - itemResponse.setProductId(item.getProduct().getId()); - itemResponse.setProductName(item.getProduct().getProductName()); + itemResponse.setSaleItemId(item.getSaleItemId()); + itemResponse.setProdId(item.getProduct().getProdId()); + itemResponse.setProductName(item.getProduct().getProdName()); itemResponse.setQuantity(item.getQuantity()); itemResponse.setUnitPrice(item.getUnitPrice()); - itemResponse.setSubtotal(item.getSubtotal()); itemResponses.add(itemResponse); } response.setItems(itemResponses); diff --git a/src/main/java/com/petshop/backend/service/ServiceService.java b/src/main/java/com/petshop/backend/service/ServiceService.java index 72e5662f..5243f101 100644 --- a/src/main/java/com/petshop/backend/service/ServiceService.java +++ b/src/main/java/com/petshop/backend/service/ServiceService.java @@ -39,10 +39,9 @@ public class ServiceService { public ServiceResponse createService(ServiceRequest request) { com.petshop.backend.entity.Service service = new com.petshop.backend.entity.Service(); service.setServiceName(request.getServiceName()); - service.setServiceDescription(request.getServiceDescription()); + service.setServiceDesc(request.getServiceDesc()); service.setServicePrice(request.getServicePrice()); - service.setServiceDurationMinutes(request.getServiceDurationMinutes()); - service.setActive(request.getActive() != null ? request.getActive() : true); + service.setServiceDuration(request.getServiceDuration()); service = serviceRepository.save(service); return mapToResponse(service); @@ -54,10 +53,9 @@ public class ServiceService { .orElseThrow(() -> new ResourceNotFoundException("Service not found with id: " + id)); service.setServiceName(request.getServiceName()); - service.setServiceDescription(request.getServiceDescription()); + service.setServiceDesc(request.getServiceDesc()); service.setServicePrice(request.getServicePrice()); - service.setServiceDurationMinutes(request.getServiceDurationMinutes()); - service.setActive(request.getActive() != null ? request.getActive() : true); + service.setServiceDuration(request.getServiceDuration()); service = serviceRepository.save(service); return mapToResponse(service); @@ -78,12 +76,11 @@ public class ServiceService { private ServiceResponse mapToResponse(com.petshop.backend.entity.Service service) { return new ServiceResponse( - service.getId(), + service.getServiceId(), service.getServiceName(), - service.getServiceDescription(), + service.getServiceDesc(), service.getServicePrice(), - service.getServiceDurationMinutes(), - service.getActive(), + service.getServiceDuration(), service.getCreatedAt(), service.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/StoreService.java b/src/main/java/com/petshop/backend/service/StoreService.java index 79ab3c47..2d7564e7 100644 --- a/src/main/java/com/petshop/backend/service/StoreService.java +++ b/src/main/java/com/petshop/backend/service/StoreService.java @@ -1,7 +1,7 @@ package com.petshop.backend.service; import com.petshop.backend.dto.store.StoreResponse; -import com.petshop.backend.entity.Store; +import com.petshop.backend.entity.StoreLocation; import com.petshop.backend.repository.StoreRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -17,7 +17,7 @@ public class StoreService { } public Page getAllStores(String query, Pageable pageable) { - Page stores; + Page stores; if (query != null && !query.trim().isEmpty()) { stores = storeRepository.searchStores(query, pageable); } else { @@ -26,11 +26,13 @@ public class StoreService { return stores.map(this::mapToResponse); } - private StoreResponse mapToResponse(Store store) { + private StoreResponse mapToResponse(StoreLocation store) { return new StoreResponse( - store.getId(), + store.getStoreId(), store.getStoreName(), - store.getStoreLocation(), + store.getAddress(), + store.getPhone(), + store.getEmail(), store.getCreatedAt() ); } diff --git a/src/main/java/com/petshop/backend/service/SupplierService.java b/src/main/java/com/petshop/backend/service/SupplierService.java index b234b759..2e80eeaa 100644 --- a/src/main/java/com/petshop/backend/service/SupplierService.java +++ b/src/main/java/com/petshop/backend/service/SupplierService.java @@ -39,12 +39,11 @@ public class SupplierService { @Transactional public SupplierResponse createSupplier(SupplierRequest request) { Supplier supplier = new Supplier(); - supplier.setSupplierName(request.getSupName()); - supplier.setSupplierContact(request.getSupContact()); - supplier.setSupplierEmail(request.getSupEmail()); - supplier.setSupplierPhone(request.getSupPhone()); - supplier.setSupplierAddress(request.getSupAddress()); - supplier.setActive(request.getActive()); + supplier.setSupCompany(request.getSupCompany()); + supplier.setSupContactFirstName(request.getSupContactFirstName()); + supplier.setSupContactLastName(request.getSupContactLastName()); + supplier.setSupEmail(request.getSupEmail()); + supplier.setSupPhone(request.getSupPhone()); supplier = supplierRepository.save(supplier); return mapToResponse(supplier); @@ -55,12 +54,11 @@ public class SupplierService { Supplier supplier = supplierRepository.findById(id) .orElseThrow(() -> new ResourceNotFoundException("Supplier not found with id: " + id)); - supplier.setSupplierName(request.getSupName()); - supplier.setSupplierContact(request.getSupContact()); - supplier.setSupplierEmail(request.getSupEmail()); - supplier.setSupplierPhone(request.getSupPhone()); - supplier.setSupplierAddress(request.getSupAddress()); - supplier.setActive(request.getActive()); + supplier.setSupCompany(request.getSupCompany()); + supplier.setSupContactFirstName(request.getSupContactFirstName()); + supplier.setSupContactLastName(request.getSupContactLastName()); + supplier.setSupEmail(request.getSupEmail()); + supplier.setSupPhone(request.getSupPhone()); supplier = supplierRepository.save(supplier); return mapToResponse(supplier); @@ -81,13 +79,12 @@ public class SupplierService { private SupplierResponse mapToResponse(Supplier supplier) { return new SupplierResponse( - supplier.getId(), - supplier.getSupplierName(), - supplier.getSupplierContact(), - supplier.getSupplierEmail(), - supplier.getSupplierPhone(), - supplier.getSupplierAddress(), - supplier.getActive(), + supplier.getSupId(), + supplier.getSupCompany(), + supplier.getSupContactFirstName(), + supplier.getSupContactLastName(), + supplier.getSupEmail(), + supplier.getSupPhone(), supplier.getCreatedAt(), supplier.getUpdatedAt() ); diff --git a/src/main/java/com/petshop/backend/service/UserService.java b/src/main/java/com/petshop/backend/service/UserService.java index e1317aa7..183d05d9 100644 --- a/src/main/java/com/petshop/backend/service/UserService.java +++ b/src/main/java/com/petshop/backend/service/UserService.java @@ -44,10 +44,7 @@ public class UserService { User user = new User(); user.setUsername(request.getUsername()); user.setPassword(passwordEncoder.encode(request.getPassword())); - user.setFullName(request.getFullName()); - user.setEmail(request.getEmail()); user.setRole(request.getRole()); - user.setActive(request.getActive()); user = userRepository.save(user); return mapToResponse(user); @@ -62,10 +59,7 @@ public class UserService { if (request.getPassword() != null && !request.getPassword().trim().isEmpty()) { user.setPassword(passwordEncoder.encode(request.getPassword())); } - user.setFullName(request.getFullName()); - user.setEmail(request.getEmail()); user.setRole(request.getRole()); - user.setActive(request.getActive()); user = userRepository.save(user); return mapToResponse(user); @@ -85,15 +79,10 @@ public class UserService { } private UserResponse mapToResponse(User user) { - return new UserResponse( - user.getId(), - user.getUsername(), - user.getFullName(), - user.getEmail(), - user.getRole().toString(), - user.getActive(), - user.getCreatedAt(), - user.getUpdatedAt() - ); + UserResponse response = new UserResponse(); + response.setId(user.getId()); + response.setUsername(user.getUsername()); + response.setRole(user.getRole().toString()); + return response; } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 315667e7..f04fe658 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,7 +10,9 @@ spring: jpa: hibernate: - ddl-auto: update + ddl-auto: validate + naming: + physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl show-sql: ${JPA_SHOW_SQL:false} properties: hibernate: diff --git a/test_endpoints.sh b/test_endpoints.sh deleted file mode 100755 index d310bbe6..00000000 --- a/test_endpoints.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -ADMIN_TOKEN="eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTc3MjczMzAxOSwiZXhwIjoxNzcyODE5NDE5fQ.__RqJbY2_HMjMlF6MoU8LagTu8pxjmizYYg4BQ0ahxRn9PV5iSQO3WRnCnujyE04AOY5yjTDEakOZOTEpiDFSw" -STAFF_TOKEN="eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdGFmZiIsImlhdCI6MTc3MjczMzAyMCwiZXhwIjoxNzcyODE5NDIwfQ.m7jC_QMWmJsj-kc4Qb-9cQwUEnJEAYJ7mbpKJOMISSup1rONwloN3Heio6Iw5ysIkjNt6uZbwIX2SZygbxQSVg" -BASE_URL="http://localhost:8080/api/v1" - -PASS=0 -FAIL=0 -TOTAL=0 - -test_endpoint() { - local method=$1 - local path=$2 - local token=$3 - local expected_status=$4 - local data=$5 - local desc=$6 - - TOTAL=$((TOTAL + 1)) - - if [ -z "$data" ]; then - response=$(curl -s -w "\n%{http_code}" -X $method "$BASE_URL$path" -H "Authorization: Bearer $token" -H "Content-Type: application/json") - else - response=$(curl -s -w "\n%{http_code}" -X $method "$BASE_URL$path" -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d "$data") - fi - - status=$(echo "$response" | tail -n1) - body=$(echo "$response" | head -n-1) - - if [ "$status" = "$expected_status" ]; then - echo "✓ PASS: $desc ($method $path) - $status" - PASS=$((PASS + 1)) - echo "$body" | jq '.' 2>/dev/null || echo "$body" - else - echo "✗ FAIL: $desc ($method $path) - Expected $expected_status, got $status" - FAIL=$((FAIL + 1)) - echo "$body" - fi - echo "---" -} - -echo "=========================================" -echo "PHASE 1: DROPDOWN ENDPOINTS (7 endpoints)" -echo "=========================================" - -test_endpoint "GET" "/dropdowns/pets" "$STAFF_TOKEN" "200" "" "Get pets dropdown" -test_endpoint "GET" "/dropdowns/customers" "$STAFF_TOKEN" "200" "" "Get customers dropdown" -test_endpoint "GET" "/dropdowns/services" "$STAFF_TOKEN" "200" "" "Get services dropdown" -test_endpoint "GET" "/dropdowns/products" "$STAFF_TOKEN" "200" "" "Get products dropdown" -test_endpoint "GET" "/dropdowns/categories" "$STAFF_TOKEN" "200" "" "Get categories dropdown" -test_endpoint "GET" "/dropdowns/stores" "$STAFF_TOKEN" "200" "" "Get stores dropdown" -test_endpoint "GET" "/dropdowns/suppliers" "$ADMIN_TOKEN" "200" "" "Get suppliers dropdown (admin)" - -echo "" -echo "=========================================" -echo "SUMMARY: Phase 1" -echo "=========================================" -echo "Total: $TOTAL | Pass: $PASS | Fail: $FAIL"