Merge pull request #1 from RecentRunner/fixes

Fixes
This commit is contained in:
2026-03-07 12:19:52 -07:00
committed by GitHub
95 changed files with 2422 additions and 2987 deletions

394
Petstoredata.sql Normal file
View File

@@ -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');

View File

@@ -11,6 +11,7 @@ services:
- "3306:3306" - "3306:3306"
volumes: volumes:
- db_data:/var/lib/mysql - db_data:/var/lib/mysql
- ./sql:/docker-entrypoint-initdb.d
healthcheck: healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"] test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uroot", "-proot"]
interval: 5s interval: 5s
@@ -24,8 +25,8 @@ services:
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/Petstoredb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/Petstoredb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
SPRING_DATASOURCE_USERNAME: petshop SPRING_DATASOURCE_USERNAME: petshop
SPRING_DATASOURCE_PASSWORD: petshop SPRING_DATASOURCE_PASSWORD: petshop
# Change this in real use # Change this in real use (must be at least 32 characters)
JWT_SECRET: change_me_please JWT_SECRET: change_me_please_this_secret_key_is_long_enough_for_jwt_hmac_sha256
ports: ports:
- "8080:8080" - "8080:8080"
depends_on: depends_on:

436
sql/01_petstore_init.sql Normal file
View File

@@ -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)

View File

@@ -23,10 +23,7 @@ public class DataInitializer implements CommandLineRunner {
User admin = new User(); User admin = new User();
admin.setUsername("admin"); admin.setUsername("admin");
admin.setPassword(passwordEncoder.encode("admin123")); admin.setPassword(passwordEncoder.encode("admin123"));
admin.setFullName("Admin User");
admin.setEmail("admin@petshop.com");
admin.setRole(User.Role.ADMIN); admin.setRole(User.Role.ADMIN);
admin.setActive(true);
userRepository.save(admin); userRepository.save(admin);
} }
@@ -34,10 +31,7 @@ public class DataInitializer implements CommandLineRunner {
User staff = new User(); User staff = new User();
staff.setUsername("staff"); staff.setUsername("staff");
staff.setPassword(passwordEncoder.encode("staff123")); staff.setPassword(passwordEncoder.encode("staff123"));
staff.setFullName("Staff User");
staff.setEmail("staff@petshop.com");
staff.setRole(User.Role.STAFF); staff.setRole(User.Role.STAFF);
staff.setActive(true);
userRepository.save(staff); userRepository.save(staff);
} }
} }

View File

@@ -2,7 +2,6 @@ package com.petshop.backend.controller;
import com.petshop.backend.dto.auth.LoginRequest; import com.petshop.backend.dto.auth.LoginRequest;
import com.petshop.backend.dto.auth.LoginResponse; 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.dto.auth.UserInfoResponse;
import com.petshop.backend.entity.User; import com.petshop.backend.entity.User;
import com.petshop.backend.repository.UserRepository; import com.petshop.backend.repository.UserRepository;
@@ -39,40 +38,6 @@ public class AuthController {
this.passwordEncoder = passwordEncoder; this.passwordEncoder = passwordEncoder;
} }
@PostMapping("/register")
public ResponseEntity<?> register(@Valid @RequestBody RegisterRequest request) {
if (userRepository.findByUsername(request.getEmail()).isPresent()) {
Map<String, String> 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") @PostMapping("/login")
public ResponseEntity<?> login(@Valid @RequestBody LoginRequest request) { public ResponseEntity<?> login(@Valid @RequestBody LoginRequest request) {
try { try {
@@ -94,7 +59,6 @@ public class AuthController {
return ResponseEntity.ok(new LoginResponse( return ResponseEntity.ok(new LoginResponse(
token, token,
user.getUsername(), user.getUsername(),
user.getFullName(),
user.getRole().name() user.getRole().name()
)); ));
@@ -116,8 +80,6 @@ public class AuthController {
return ResponseEntity.ok(new UserInfoResponse( return ResponseEntity.ok(new UserInfoResponse(
user.getId(), user.getId(),
user.getUsername(), user.getUsername(),
user.getFullName(),
user.getEmail(),
user.getRole().name() user.getRole().name()
)); ));
} }

View File

@@ -40,7 +40,7 @@ public class DropdownController {
public ResponseEntity<List<DropdownOption>> getPets() { public ResponseEntity<List<DropdownOption>> getPets() {
return ResponseEntity.ok( return ResponseEntity.ok(
petRepository.findAll().stream() petRepository.findAll().stream()
.map(p -> new DropdownOption(p.getId(), p.getPetName())) .map(p -> new DropdownOption(p.getPetId(), p.getPetName()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
} }
@@ -49,7 +49,7 @@ public class DropdownController {
public ResponseEntity<List<DropdownOption>> getCustomers() { public ResponseEntity<List<DropdownOption>> getCustomers() {
return ResponseEntity.ok( return ResponseEntity.ok(
customerRepository.findAll().stream() customerRepository.findAll().stream()
.map(c -> new DropdownOption(c.getId(), c.getCustomerName())) .map(c -> new DropdownOption(c.getCustomerId(), c.getFirstName() + " " + c.getLastName()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
} }
@@ -58,7 +58,7 @@ public class DropdownController {
public ResponseEntity<List<DropdownOption>> getServices() { public ResponseEntity<List<DropdownOption>> getServices() {
return ResponseEntity.ok( return ResponseEntity.ok(
serviceRepository.findAll().stream() serviceRepository.findAll().stream()
.map(s -> new DropdownOption(s.getId(), s.getServiceName())) .map(s -> new DropdownOption(s.getServiceId(), s.getServiceName()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
} }
@@ -67,7 +67,7 @@ public class DropdownController {
public ResponseEntity<List<DropdownOption>> getProducts() { public ResponseEntity<List<DropdownOption>> getProducts() {
return ResponseEntity.ok( return ResponseEntity.ok(
productRepository.findAll().stream() productRepository.findAll().stream()
.map(p -> new DropdownOption(p.getId(), p.getProductName())) .map(p -> new DropdownOption(p.getProdId(), p.getProdName()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
} }
@@ -76,7 +76,7 @@ public class DropdownController {
public ResponseEntity<List<DropdownOption>> getCategories() { public ResponseEntity<List<DropdownOption>> getCategories() {
return ResponseEntity.ok( return ResponseEntity.ok(
categoryRepository.findAll().stream() categoryRepository.findAll().stream()
.map(c -> new DropdownOption(c.getId(), c.getCategoryName())) .map(c -> new DropdownOption(c.getCategoryId(), c.getCategoryName()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
} }
@@ -85,7 +85,7 @@ public class DropdownController {
public ResponseEntity<List<DropdownOption>> getStores() { public ResponseEntity<List<DropdownOption>> getStores() {
return ResponseEntity.ok( return ResponseEntity.ok(
storeRepository.findAll().stream() storeRepository.findAll().stream()
.map(s -> new DropdownOption(s.getId(), s.getStoreName())) .map(s -> new DropdownOption(s.getStoreId(), s.getStoreName()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
} }
@@ -95,7 +95,7 @@ public class DropdownController {
public ResponseEntity<List<DropdownOption>> getSuppliers() { public ResponseEntity<List<DropdownOption>> getSuppliers() {
return ResponseEntity.ok( return ResponseEntity.ok(
supplierRepository.findAll().stream() supplierRepository.findAll().stream()
.map(s -> new DropdownOption(s.getId(), s.getSupplierName())) .map(s -> new DropdownOption(s.getSupId(), s.getSupCompany()))
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
} }

View File

@@ -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<RefundResponse> createRefund(
@PathVariable Long saleId,
@Valid @RequestBody RefundRequest request) {
return ResponseEntity.status(HttpStatus.CREATED).body(refundService.createRefund(saleId, request));
}
}

View File

@@ -1,8 +1,7 @@
package com.petshop.backend.dto.adoption; package com.petshop.backend.dto.adoption;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Objects; import java.util.Objects;
@@ -16,11 +15,8 @@ public class AdoptionRequest {
@NotNull(message = "Adoption date is required") @NotNull(message = "Adoption date is required")
private LocalDate adoptionDate; private LocalDate adoptionDate;
@NotNull(message = "Adoption fee is required") @NotBlank(message = "Adoption status is required")
@Positive(message = "Adoption fee must be positive") private String adoptionStatus;
private BigDecimal adoptionFee;
private String notes;
public Long getPetId() { public Long getPetId() {
return petId; return petId;
@@ -46,20 +42,12 @@ public class AdoptionRequest {
this.adoptionDate = adoptionDate; this.adoptionDate = adoptionDate;
} }
public BigDecimal getAdoptionFee() { public String getAdoptionStatus() {
return adoptionFee; return adoptionStatus;
} }
public void setAdoptionFee(BigDecimal adoptionFee) { public void setAdoptionStatus(String adoptionStatus) {
this.adoptionFee = adoptionFee; this.adoptionStatus = adoptionStatus;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
} }
@Override @Override
@@ -70,13 +58,12 @@ public class AdoptionRequest {
return Objects.equals(petId, that.petId) && return Objects.equals(petId, that.petId) &&
Objects.equals(customerId, that.customerId) && Objects.equals(customerId, that.customerId) &&
Objects.equals(adoptionDate, that.adoptionDate) && Objects.equals(adoptionDate, that.adoptionDate) &&
Objects.equals(adoptionFee, that.adoptionFee) && Objects.equals(adoptionStatus, that.adoptionStatus);
Objects.equals(notes, that.notes);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(petId, customerId, adoptionDate, adoptionFee, notes); return Objects.hash(petId, customerId, adoptionDate, adoptionStatus);
} }
@Override @Override
@@ -85,8 +72,7 @@ public class AdoptionRequest {
"petId=" + petId + "petId=" + petId +
", customerId=" + customerId + ", customerId=" + customerId +
", adoptionDate=" + adoptionDate + ", adoptionDate=" + adoptionDate +
", adoptionFee=" + adoptionFee + ", adoptionStatus='" + adoptionStatus + '\'' +
", notes='" + notes + '\'' +
'}'; '}';
} }
} }

View File

@@ -1,44 +1,41 @@
package com.petshop.backend.dto.adoption; package com.petshop.backend.dto.adoption;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class AdoptionResponse { public class AdoptionResponse {
private Long id; private Long adoptionId;
private Long petId; private Long petId;
private String petName; private String petName;
private Long customerId; private Long customerId;
private String customerName; private String customerName;
private LocalDate adoptionDate; private LocalDate adoptionDate;
private BigDecimal adoptionFee; private String adoptionStatus;
private String notes;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public AdoptionResponse() { public AdoptionResponse() {
} }
public AdoptionResponse(Long id, Long petId, String petName, Long customerId, String customerName, LocalDate adoptionDate, BigDecimal adoptionFee, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) { public AdoptionResponse(Long adoptionId, Long petId, String petName, Long customerId, String customerName, LocalDate adoptionDate, String adoptionStatus, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.adoptionId = adoptionId;
this.petId = petId; this.petId = petId;
this.petName = petName; this.petName = petName;
this.customerId = customerId; this.customerId = customerId;
this.customerName = customerName; this.customerName = customerName;
this.adoptionDate = adoptionDate; this.adoptionDate = adoptionDate;
this.adoptionFee = adoptionFee; this.adoptionStatus = adoptionStatus;
this.notes = notes;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getAdoptionId() {
return id; return adoptionId;
} }
public void setId(Long id) { public void setAdoptionId(Long adoptionId) {
this.id = id; this.adoptionId = adoptionId;
} }
public Long getPetId() { public Long getPetId() {
@@ -81,20 +78,12 @@ public class AdoptionResponse {
this.adoptionDate = adoptionDate; this.adoptionDate = adoptionDate;
} }
public BigDecimal getAdoptionFee() { public String getAdoptionStatus() {
return adoptionFee; return adoptionStatus;
} }
public void setAdoptionFee(BigDecimal adoptionFee) { public void setAdoptionStatus(String adoptionStatus) {
this.adoptionFee = adoptionFee; this.adoptionStatus = adoptionStatus;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -118,25 +107,24 @@ public class AdoptionResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
AdoptionResponse that = (AdoptionResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "AdoptionResponse{" + return "AdoptionResponse{" +
"id=" + id + "adoptionId=" + adoptionId +
", petId=" + petId + ", petId=" + petId +
", petName='" + petName + '\'' + ", petName='" + petName + '\'' +
", customerId=" + customerId + ", customerId=" + customerId +
", customerName='" + customerName + '\'' + ", customerName='" + customerName + '\'' +
", adoptionDate=" + adoptionDate + ", adoptionDate=" + adoptionDate +
", adoptionFee=" + adoptionFee + ", adoptionStatus='" + adoptionStatus + '\'' +
", notes='" + notes + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -1,6 +1,5 @@
package com.petshop.backend.dto.appointment; package com.petshop.backend.dto.appointment;
import com.petshop.backend.entity.Appointment;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.time.LocalDate; import java.time.LocalDate;
@@ -21,14 +20,12 @@ public class AppointmentRequest {
@NotNull(message = "Appointment time is required") @NotNull(message = "Appointment time is required")
private LocalTime appointmentTime; private LocalTime appointmentTime;
@NotNull(message = "Status is required") @NotNull(message = "Appointment status is required")
private Appointment.AppointmentStatus status; private String appointmentStatus;
@NotEmpty(message = "At least one pet must be specified") @NotEmpty(message = "At least one pet must be specified")
private List<Long> petIds; private List<Long> petIds;
private String notes;
public Long getCustomerId() { public Long getCustomerId() {
return customerId; return customerId;
} }
@@ -61,12 +58,12 @@ public class AppointmentRequest {
this.appointmentTime = appointmentTime; this.appointmentTime = appointmentTime;
} }
public Appointment.AppointmentStatus getStatus() { public String getAppointmentStatus() {
return status; return appointmentStatus;
} }
public void setStatus(Appointment.AppointmentStatus status) { public void setAppointmentStatus(String appointmentStatus) {
this.status = status; this.appointmentStatus = appointmentStatus;
} }
public List<Long> getPetIds() { public List<Long> getPetIds() {
@@ -77,14 +74,6 @@ public class AppointmentRequest {
this.petIds = petIds; this.petIds = petIds;
} }
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@@ -94,14 +83,13 @@ public class AppointmentRequest {
Objects.equals(serviceId, that.serviceId) && Objects.equals(serviceId, that.serviceId) &&
Objects.equals(appointmentDate, that.appointmentDate) && Objects.equals(appointmentDate, that.appointmentDate) &&
Objects.equals(appointmentTime, that.appointmentTime) && Objects.equals(appointmentTime, that.appointmentTime) &&
status == that.status && Objects.equals(appointmentStatus, that.appointmentStatus) &&
Objects.equals(petIds, that.petIds) && Objects.equals(petIds, that.petIds);
Objects.equals(notes, that.notes);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(customerId, serviceId, appointmentDate, appointmentTime, status, petIds, notes); return Objects.hash(customerId, serviceId, appointmentDate, appointmentTime, appointmentStatus, petIds);
} }
@Override @Override
@@ -111,9 +99,8 @@ public class AppointmentRequest {
", serviceId=" + serviceId + ", serviceId=" + serviceId +
", appointmentDate=" + appointmentDate + ", appointmentDate=" + appointmentDate +
", appointmentTime=" + appointmentTime + ", appointmentTime=" + appointmentTime +
", status=" + status + ", appointmentStatus='" + appointmentStatus + '\'' +
", petIds=" + petIds + ", petIds=" + petIds +
", notes='" + notes + '\'' +
'}'; '}';
} }
} }

View File

@@ -7,45 +7,43 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
public class AppointmentResponse { public class AppointmentResponse {
private Long id; private Long appointmentId;
private Long customerId; private Long customerId;
private String customerName; private String customerName;
private Long serviceId; private Long serviceId;
private String serviceName; private String serviceName;
private LocalDate appointmentDate; private LocalDate appointmentDate;
private LocalTime appointmentTime; private LocalTime appointmentTime;
private String status; private String appointmentStatus;
private List<String> petNames; private List<String> petNames;
private List<Long> petIds; private List<Long> petIds;
private String notes;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public AppointmentResponse() { public AppointmentResponse() {
} }
public AppointmentResponse(Long id, Long customerId, String customerName, Long serviceId, String serviceName, LocalDate appointmentDate, LocalTime appointmentTime, String status, List<String> petNames, List<Long> petIds, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) { public AppointmentResponse(Long appointmentId, Long customerId, String customerName, Long serviceId, String serviceName, LocalDate appointmentDate, LocalTime appointmentTime, String appointmentStatus, List<String> petNames, List<Long> petIds, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.appointmentId = appointmentId;
this.customerId = customerId; this.customerId = customerId;
this.customerName = customerName; this.customerName = customerName;
this.serviceId = serviceId; this.serviceId = serviceId;
this.serviceName = serviceName; this.serviceName = serviceName;
this.appointmentDate = appointmentDate; this.appointmentDate = appointmentDate;
this.appointmentTime = appointmentTime; this.appointmentTime = appointmentTime;
this.status = status; this.appointmentStatus = appointmentStatus;
this.petNames = petNames; this.petNames = petNames;
this.petIds = petIds; this.petIds = petIds;
this.notes = notes;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getAppointmentId() {
return id; return appointmentId;
} }
public void setId(Long id) { public void setAppointmentId(Long appointmentId) {
this.id = id; this.appointmentId = appointmentId;
} }
public Long getCustomerId() { public Long getCustomerId() {
@@ -96,12 +94,12 @@ public class AppointmentResponse {
this.appointmentTime = appointmentTime; this.appointmentTime = appointmentTime;
} }
public String getStatus() { public String getAppointmentStatus() {
return status; return appointmentStatus;
} }
public void setStatus(String status) { public void setAppointmentStatus(String appointmentStatus) {
this.status = status; this.appointmentStatus = appointmentStatus;
} }
public List<String> getPetNames() { public List<String> getPetNames() {
@@ -120,14 +118,6 @@ public class AppointmentResponse {
this.petIds = petIds; this.petIds = petIds;
} }
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
return createdAt; return createdAt;
} }
@@ -149,28 +139,27 @@ public class AppointmentResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
AppointmentResponse that = (AppointmentResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "AppointmentResponse{" + return "AppointmentResponse{" +
"id=" + id + "appointmentId=" + appointmentId +
", customerId=" + customerId + ", customerId=" + customerId +
", customerName='" + customerName + '\'' + ", customerName='" + customerName + '\'' +
", serviceId=" + serviceId + ", serviceId=" + serviceId +
", serviceName='" + serviceName + '\'' + ", serviceName='" + serviceName + '\'' +
", appointmentDate=" + appointmentDate + ", appointmentDate=" + appointmentDate +
", appointmentTime=" + appointmentTime + ", appointmentTime=" + appointmentTime +
", status='" + status + '\'' + ", appointmentStatus='" + appointmentStatus + '\'' +
", petNames=" + petNames + ", petNames=" + petNames +
", petIds=" + petIds + ", petIds=" + petIds +
", notes='" + notes + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -5,16 +5,14 @@ import java.util.Objects;
public class LoginResponse { public class LoginResponse {
private String token; private String token;
private String username; private String username;
private String fullName;
private String role; private String role;
public LoginResponse() { public LoginResponse() {
} }
public LoginResponse(String token, String username, String fullName, String role) { public LoginResponse(String token, String username, String role) {
this.token = token; this.token = token;
this.username = username; this.username = username;
this.fullName = fullName;
this.role = role; this.role = role;
} }
@@ -34,14 +32,6 @@ public class LoginResponse {
this.username = username; this.username = username;
} }
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getRole() { public String getRole() {
return role; return role;
} }
@@ -55,12 +45,12 @@ public class LoginResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
LoginResponse that = (LoginResponse) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(token, username, fullName, role); return Objects.hash(token, username, role);
} }
@Override @Override
@@ -68,7 +58,6 @@ public class LoginResponse {
return "LoginResponse{" + return "LoginResponse{" +
"token='" + token + '\'' + "token='" + token + '\'' +
", username='" + username + '\'' + ", username='" + username + '\'' +
", fullName='" + fullName + '\'' +
", role='" + role + '\'' + ", role='" + role + '\'' +
'}'; '}';
} }

View File

@@ -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]'" +
'}';
}
}

View File

@@ -5,18 +5,14 @@ import java.util.Objects;
public class UserInfoResponse { public class UserInfoResponse {
private Long id; private Long id;
private String username; private String username;
private String fullName;
private String email;
private String role; private String role;
public UserInfoResponse() { 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.id = id;
this.username = username; this.username = username;
this.fullName = fullName;
this.email = email;
this.role = role; this.role = role;
} }
@@ -36,22 +32,6 @@ public class UserInfoResponse {
this.username = username; 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() { public String getRole() {
return role; return role;
} }
@@ -65,12 +45,12 @@ public class UserInfoResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
UserInfoResponse that = (UserInfoResponse) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, username, fullName, email, role); return Objects.hash(id, username, role);
} }
@Override @Override
@@ -78,8 +58,6 @@ public class UserInfoResponse {
return "UserInfoResponse{" + return "UserInfoResponse{" +
"id=" + id + "id=" + id +
", username='" + username + '\'' + ", username='" + username + '\'' +
", fullName='" + fullName + '\'' +
", email='" + email + '\'' +
", role='" + role + '\'' + ", role='" + role + '\'' +
'}'; '}';
} }

View File

@@ -7,7 +7,7 @@ public class CategoryRequest {
@NotBlank(message = "Category name is required") @NotBlank(message = "Category name is required")
private String categoryName; private String categoryName;
private String categoryDescription; private String categoryType;
public String getCategoryName() { public String getCategoryName() {
return categoryName; return categoryName;
@@ -17,12 +17,12 @@ public class CategoryRequest {
this.categoryName = categoryName; this.categoryName = categoryName;
} }
public String getCategoryDescription() { public String getCategoryType() {
return categoryDescription; return categoryType;
} }
public void setCategoryDescription(String categoryDescription) { public void setCategoryType(String categoryType) {
this.categoryDescription = categoryDescription; this.categoryType = categoryType;
} }
@Override @Override
@@ -31,19 +31,19 @@ public class CategoryRequest {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
CategoryRequest that = (CategoryRequest) o; CategoryRequest that = (CategoryRequest) o;
return Objects.equals(categoryName, that.categoryName) && return Objects.equals(categoryName, that.categoryName) &&
Objects.equals(categoryDescription, that.categoryDescription); Objects.equals(categoryType, that.categoryType);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(categoryName, categoryDescription); return Objects.hash(categoryName, categoryType);
} }
@Override @Override
public String toString() { public String toString() {
return "CategoryRequest{" + return "CategoryRequest{" +
"categoryName='" + categoryName + '\'' + "categoryName='" + categoryName + '\'' +
", categoryDescription='" + categoryDescription + '\'' + ", categoryType='" + categoryType + '\'' +
'}'; '}';
} }
} }

View File

@@ -4,29 +4,29 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class CategoryResponse { public class CategoryResponse {
private Long id; private Long categoryId;
private String categoryName; private String categoryName;
private String categoryDescription; private String categoryType;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public CategoryResponse() { public CategoryResponse() {
} }
public CategoryResponse(Long id, String categoryName, String categoryDescription, LocalDateTime createdAt, LocalDateTime updatedAt) { public CategoryResponse(Long categoryId, String categoryName, String categoryType, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.categoryId = categoryId;
this.categoryName = categoryName; this.categoryName = categoryName;
this.categoryDescription = categoryDescription; this.categoryType = categoryType;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getCategoryId() {
return id; return categoryId;
} }
public void setId(Long id) { public void setCategoryId(Long categoryId) {
this.id = id; this.categoryId = categoryId;
} }
public String getCategoryName() { public String getCategoryName() {
@@ -37,12 +37,12 @@ public class CategoryResponse {
this.categoryName = categoryName; this.categoryName = categoryName;
} }
public String getCategoryDescription() { public String getCategoryType() {
return categoryDescription; return categoryType;
} }
public void setCategoryDescription(String categoryDescription) { public void setCategoryType(String categoryType) {
this.categoryDescription = categoryDescription; this.categoryType = categoryType;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -66,20 +66,20 @@ public class CategoryResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
CategoryResponse that = (CategoryResponse) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, categoryName, categoryDescription, createdAt, updatedAt); return Objects.hash(categoryId, categoryName, categoryType, createdAt, updatedAt);
} }
@Override @Override
public String toString() { public String toString() {
return "CategoryResponse{" + return "CategoryResponse{" +
"id=" + id + "categoryId=" + categoryId +
", categoryName='" + categoryName + '\'' + ", categoryName='" + categoryName + '\'' +
", categoryDescription='" + categoryDescription + '\'' + ", categoryType='" + categoryType + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -5,45 +5,47 @@ import jakarta.validation.constraints.NotBlank;
import java.util.Objects; import java.util.Objects;
public class CustomerRequest { public class CustomerRequest {
@NotBlank(message = "Customer name is required") @NotBlank(message = "First name is required")
private String customerName; private String firstName;
@NotBlank(message = "Last name is required")
private String lastName;
@Email(message = "Invalid email format") @Email(message = "Invalid email format")
private String customerEmail; private String email;
private String customerPhone; private String phone;
private String customerAddress;
public String getCustomerName() { public String getFirstName() {
return customerName; return firstName;
} }
public void setCustomerName(String customerName) { public void setFirstName(String firstName) {
this.customerName = customerName; this.firstName = firstName;
} }
public String getCustomerEmail() { public String getLastName() {
return customerEmail; return lastName;
} }
public void setCustomerEmail(String customerEmail) { public void setLastName(String lastName) {
this.customerEmail = customerEmail; this.lastName = lastName;
} }
public String getCustomerPhone() { public String getEmail() {
return customerPhone; return email;
} }
public void setCustomerPhone(String customerPhone) { public void setEmail(String email) {
this.customerPhone = customerPhone; this.email = email;
} }
public String getCustomerAddress() { public String getPhone() {
return customerAddress; return phone;
} }
public void setCustomerAddress(String customerAddress) { public void setPhone(String phone) {
this.customerAddress = customerAddress; this.phone = phone;
} }
@Override @Override
@@ -51,24 +53,24 @@ public class CustomerRequest {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
CustomerRequest that = (CustomerRequest) o; CustomerRequest that = (CustomerRequest) o;
return Objects.equals(customerName, that.customerName) && return Objects.equals(firstName, that.firstName) &&
Objects.equals(customerEmail, that.customerEmail) && Objects.equals(lastName, that.lastName) &&
Objects.equals(customerPhone, that.customerPhone) && Objects.equals(email, that.email) &&
Objects.equals(customerAddress, that.customerAddress); Objects.equals(phone, that.phone);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(customerName, customerEmail, customerPhone, customerAddress); return Objects.hash(firstName, lastName, email, phone);
} }
@Override @Override
public String toString() { public String toString() {
return "CustomerRequest{" + return "CustomerRequest{" +
"customerName='" + customerName + '\'' + "firstName='" + firstName + '\'' +
", customerEmail='" + customerEmail + '\'' + ", lastName='" + lastName + '\'' +
", customerPhone='" + customerPhone + '\'' + ", email='" + email + '\'' +
", customerAddress='" + customerAddress + '\'' + ", phone='" + phone + '\'' +
'}'; '}';
} }
} }

View File

@@ -4,65 +4,65 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class CustomerResponse { public class CustomerResponse {
private Long id; private Long customerId;
private String customerName; private String firstName;
private String customerEmail; private String lastName;
private String customerPhone; private String email;
private String customerAddress; private String phone;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public CustomerResponse() { public CustomerResponse() {
} }
public CustomerResponse(Long id, String customerName, String customerEmail, String customerPhone, String customerAddress, LocalDateTime createdAt, LocalDateTime updatedAt) { public CustomerResponse(Long customerId, String firstName, String lastName, String email, String phone, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.customerId = customerId;
this.customerName = customerName; this.firstName = firstName;
this.customerEmail = customerEmail; this.lastName = lastName;
this.customerPhone = customerPhone; this.email = email;
this.customerAddress = customerAddress; this.phone = phone;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getCustomerId() {
return id; return customerId;
} }
public void setId(Long id) { public void setCustomerId(Long customerId) {
this.id = id; this.customerId = customerId;
} }
public String getCustomerName() { public String getFirstName() {
return customerName; return firstName;
} }
public void setCustomerName(String customerName) { public void setFirstName(String firstName) {
this.customerName = customerName; this.firstName = firstName;
} }
public String getCustomerEmail() { public String getLastName() {
return customerEmail; return lastName;
} }
public void setCustomerEmail(String customerEmail) { public void setLastName(String lastName) {
this.customerEmail = customerEmail; this.lastName = lastName;
} }
public String getCustomerPhone() { public String getEmail() {
return customerPhone; return email;
} }
public void setCustomerPhone(String customerPhone) { public void setEmail(String email) {
this.customerPhone = customerPhone; this.email = email;
} }
public String getCustomerAddress() { public String getPhone() {
return customerAddress; return phone;
} }
public void setCustomerAddress(String customerAddress) { public void setPhone(String phone) {
this.customerAddress = customerAddress; this.phone = phone;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -86,22 +86,22 @@ public class CustomerResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
CustomerResponse that = (CustomerResponse) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, customerName, customerEmail, customerPhone, customerAddress, createdAt, updatedAt); return Objects.hash(customerId, firstName, lastName, email, phone, createdAt, updatedAt);
} }
@Override @Override
public String toString() { public String toString() {
return "CustomerResponse{" + return "CustomerResponse{" +
"id=" + id + "customerId=" + customerId +
", customerName='" + customerName + '\'' + ", firstName='" + firstName + '\'' +
", customerEmail='" + customerEmail + '\'' + ", lastName='" + lastName + '\'' +
", customerPhone='" + customerPhone + '\'' + ", email='" + email + '\'' +
", customerAddress='" + customerAddress + '\'' + ", phone='" + phone + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -8,15 +8,10 @@ public class InventoryRequest {
@NotNull(message = "Product ID is required") @NotNull(message = "Product ID is required")
private Long prodId; private Long prodId;
private Long storeId;
@NotNull(message = "Quantity is required") @NotNull(message = "Quantity is required")
@PositiveOrZero(message = "Quantity must be zero or positive") @PositiveOrZero(message = "Quantity must be zero or positive")
private Integer quantity; private Integer quantity;
@PositiveOrZero(message = "Reorder level must be zero or positive")
private Integer reorderLevel = 10;
public Long getProdId() { public Long getProdId() {
return prodId; return prodId;
} }
@@ -25,14 +20,6 @@ public class InventoryRequest {
this.prodId = prodId; this.prodId = prodId;
} }
public Long getStoreId() {
return storeId;
}
public void setStoreId(Long storeId) {
this.storeId = storeId;
}
public Integer getQuantity() { public Integer getQuantity() {
return quantity; return quantity;
} }
@@ -41,37 +28,25 @@ public class InventoryRequest {
this.quantity = quantity; this.quantity = quantity;
} }
public Integer getReorderLevel() {
return reorderLevel;
}
public void setReorderLevel(Integer reorderLevel) {
this.reorderLevel = reorderLevel;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
InventoryRequest that = (InventoryRequest) o; InventoryRequest that = (InventoryRequest) o;
return Objects.equals(prodId, that.prodId) && return Objects.equals(prodId, that.prodId) &&
Objects.equals(storeId, that.storeId) && Objects.equals(quantity, that.quantity);
Objects.equals(quantity, that.quantity) &&
Objects.equals(reorderLevel, that.reorderLevel);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(prodId, storeId, quantity, reorderLevel); return Objects.hash(prodId, quantity);
} }
@Override @Override
public String toString() { public String toString() {
return "InventoryRequest{" + return "InventoryRequest{" +
"prodId=" + prodId + "prodId=" + prodId +
", storeId=" + storeId +
", quantity=" + quantity + ", quantity=" + quantity +
", reorderLevel=" + reorderLevel +
'}'; '}';
} }
} }

View File

@@ -4,49 +4,41 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class InventoryResponse { public class InventoryResponse {
private Long id; private Long inventoryId;
private Long productId; private Long prodId;
private String productName; private String productName;
private String categoryName; private String categoryName;
private Long storeId;
private String storeName;
private Integer quantity; private Integer quantity;
private Integer reorderLevel;
private LocalDateTime lastRestocked;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public InventoryResponse() { 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) { public InventoryResponse(Long inventoryId, Long prodId, String productName, String categoryName, Integer quantity, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.inventoryId = inventoryId;
this.productId = productId; this.prodId = prodId;
this.productName = productName; this.productName = productName;
this.categoryName = categoryName; this.categoryName = categoryName;
this.storeId = storeId;
this.storeName = storeName;
this.quantity = quantity; this.quantity = quantity;
this.reorderLevel = reorderLevel;
this.lastRestocked = lastRestocked;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getInventoryId() {
return id; return inventoryId;
} }
public void setId(Long id) { public void setInventoryId(Long inventoryId) {
this.id = id; this.inventoryId = inventoryId;
} }
public Long getProductId() { public Long getProdId() {
return productId; return prodId;
} }
public void setProductId(Long productId) { public void setProdId(Long prodId) {
this.productId = productId; this.prodId = prodId;
} }
public String getProductName() { public String getProductName() {
@@ -65,22 +57,6 @@ public class InventoryResponse {
this.categoryName = categoryName; 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() { public Integer getQuantity() {
return quantity; return quantity;
} }
@@ -89,22 +65,6 @@ public class InventoryResponse {
this.quantity = quantity; 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() { public LocalDateTime getCreatedAt() {
return createdAt; return createdAt;
} }
@@ -126,26 +86,22 @@ public class InventoryResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
InventoryResponse that = (InventoryResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "InventoryResponse{" + return "InventoryResponse{" +
"id=" + id + "inventoryId=" + inventoryId +
", productId=" + productId + ", prodId=" + prodId +
", productName='" + productName + '\'' + ", productName='" + productName + '\'' +
", categoryName='" + categoryName + '\'' + ", categoryName='" + categoryName + '\'' +
", storeId=" + storeId +
", storeName='" + storeName + '\'' +
", quantity=" + quantity + ", quantity=" + quantity +
", reorderLevel=" + reorderLevel +
", lastRestocked=" + lastRestocked +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -1,6 +1,5 @@
package com.petshop.backend.dto.pet; package com.petshop.backend.dto.pet;
import com.petshop.backend.entity.Pet;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive; import jakarta.validation.constraints.Positive;
@@ -20,7 +19,7 @@ public class PetRequest {
private Integer petAge; private Integer petAge;
@NotNull(message = "Status is required") @NotNull(message = "Status is required")
private Pet.PetStatus petStatus; private String petStatus;
private BigDecimal petPrice; private BigDecimal petPrice;
@@ -56,11 +55,11 @@ public class PetRequest {
this.petAge = petAge; this.petAge = petAge;
} }
public Pet.PetStatus getPetStatus() { public String getPetStatus() {
return petStatus; return petStatus;
} }
public void setPetStatus(Pet.PetStatus petStatus) { public void setPetStatus(String petStatus) {
this.petStatus = petStatus; this.petStatus = petStatus;
} }

View File

@@ -5,7 +5,7 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class PetResponse { public class PetResponse {
private Long id; private Long petId;
private String petName; private String petName;
private String petSpecies; private String petSpecies;
private String petBreed; private String petBreed;
@@ -18,8 +18,8 @@ public class PetResponse {
public PetResponse() { public PetResponse() {
} }
public PetResponse(Long id, String petName, String petSpecies, String petBreed, Integer petAge, String petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { public PetResponse(Long petId, String petName, String petSpecies, String petBreed, Integer petAge, String petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.petId = petId;
this.petName = petName; this.petName = petName;
this.petSpecies = petSpecies; this.petSpecies = petSpecies;
this.petBreed = petBreed; this.petBreed = petBreed;
@@ -30,12 +30,12 @@ public class PetResponse {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getPetId() {
return id; return petId;
} }
public void setId(Long id) { public void setPetId(Long petId) {
this.id = id; this.petId = petId;
} }
public String getPetName() { public String getPetName() {
@@ -107,18 +107,18 @@ public class PetResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
PetResponse that = (PetResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "PetResponse{" + return "PetResponse{" +
"id=" + id + "petId=" + petId +
", petName='" + petName + '\'' + ", petName='" + petName + '\'' +
", petSpecies='" + petSpecies + '\'' + ", petSpecies='" + petSpecies + '\'' +
", petBreed='" + petBreed + '\'' + ", petBreed='" + petBreed + '\'' +

View File

@@ -19,8 +19,6 @@ public class ProductRequest {
@Positive(message = "Price must be positive") @Positive(message = "Price must be positive")
private BigDecimal prodPrice; private BigDecimal prodPrice;
private Boolean active = true;
public String getProdName() { public String getProdName() {
return prodName; return prodName;
} }
@@ -53,14 +51,6 @@ public class ProductRequest {
this.prodPrice = prodPrice; this.prodPrice = prodPrice;
} }
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@@ -69,13 +59,12 @@ public class ProductRequest {
return Objects.equals(prodName, that.prodName) && return Objects.equals(prodName, that.prodName) &&
Objects.equals(categoryId, that.categoryId) && Objects.equals(categoryId, that.categoryId) &&
Objects.equals(prodDesc, that.prodDesc) && Objects.equals(prodDesc, that.prodDesc) &&
Objects.equals(prodPrice, that.prodPrice) && Objects.equals(prodPrice, that.prodPrice);
Objects.equals(active, that.active);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(prodName, categoryId, prodDesc, prodPrice, active); return Objects.hash(prodName, categoryId, prodDesc, prodPrice);
} }
@Override @Override
@@ -85,7 +74,6 @@ public class ProductRequest {
", categoryId=" + categoryId + ", categoryId=" + categoryId +
", prodDesc='" + prodDesc + '\'' + ", prodDesc='" + prodDesc + '\'' +
", prodPrice=" + prodPrice + ", prodPrice=" + prodPrice +
", active=" + active +
'}'; '}';
} }
} }

View File

@@ -5,45 +5,43 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class ProductResponse { public class ProductResponse {
private Long id; private Long prodId;
private String productName; private String prodName;
private Long categoryId; private Long categoryId;
private String categoryName; private String categoryName;
private String productDescription; private String prodDesc;
private BigDecimal productPrice; private BigDecimal prodPrice;
private Boolean active;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public ProductResponse() { public ProductResponse() {
} }
public ProductResponse(Long id, String productName, Long categoryId, String categoryName, String productDescription, BigDecimal productPrice, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { public ProductResponse(Long prodId, String prodName, Long categoryId, String categoryName, String prodDesc, BigDecimal prodPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.prodId = prodId;
this.productName = productName; this.prodName = prodName;
this.categoryId = categoryId; this.categoryId = categoryId;
this.categoryName = categoryName; this.categoryName = categoryName;
this.productDescription = productDescription; this.prodDesc = prodDesc;
this.productPrice = productPrice; this.prodPrice = prodPrice;
this.active = active;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getProdId() {
return id; return prodId;
} }
public void setId(Long id) { public void setProdId(Long prodId) {
this.id = id; this.prodId = prodId;
} }
public String getProductName() { public String getProdName() {
return productName; return prodName;
} }
public void setProductName(String productName) { public void setProdName(String prodName) {
this.productName = productName; this.prodName = prodName;
} }
public Long getCategoryId() { public Long getCategoryId() {
@@ -62,28 +60,20 @@ public class ProductResponse {
this.categoryName = categoryName; this.categoryName = categoryName;
} }
public String getProductDescription() { public String getProdDesc() {
return productDescription; return prodDesc;
} }
public void setProductDescription(String productDescription) { public void setProdDesc(String prodDesc) {
this.productDescription = productDescription; this.prodDesc = prodDesc;
} }
public BigDecimal getProductPrice() { public BigDecimal getProdPrice() {
return productPrice; return prodPrice;
} }
public void setProductPrice(BigDecimal productPrice) { public void setProdPrice(BigDecimal prodPrice) {
this.productPrice = productPrice; this.prodPrice = prodPrice;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -107,24 +97,23 @@ public class ProductResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
ProductResponse that = (ProductResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "ProductResponse{" + return "ProductResponse{" +
"id=" + id + "prodId=" + prodId +
", productName='" + productName + '\'' + ", prodName='" + prodName + '\'' +
", categoryId=" + categoryId + ", categoryId=" + categoryId +
", categoryName='" + categoryName + '\'' + ", categoryName='" + categoryName + '\'' +
", productDescription='" + productDescription + '\'' + ", prodDesc='" + prodDesc + '\'' +
", productPrice=" + productPrice + ", prodPrice=" + prodPrice +
", active=" + active +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -2,7 +2,6 @@ package com.petshop.backend.dto.productsupplier;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive; import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Objects; import java.util.Objects;
@@ -13,14 +12,9 @@ public class ProductSupplierRequest {
@NotNull(message = "Supplier ID is required") @NotNull(message = "Supplier ID is required")
private Long supplierId; private Long supplierId;
@NotNull(message = "Cost price is required") @NotNull(message = "Cost is required")
@Positive(message = "Cost price must be positive") @Positive(message = "Cost must be positive")
private BigDecimal costPrice; private BigDecimal cost;
@PositiveOrZero(message = "Lead time must be zero or positive")
private Integer leadTimeDays;
private Boolean isPreferred = false;
public Long getProductId() { public Long getProductId() {
return productId; return productId;
@@ -38,28 +32,12 @@ public class ProductSupplierRequest {
this.supplierId = supplierId; this.supplierId = supplierId;
} }
public BigDecimal getCostPrice() { public BigDecimal getCost() {
return costPrice; return cost;
} }
public void setCostPrice(BigDecimal costPrice) { public void setCost(BigDecimal cost) {
this.costPrice = costPrice; this.cost = cost;
}
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;
} }
@Override @Override
@@ -69,14 +47,12 @@ public class ProductSupplierRequest {
ProductSupplierRequest that = (ProductSupplierRequest) o; ProductSupplierRequest that = (ProductSupplierRequest) o;
return Objects.equals(productId, that.productId) && return Objects.equals(productId, that.productId) &&
Objects.equals(supplierId, that.supplierId) && Objects.equals(supplierId, that.supplierId) &&
Objects.equals(costPrice, that.costPrice) && Objects.equals(cost, that.cost);
Objects.equals(leadTimeDays, that.leadTimeDays) &&
Objects.equals(isPreferred, that.isPreferred);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(productId, supplierId, costPrice, leadTimeDays, isPreferred); return Objects.hash(productId, supplierId, cost);
} }
@Override @Override
@@ -84,9 +60,7 @@ public class ProductSupplierRequest {
return "ProductSupplierRequest{" + return "ProductSupplierRequest{" +
"productId=" + productId + "productId=" + productId +
", supplierId=" + supplierId + ", supplierId=" + supplierId +
", costPrice=" + costPrice + ", cost=" + cost +
", leadTimeDays=" + leadTimeDays +
", isPreferred=" + isPreferred +
'}'; '}';
} }
} }

View File

@@ -9,23 +9,19 @@ public class ProductSupplierResponse {
private String productName; private String productName;
private Long supplierId; private Long supplierId;
private String supplierName; private String supplierName;
private BigDecimal costPrice; private BigDecimal cost;
private Integer leadTimeDays;
private Boolean isPreferred;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public ProductSupplierResponse() { 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.productId = productId;
this.productName = productName; this.productName = productName;
this.supplierId = supplierId; this.supplierId = supplierId;
this.supplierName = supplierName; this.supplierName = supplierName;
this.costPrice = costPrice; this.cost = cost;
this.leadTimeDays = leadTimeDays;
this.isPreferred = isPreferred;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
@@ -62,28 +58,12 @@ public class ProductSupplierResponse {
this.supplierName = supplierName; this.supplierName = supplierName;
} }
public BigDecimal getCostPrice() { public BigDecimal getCost() {
return costPrice; return cost;
} }
public void setCostPrice(BigDecimal costPrice) { public void setCost(BigDecimal cost) {
this.costPrice = costPrice; this.cost = cost;
}
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 LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -107,12 +87,12 @@ public class ProductSupplierResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
ProductSupplierResponse that = (ProductSupplierResponse) o; 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 @Override
public int hashCode() { 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 @Override
@@ -122,9 +102,7 @@ public class ProductSupplierResponse {
", productName='" + productName + '\'' + ", productName='" + productName + '\'' +
", supplierId=" + supplierId + ", supplierId=" + supplierId +
", supplierName='" + supplierName + '\'' + ", supplierName='" + supplierName + '\'' +
", costPrice=" + costPrice + ", cost=" + cost +
", leadTimeDays=" + leadTimeDays +
", isPreferred=" + isPreferred +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -1,55 +1,45 @@
package com.petshop.backend.dto.purchaseorder; package com.petshop.backend.dto.purchaseorder;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects; import java.util.Objects;
public class PurchaseOrderResponse { public class PurchaseOrderResponse {
private Long id; private Long purchaseOrderId;
private Long supplierId; private Long supId;
private String supplierName; private String supplierName;
private LocalDate orderDate; private LocalDate orderDate;
private LocalDate expectedDelivery;
private String status; private String status;
private BigDecimal totalAmount;
private String notes;
private List<PurchaseOrderItemResponse> items;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public PurchaseOrderResponse() { public PurchaseOrderResponse() {
} }
public PurchaseOrderResponse(Long id, Long supplierId, String supplierName, LocalDate orderDate, LocalDate expectedDelivery, String status, BigDecimal totalAmount, String notes, List<PurchaseOrderItemResponse> items, LocalDateTime createdAt, LocalDateTime updatedAt) { public PurchaseOrderResponse(Long purchaseOrderId, Long supId, String supplierName, LocalDate orderDate, String status, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.purchaseOrderId = purchaseOrderId;
this.supplierId = supplierId; this.supId = supId;
this.supplierName = supplierName; this.supplierName = supplierName;
this.orderDate = orderDate; this.orderDate = orderDate;
this.expectedDelivery = expectedDelivery;
this.status = status; this.status = status;
this.totalAmount = totalAmount;
this.notes = notes;
this.items = items;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getPurchaseOrderId() {
return id; return purchaseOrderId;
} }
public void setId(Long id) { public void setPurchaseOrderId(Long purchaseOrderId) {
this.id = id; this.purchaseOrderId = purchaseOrderId;
} }
public Long getSupplierId() { public Long getSupId() {
return supplierId; return supId;
} }
public void setSupplierId(Long supplierId) { public void setSupId(Long supId) {
this.supplierId = supplierId; this.supId = supId;
} }
public String getSupplierName() { public String getSupplierName() {
@@ -68,14 +58,6 @@ public class PurchaseOrderResponse {
this.orderDate = orderDate; this.orderDate = orderDate;
} }
public LocalDate getExpectedDelivery() {
return expectedDelivery;
}
public void setExpectedDelivery(LocalDate expectedDelivery) {
this.expectedDelivery = expectedDelivery;
}
public String getStatus() { public String getStatus() {
return status; return status;
} }
@@ -84,30 +66,6 @@ public class PurchaseOrderResponse {
this.status = 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<PurchaseOrderItemResponse> getItems() {
return items;
}
public void setItems(List<PurchaseOrderItemResponse> items) {
this.items = items;
}
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
return createdAt; return createdAt;
} }
@@ -129,122 +87,24 @@ public class PurchaseOrderResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
PurchaseOrderResponse that = (PurchaseOrderResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "PurchaseOrderResponse{" + return "PurchaseOrderResponse{" +
"id=" + id + "purchaseOrderId=" + purchaseOrderId +
", supplierId=" + supplierId + ", supId=" + supId +
", supplierName='" + supplierName + '\'' + ", supplierName='" + supplierName + '\'' +
", orderDate=" + orderDate + ", orderDate=" + orderDate +
", expectedDelivery=" + expectedDelivery +
", status='" + status + '\'' + ", status='" + status + '\'' +
", totalAmount=" + totalAmount +
", notes='" + notes + '\'' +
", items=" + items +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", 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 +
'}';
}
}
} }

View File

@@ -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 +
'}';
}
}

View File

@@ -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<RefundItemRequest> items;
private String refundReason;
public List<RefundItemRequest> getItems() {
return items;
}
public void setItems(List<RefundItemRequest> 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 + '\'' +
'}';
}
}

View File

@@ -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<RefundItemResponse> items;
private LocalDateTime createdAt;
public RefundResponse() {
}
public RefundResponse(Long id, Long saleId, LocalDateTime refundDate, BigDecimal refundAmount, String refundReason, Long processedBy, String processedByName, List<RefundItemResponse> 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<RefundItemResponse> getItems() {
return items;
}
public void setItems(List<RefundItemResponse> 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 +
'}';
}
}
}

View File

@@ -6,18 +6,17 @@ import java.util.Objects;
public class SaleItemRequest { public class SaleItemRequest {
@NotNull(message = "Product ID is required") @NotNull(message = "Product ID is required")
private Long productId; private Long prodId;
@NotNull(message = "Quantity is required") @NotNull(message = "Quantity is required")
@Positive(message = "Quantity must be positive")
private Integer quantity; private Integer quantity;
public Long getProductId() { public Long getProdId() {
return productId; return prodId;
} }
public void setProductId(Long productId) { public void setProdId(Long prodId) {
this.productId = productId; this.prodId = prodId;
} }
public Integer getQuantity() { public Integer getQuantity() {
@@ -33,19 +32,19 @@ public class SaleItemRequest {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SaleItemRequest that = (SaleItemRequest) o; SaleItemRequest that = (SaleItemRequest) o;
return Objects.equals(productId, that.productId) && return Objects.equals(prodId, that.prodId) &&
Objects.equals(quantity, that.quantity); Objects.equals(quantity, that.quantity);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(productId, quantity); return Objects.hash(prodId, quantity);
} }
@Override @Override
public String toString() { public String toString() {
return "SaleItemRequest{" + return "SaleItemRequest{" +
"productId=" + productId + "prodId=" + prodId +
", quantity=" + quantity + ", quantity=" + quantity +
'}'; '}';
} }

View File

@@ -3,33 +3,22 @@ package com.petshop.backend.dto.sale;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public class SaleRequest { public class SaleRequest {
private Long customerId;
@NotNull(message = "Store ID is required") @NotNull(message = "Store ID is required")
private Long storeId; private Long storeId;
private String paymentMethod; private String paymentMethod;
private BigDecimal tax = BigDecimal.ZERO;
@NotEmpty(message = "At least one item is required") @NotEmpty(message = "At least one item is required")
@Valid @Valid
private List<SaleItemRequest> items; private List<SaleItemRequest> items;
private String notes; private Boolean isRefund = false;
public Long getCustomerId() { private Long originalSaleId;
return customerId;
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
public Long getStoreId() { public Long getStoreId() {
return storeId; return storeId;
@@ -47,14 +36,6 @@ public class SaleRequest {
this.paymentMethod = paymentMethod; this.paymentMethod = paymentMethod;
} }
public BigDecimal getTax() {
return tax;
}
public void setTax(BigDecimal tax) {
this.tax = tax;
}
public List<SaleItemRequest> getItems() { public List<SaleItemRequest> getItems() {
return items; return items;
} }
@@ -63,12 +44,20 @@ public class SaleRequest {
this.items = items; this.items = items;
} }
public String getNotes() { public Boolean getIsRefund() {
return notes; return isRefund;
} }
public void setNotes(String notes) { public void setIsRefund(Boolean isRefund) {
this.notes = notes; this.isRefund = isRefund;
}
public Long getOriginalSaleId() {
return originalSaleId;
}
public void setOriginalSaleId(Long originalSaleId) {
this.originalSaleId = originalSaleId;
} }
@Override @Override
@@ -76,28 +65,26 @@ public class SaleRequest {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SaleRequest that = (SaleRequest) o; SaleRequest that = (SaleRequest) o;
return Objects.equals(customerId, that.customerId) && return Objects.equals(storeId, that.storeId) &&
Objects.equals(storeId, that.storeId) &&
Objects.equals(paymentMethod, that.paymentMethod) && Objects.equals(paymentMethod, that.paymentMethod) &&
Objects.equals(tax, that.tax) &&
Objects.equals(items, that.items) && Objects.equals(items, that.items) &&
Objects.equals(notes, that.notes); Objects.equals(isRefund, that.isRefund) &&
Objects.equals(originalSaleId, that.originalSaleId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(customerId, storeId, paymentMethod, tax, items, notes); return Objects.hash(storeId, paymentMethod, items, isRefund, originalSaleId);
} }
@Override @Override
public String toString() { public String toString() {
return "SaleRequest{" + return "SaleRequest{" +
"customerId=" + customerId + "storeId=" + storeId +
", storeId=" + storeId +
", paymentMethod='" + paymentMethod + '\'' + ", paymentMethod='" + paymentMethod + '\'' +
", tax=" + tax +
", items=" + items + ", items=" + items +
", notes='" + notes + '\'' + ", isRefund=" + isRefund +
", originalSaleId=" + originalSaleId +
'}'; '}';
} }
} }

View File

@@ -6,49 +6,43 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
public class SaleResponse { public class SaleResponse {
private Long id; private Long saleId;
private LocalDateTime saleDate; private LocalDateTime saleDate;
private Long employeeId; private Long employeeId;
private String employeeName; private String employeeName;
private Long customerId;
private String customerName;
private Long storeId; private Long storeId;
private String storeName; private String storeName;
private BigDecimal subtotal; private BigDecimal totalAmount;
private BigDecimal tax;
private BigDecimal total;
private String paymentMethod; private String paymentMethod;
private String notes; private Boolean isRefund;
private Long originalSaleId;
private List<SaleItemResponse> items; private List<SaleItemResponse> items;
private LocalDateTime createdAt; private LocalDateTime createdAt;
public SaleResponse() { 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<SaleItemResponse> items, LocalDateTime createdAt) { public SaleResponse(Long saleId, LocalDateTime saleDate, Long employeeId, String employeeName, Long storeId, String storeName, BigDecimal totalAmount, String paymentMethod, Boolean isRefund, Long originalSaleId, List<SaleItemResponse> items, LocalDateTime createdAt) {
this.id = id; this.saleId = saleId;
this.saleDate = saleDate; this.saleDate = saleDate;
this.employeeId = employeeId; this.employeeId = employeeId;
this.employeeName = employeeName; this.employeeName = employeeName;
this.customerId = customerId;
this.customerName = customerName;
this.storeId = storeId; this.storeId = storeId;
this.storeName = storeName; this.storeName = storeName;
this.subtotal = subtotal; this.totalAmount = totalAmount;
this.tax = tax;
this.total = total;
this.paymentMethod = paymentMethod; this.paymentMethod = paymentMethod;
this.notes = notes; this.isRefund = isRefund;
this.originalSaleId = originalSaleId;
this.items = items; this.items = items;
this.createdAt = createdAt; this.createdAt = createdAt;
} }
public Long getId() { public Long getSaleId() {
return id; return saleId;
} }
public void setId(Long id) { public void setSaleId(Long saleId) {
this.id = id; this.saleId = saleId;
} }
public LocalDateTime getSaleDate() { public LocalDateTime getSaleDate() {
@@ -75,22 +69,6 @@ public class SaleResponse {
this.employeeName = employeeName; 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() { public Long getStoreId() {
return storeId; return storeId;
} }
@@ -107,28 +85,12 @@ public class SaleResponse {
this.storeName = storeName; this.storeName = storeName;
} }
public BigDecimal getSubtotal() { public BigDecimal getTotalAmount() {
return subtotal; return totalAmount;
} }
public void setSubtotal(BigDecimal subtotal) { public void setTotalAmount(BigDecimal totalAmount) {
this.subtotal = subtotal; this.totalAmount = totalAmount;
}
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 String getPaymentMethod() { public String getPaymentMethod() {
@@ -139,12 +101,20 @@ public class SaleResponse {
this.paymentMethod = paymentMethod; this.paymentMethod = paymentMethod;
} }
public String getNotes() { public Boolean getIsRefund() {
return notes; return isRefund;
} }
public void setNotes(String notes) { public void setIsRefund(Boolean isRefund) {
this.notes = notes; this.isRefund = isRefund;
}
public Long getOriginalSaleId() {
return originalSaleId;
}
public void setOriginalSaleId(Long originalSaleId) {
this.originalSaleId = originalSaleId;
} }
public List<SaleItemResponse> getItems() { public List<SaleItemResponse> getItems() {
@@ -168,69 +138,64 @@ public class SaleResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SaleResponse that = (SaleResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "SaleResponse{" + return "SaleResponse{" +
"id=" + id + "saleId=" + saleId +
", saleDate=" + saleDate + ", saleDate=" + saleDate +
", employeeId=" + employeeId + ", employeeId=" + employeeId +
", employeeName='" + employeeName + '\'' + ", employeeName='" + employeeName + '\'' +
", customerId=" + customerId +
", customerName='" + customerName + '\'' +
", storeId=" + storeId + ", storeId=" + storeId +
", storeName='" + storeName + '\'' + ", storeName='" + storeName + '\'' +
", subtotal=" + subtotal + ", totalAmount=" + totalAmount +
", tax=" + tax +
", total=" + total +
", paymentMethod='" + paymentMethod + '\'' + ", paymentMethod='" + paymentMethod + '\'' +
", notes='" + notes + '\'' + ", isRefund=" + isRefund +
", originalSaleId=" + originalSaleId +
", items=" + items + ", items=" + items +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
'}'; '}';
} }
public static class SaleItemResponse { public static class SaleItemResponse {
private Long id; private Long saleItemId;
private Long productId; private Long prodId;
private String productName; private String productName;
private Integer quantity; private Integer quantity;
private BigDecimal unitPrice; private BigDecimal unitPrice;
private BigDecimal subtotal;
public SaleItemResponse() { public SaleItemResponse() {
} }
public SaleItemResponse(Long id, Long productId, String productName, Integer quantity, BigDecimal unitPrice, BigDecimal subtotal) { public SaleItemResponse(Long saleItemId, Long prodId, String productName, Integer quantity, BigDecimal unitPrice) {
this.id = id; this.saleItemId = saleItemId;
this.productId = productId; this.prodId = prodId;
this.productName = productName; this.productName = productName;
this.quantity = quantity; this.quantity = quantity;
this.unitPrice = unitPrice; this.unitPrice = unitPrice;
this.subtotal = subtotal;
} }
public Long getId() { public Long getSaleItemId() {
return id; return saleItemId;
} }
public void setId(Long id) { public void setSaleItemId(Long saleItemId) {
this.id = id; this.saleItemId = saleItemId;
} }
public Long getProductId() { public Long getProdId() {
return productId; return prodId;
} }
public void setProductId(Long productId) { public void setProdId(Long prodId) {
this.productId = productId; this.prodId = prodId;
} }
public String getProductName() { public String getProductName() {
@@ -257,36 +222,27 @@ public class SaleResponse {
this.unitPrice = unitPrice; this.unitPrice = unitPrice;
} }
public BigDecimal getSubtotal() {
return subtotal;
}
public void setSubtotal(BigDecimal subtotal) {
this.subtotal = subtotal;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SaleItemResponse that = (SaleItemResponse) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, productId, productName, quantity, unitPrice, subtotal); return Objects.hash(saleItemId, prodId, productName, quantity, unitPrice);
} }
@Override @Override
public String toString() { public String toString() {
return "SaleItemResponse{" + return "SaleItemResponse{" +
"id=" + id + "saleItemId=" + saleItemId +
", productId=" + productId + ", prodId=" + prodId +
", productName='" + productName + '\'' + ", productName='" + productName + '\'' +
", quantity=" + quantity + ", quantity=" + quantity +
", unitPrice=" + unitPrice + ", unitPrice=" + unitPrice +
", subtotal=" + subtotal +
'}'; '}';
} }
} }

View File

@@ -10,16 +10,14 @@ public class ServiceRequest {
@NotBlank(message = "Service name is required") @NotBlank(message = "Service name is required")
private String serviceName; private String serviceName;
private String serviceDescription; private String serviceDesc;
@NotNull(message = "Service price is required") @NotNull(message = "Service price is required")
@Positive(message = "Price must be positive") @Positive(message = "Price must be positive")
private BigDecimal servicePrice; private BigDecimal servicePrice;
@Positive(message = "Duration must be positive") @Positive(message = "Duration must be positive")
private Integer serviceDurationMinutes; private Integer serviceDuration;
private Boolean active = true;
public String getServiceName() { public String getServiceName() {
return serviceName; return serviceName;
@@ -29,12 +27,12 @@ public class ServiceRequest {
this.serviceName = serviceName; this.serviceName = serviceName;
} }
public String getServiceDescription() { public String getServiceDesc() {
return serviceDescription; return serviceDesc;
} }
public void setServiceDescription(String serviceDescription) { public void setServiceDesc(String serviceDesc) {
this.serviceDescription = serviceDescription; this.serviceDesc = serviceDesc;
} }
public BigDecimal getServicePrice() { public BigDecimal getServicePrice() {
@@ -45,20 +43,12 @@ public class ServiceRequest {
this.servicePrice = servicePrice; this.servicePrice = servicePrice;
} }
public Integer getServiceDurationMinutes() { public Integer getServiceDuration() {
return serviceDurationMinutes; return serviceDuration;
} }
public void setServiceDurationMinutes(Integer serviceDurationMinutes) { public void setServiceDuration(Integer serviceDuration) {
this.serviceDurationMinutes = serviceDurationMinutes; this.serviceDuration = serviceDuration;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
} }
@Override @Override
@@ -67,25 +57,23 @@ public class ServiceRequest {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
ServiceRequest that = (ServiceRequest) o; ServiceRequest that = (ServiceRequest) o;
return Objects.equals(serviceName, that.serviceName) && return Objects.equals(serviceName, that.serviceName) &&
Objects.equals(serviceDescription, that.serviceDescription) && Objects.equals(serviceDesc, that.serviceDesc) &&
Objects.equals(servicePrice, that.servicePrice) && Objects.equals(servicePrice, that.servicePrice) &&
Objects.equals(serviceDurationMinutes, that.serviceDurationMinutes) && Objects.equals(serviceDuration, that.serviceDuration);
Objects.equals(active, that.active);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(serviceName, serviceDescription, servicePrice, serviceDurationMinutes, active); return Objects.hash(serviceName, serviceDesc, servicePrice, serviceDuration);
} }
@Override @Override
public String toString() { public String toString() {
return "ServiceRequest{" + return "ServiceRequest{" +
"serviceName='" + serviceName + '\'' + "serviceName='" + serviceName + '\'' +
", serviceDescription='" + serviceDescription + '\'' + ", serviceDesc='" + serviceDesc + '\'' +
", servicePrice=" + servicePrice + ", servicePrice=" + servicePrice +
", serviceDurationMinutes=" + serviceDurationMinutes + ", serviceDuration=" + serviceDuration +
", active=" + active +
'}'; '}';
} }
} }

View File

@@ -5,35 +5,33 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class ServiceResponse { public class ServiceResponse {
private Long id; private Long serviceId;
private String serviceName; private String serviceName;
private String serviceDescription; private String serviceDesc;
private BigDecimal servicePrice; private BigDecimal servicePrice;
private Integer serviceDurationMinutes; private Integer serviceDuration;
private Boolean active;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public ServiceResponse() { public ServiceResponse() {
} }
public ServiceResponse(Long id, String serviceName, String serviceDescription, BigDecimal servicePrice, Integer serviceDurationMinutes, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { public ServiceResponse(Long serviceId, String serviceName, String serviceDesc, BigDecimal servicePrice, Integer serviceDuration, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.serviceId = serviceId;
this.serviceName = serviceName; this.serviceName = serviceName;
this.serviceDescription = serviceDescription; this.serviceDesc = serviceDesc;
this.servicePrice = servicePrice; this.servicePrice = servicePrice;
this.serviceDurationMinutes = serviceDurationMinutes; this.serviceDuration = serviceDuration;
this.active = active;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getServiceId() {
return id; return serviceId;
} }
public void setId(Long id) { public void setServiceId(Long serviceId) {
this.id = id; this.serviceId = serviceId;
} }
public String getServiceName() { public String getServiceName() {
@@ -44,12 +42,12 @@ public class ServiceResponse {
this.serviceName = serviceName; this.serviceName = serviceName;
} }
public String getServiceDescription() { public String getServiceDesc() {
return serviceDescription; return serviceDesc;
} }
public void setServiceDescription(String serviceDescription) { public void setServiceDesc(String serviceDesc) {
this.serviceDescription = serviceDescription; this.serviceDesc = serviceDesc;
} }
public BigDecimal getServicePrice() { public BigDecimal getServicePrice() {
@@ -60,20 +58,12 @@ public class ServiceResponse {
this.servicePrice = servicePrice; this.servicePrice = servicePrice;
} }
public Integer getServiceDurationMinutes() { public Integer getServiceDuration() {
return serviceDurationMinutes; return serviceDuration;
} }
public void setServiceDurationMinutes(Integer serviceDurationMinutes) { public void setServiceDuration(Integer serviceDuration) {
this.serviceDurationMinutes = serviceDurationMinutes; this.serviceDuration = serviceDuration;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -97,23 +87,22 @@ public class ServiceResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
ServiceResponse that = (ServiceResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "ServiceResponse{" + return "ServiceResponse{" +
"id=" + id + "serviceId=" + serviceId +
", serviceName='" + serviceName + '\'' + ", serviceName='" + serviceName + '\'' +
", serviceDescription='" + serviceDescription + '\'' + ", serviceDesc='" + serviceDesc + '\'' +
", servicePrice=" + servicePrice + ", servicePrice=" + servicePrice +
", serviceDurationMinutes=" + serviceDurationMinutes + ", serviceDuration=" + serviceDuration +
", active=" + active +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -4,27 +4,31 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class StoreResponse { public class StoreResponse {
private Long id; private Long storeId;
private String storeName; private String storeName;
private String storeLocation; private String address;
private String phone;
private String email;
private LocalDateTime createdAt; private LocalDateTime createdAt;
public StoreResponse() { public StoreResponse() {
} }
public StoreResponse(Long id, String storeName, String storeLocation, LocalDateTime createdAt) { public StoreResponse(Long storeId, String storeName, String address, String phone, String email, LocalDateTime createdAt) {
this.id = id; this.storeId = storeId;
this.storeName = storeName; this.storeName = storeName;
this.storeLocation = storeLocation; this.address = address;
this.phone = phone;
this.email = email;
this.createdAt = createdAt; this.createdAt = createdAt;
} }
public Long getId() { public Long getStoreId() {
return id; return storeId;
} }
public void setId(Long id) { public void setStoreId(Long storeId) {
this.id = id; this.storeId = storeId;
} }
public String getStoreName() { public String getStoreName() {
@@ -35,12 +39,28 @@ public class StoreResponse {
this.storeName = storeName; this.storeName = storeName;
} }
public String getStoreLocation() { public String getAddress() {
return storeLocation; return address;
} }
public void setStoreLocation(String storeLocation) { public void setAddress(String address) {
this.storeLocation = storeLocation; 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() { public LocalDateTime getCreatedAt() {
@@ -56,20 +76,22 @@ public class StoreResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
StoreResponse that = (StoreResponse) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, storeName, storeLocation, createdAt); return Objects.hash(storeId);
} }
@Override @Override
public String toString() { public String toString() {
return "StoreResponse{" + return "StoreResponse{" +
"id=" + id + "storeId=" + storeId +
", storeName='" + storeName + '\'' + ", storeName='" + storeName + '\'' +
", storeLocation='" + storeLocation + '\'' + ", address='" + address + '\'' +
", phone='" + phone + '\'' +
", email='" + email + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
'}'; '}';
} }

View File

@@ -5,32 +5,40 @@ import jakarta.validation.constraints.NotBlank;
import java.util.Objects; import java.util.Objects;
public class SupplierRequest { public class SupplierRequest {
@NotBlank(message = "Supplier name is required") @NotBlank(message = "Supplier company is required")
private String supName; private String supCompany;
private String supContact; private String supContactFirstName;
private String supContactLastName;
@Email(message = "Invalid email format") @Email(message = "Invalid email format")
private String supEmail; private String supEmail;
private String supPhone; private String supPhone;
private String supAddress;
private Boolean active = true;
public String getSupName() { public String getSupCompany() {
return supName; return supCompany;
} }
public void setSupName(String supName) { public void setSupCompany(String supCompany) {
this.supName = supName; this.supCompany = supCompany;
} }
public String getSupContact() { public String getSupContactFirstName() {
return supContact; return supContactFirstName;
} }
public void setSupContact(String supContact) { public void setSupContactFirstName(String supContactFirstName) {
this.supContact = supContact; this.supContactFirstName = supContactFirstName;
}
public String getSupContactLastName() {
return supContactLastName;
}
public void setSupContactLastName(String supContactLastName) {
this.supContactLastName = supContactLastName;
} }
public String getSupEmail() { public String getSupEmail() {
@@ -49,49 +57,31 @@ public class SupplierRequest {
this.supPhone = supPhone; 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 @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SupplierRequest that = (SupplierRequest) o; SupplierRequest that = (SupplierRequest) o;
return Objects.equals(supName, that.supName) && return Objects.equals(supCompany, that.supCompany) &&
Objects.equals(supContact, that.supContact) && Objects.equals(supContactFirstName, that.supContactFirstName) &&
Objects.equals(supContactLastName, that.supContactLastName) &&
Objects.equals(supEmail, that.supEmail) && Objects.equals(supEmail, that.supEmail) &&
Objects.equals(supPhone, that.supPhone) && Objects.equals(supPhone, that.supPhone);
Objects.equals(supAddress, that.supAddress) &&
Objects.equals(active, that.active);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(supName, supContact, supEmail, supPhone, supAddress, active); return Objects.hash(supCompany, supContactFirstName, supContactLastName, supEmail, supPhone);
} }
@Override @Override
public String toString() { public String toString() {
return "SupplierRequest{" + return "SupplierRequest{" +
"supName='" + supName + '\'' + "supCompany='" + supCompany + '\'' +
", supContact='" + supContact + '\'' + ", supContactFirstName='" + supContactFirstName + '\'' +
", supContactLastName='" + supContactLastName + '\'' +
", supEmail='" + supEmail + '\'' + ", supEmail='" + supEmail + '\'' +
", supPhone='" + supPhone + '\'' + ", supPhone='" + supPhone + '\'' +
", supAddress='" + supAddress + '\'' +
", active=" + active +
'}'; '}';
} }
} }

View File

@@ -4,85 +4,75 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
public class SupplierResponse { public class SupplierResponse {
private Long id; private Long supId;
private String supplierName; private String supCompany;
private String supplierContact; private String supContactFirstName;
private String supplierEmail; private String supContactLastName;
private String supplierPhone; private String supEmail;
private String supplierAddress; private String supPhone;
private Boolean active;
private LocalDateTime createdAt; private LocalDateTime createdAt;
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public SupplierResponse() { public SupplierResponse() {
} }
public SupplierResponse(Long id, String supplierName, String supplierContact, String supplierEmail, String supplierPhone, String supplierAddress, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { public SupplierResponse(Long supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.supId = supId;
this.supplierName = supplierName; this.supCompany = supCompany;
this.supplierContact = supplierContact; this.supContactFirstName = supContactFirstName;
this.supplierEmail = supplierEmail; this.supContactLastName = supContactLastName;
this.supplierPhone = supplierPhone; this.supEmail = supEmail;
this.supplierAddress = supplierAddress; this.supPhone = supPhone;
this.active = active;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getSupId() {
return id; return supId;
} }
public void setId(Long id) { public void setSupId(Long supId) {
this.id = id; this.supId = supId;
} }
public String getSupplierName() { public String getSupCompany() {
return supplierName; return supCompany;
} }
public void setSupplierName(String supplierName) { public void setSupCompany(String supCompany) {
this.supplierName = supplierName; this.supCompany = supCompany;
} }
public String getSupplierContact() { public String getSupContactFirstName() {
return supplierContact; return supContactFirstName;
} }
public void setSupplierContact(String supplierContact) { public void setSupContactFirstName(String supContactFirstName) {
this.supplierContact = supplierContact; this.supContactFirstName = supContactFirstName;
} }
public String getSupplierEmail() { public String getSupContactLastName() {
return supplierEmail; return supContactLastName;
} }
public void setSupplierEmail(String supplierEmail) { public void setSupContactLastName(String supContactLastName) {
this.supplierEmail = supplierEmail; this.supContactLastName = supContactLastName;
} }
public String getSupplierPhone() { public String getSupEmail() {
return supplierPhone; return supEmail;
} }
public void setSupplierPhone(String supplierPhone) { public void setSupEmail(String supEmail) {
this.supplierPhone = supplierPhone; this.supEmail = supEmail;
} }
public String getSupplierAddress() { public String getSupPhone() {
return supplierAddress; return supPhone;
} }
public void setSupplierAddress(String supplierAddress) { public void setSupPhone(String supPhone) {
this.supplierAddress = supplierAddress; this.supPhone = supPhone;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -106,24 +96,23 @@ public class SupplierResponse {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SupplierResponse that = (SupplierResponse) o; 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 @Override
public int hashCode() { 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 @Override
public String toString() { public String toString() {
return "SupplierResponse{" + return "SupplierResponse{" +
"id=" + id + "supId=" + supId +
", supplierName='" + supplierName + '\'' + ", supCompany='" + supCompany + '\'' +
", supplierContact='" + supplierContact + '\'' + ", supContactFirstName='" + supContactFirstName + '\'' +
", supplierEmail='" + supplierEmail + '\'' + ", supContactLastName='" + supContactLastName + '\'' +
", supplierPhone='" + supplierPhone + '\'' + ", supEmail='" + supEmail + '\'' +
", supplierAddress='" + supplierAddress + '\'' + ", supPhone='" + supPhone + '\'' +
", active=" + active +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -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 +
'}';
}
}

View File

@@ -10,29 +10,26 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "adoptions") @Table(name = "adoption")
public class Adoption { public class Adoption {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long adoptionId;
@ManyToOne @ManyToOne
@JoinColumn(name = "pet_id", nullable = false) @JoinColumn(name = "petId", nullable = false)
private Pet pet; private Pet pet;
@ManyToOne @ManyToOne
@JoinColumn(name = "customer_id", nullable = false) @JoinColumn(name = "customerId", nullable = false)
private Customer customer; private Customer customer;
@Column(name = "adoption_date", nullable = false) @Column(nullable = false)
private LocalDate adoptionDate; private LocalDate adoptionDate;
@Column(name = "adoption_fee", nullable = false, precision = 10, scale = 2) @Column(nullable = false, length = 20)
private BigDecimal adoptionFee; private String adoptionStatus;
@Column(columnDefinition = "TEXT")
private String notes;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -45,23 +42,22 @@ public class Adoption {
public Adoption() { public Adoption() {
} }
public Adoption(Long id, Pet pet, Customer customer, LocalDate adoptionDate, BigDecimal adoptionFee, String notes, LocalDateTime createdAt, LocalDateTime updatedAt) { public Adoption(Long adoptionId, Pet pet, Customer customer, LocalDate adoptionDate, String adoptionStatus, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.adoptionId = adoptionId;
this.pet = pet; this.pet = pet;
this.customer = customer; this.customer = customer;
this.adoptionDate = adoptionDate; this.adoptionDate = adoptionDate;
this.adoptionFee = adoptionFee; this.adoptionStatus = adoptionStatus;
this.notes = notes;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getAdoptionId() {
return id; return adoptionId;
} }
public void setId(Long id) { public void setAdoptionId(Long adoptionId) {
this.id = id; this.adoptionId = adoptionId;
} }
public Pet getPet() { public Pet getPet() {
@@ -88,20 +84,12 @@ public class Adoption {
this.adoptionDate = adoptionDate; this.adoptionDate = adoptionDate;
} }
public BigDecimal getAdoptionFee() { public String getAdoptionStatus() {
return adoptionFee; return adoptionStatus;
} }
public void setAdoptionFee(BigDecimal adoptionFee) { public void setAdoptionStatus(String adoptionStatus) {
this.adoptionFee = adoptionFee; this.adoptionStatus = adoptionStatus;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -125,23 +113,22 @@ public class Adoption {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Adoption adoption = (Adoption) o; Adoption adoption = (Adoption) o;
return Objects.equals(id, adoption.id); return Objects.equals(adoptionId, adoption.adoptionId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(adoptionId);
} }
@Override @Override
public String toString() { public String toString() {
return "Adoption{" + return "Adoption{" +
"id=" + id + "adoptionId=" + adoptionId +
", pet=" + pet + ", pet=" + pet +
", customer=" + customer + ", customer=" + customer +
", adoptionDate=" + adoptionDate + ", adoptionDate=" + adoptionDate +
", adoptionFee=" + adoptionFee + ", adoptionStatus='" + adoptionStatus + '\'' +
", notes='" + notes + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -12,39 +12,35 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
@Entity @Entity
@Table(name = "appointments") @Table(name = "appointment")
public class Appointment { public class Appointment {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long appointmentId;
@ManyToOne @ManyToOne
@JoinColumn(name = "customer_id", nullable = false) @JoinColumn(name = "customerId", nullable = false)
private Customer customer; private Customer customer;
@ManyToOne @ManyToOne
@JoinColumn(name = "service_id", nullable = false) @JoinColumn(name = "serviceId", nullable = false)
private Service service; private Service service;
@Column(name = "appointment_date", nullable = false) @Column(nullable = false)
private LocalDate appointmentDate; private LocalDate appointmentDate;
@Column(name = "appointment_time", nullable = false) @Column(nullable = false)
private LocalTime appointmentTime; private LocalTime appointmentTime;
@Enumerated(EnumType.STRING) @Column(nullable = false, length = 20)
@Column(nullable = false) private String appointmentStatus;
private AppointmentStatus status = AppointmentStatus.Scheduled;
@Column(columnDefinition = "TEXT")
private String notes;
@ManyToMany @ManyToMany
@JoinTable( @JoinTable(
name = "appointment_pets", name = "appointmentPet",
joinColumns = @JoinColumn(name = "appointment_id"), joinColumns = @JoinColumn(name = "appointmentId"),
inverseJoinColumns = @JoinColumn(name = "pet_id") inverseJoinColumns = @JoinColumn(name = "petId")
) )
private Set<Pet> pets = new HashSet<>(); private Set<Pet> pets = new HashSet<>();
@@ -56,32 +52,27 @@ public class Appointment {
@Column(name = "updated_at") @Column(name = "updated_at")
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public enum AppointmentStatus {
Scheduled, Completed, Cancelled
}
public Appointment() { public Appointment() {
} }
public Appointment(Long id, Customer customer, Service service, LocalDate appointmentDate, LocalTime appointmentTime, AppointmentStatus status, String notes, Set<Pet> pets, LocalDateTime createdAt, LocalDateTime updatedAt) { public Appointment(Long appointmentId, Customer customer, Service service, LocalDate appointmentDate, LocalTime appointmentTime, String appointmentStatus, Set<Pet> pets, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.appointmentId = appointmentId;
this.customer = customer; this.customer = customer;
this.service = service; this.service = service;
this.appointmentDate = appointmentDate; this.appointmentDate = appointmentDate;
this.appointmentTime = appointmentTime; this.appointmentTime = appointmentTime;
this.status = status; this.appointmentStatus = appointmentStatus;
this.notes = notes;
this.pets = pets; this.pets = pets;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getAppointmentId() {
return id; return appointmentId;
} }
public void setId(Long id) { public void setAppointmentId(Long appointmentId) {
this.id = id; this.appointmentId = appointmentId;
} }
public Customer getCustomer() { public Customer getCustomer() {
@@ -116,20 +107,12 @@ public class Appointment {
this.appointmentTime = appointmentTime; this.appointmentTime = appointmentTime;
} }
public AppointmentStatus getStatus() { public String getAppointmentStatus() {
return status; return appointmentStatus;
} }
public void setStatus(AppointmentStatus status) { public void setAppointmentStatus(String appointmentStatus) {
this.status = status; this.appointmentStatus = appointmentStatus;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
} }
public Set<Pet> getPets() { public Set<Pet> getPets() {
@@ -161,24 +144,23 @@ public class Appointment {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Appointment that = (Appointment) o; Appointment that = (Appointment) o;
return Objects.equals(id, that.id); return Objects.equals(appointmentId, that.appointmentId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(appointmentId);
} }
@Override @Override
public String toString() { public String toString() {
return "Appointment{" + return "Appointment{" +
"id=" + id + "appointmentId=" + appointmentId +
", customer=" + customer + ", customer=" + customer +
", service=" + service + ", service=" + service +
", appointmentDate=" + appointmentDate + ", appointmentDate=" + appointmentDate +
", appointmentTime=" + appointmentTime + ", appointmentTime=" + appointmentTime +
", status=" + status + ", appointmentStatus='" + appointmentStatus + '\'' +
", notes='" + notes + '\'' +
", pets=" + pets + ", pets=" + pets +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +

View File

@@ -8,18 +8,18 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "categories") @Table(name = "category")
public class Category { public class Category {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @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; private String categoryName;
@Column(name = "category_description", columnDefinition = "TEXT") @Column(nullable = false, length = 50)
private String categoryDescription; private String categoryType;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -32,20 +32,20 @@ public class Category {
public Category() { public Category() {
} }
public Category(Long id, String categoryName, String categoryDescription, LocalDateTime createdAt, LocalDateTime updatedAt) { public Category(Long categoryId, String categoryName, String categoryType, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.categoryId = categoryId;
this.categoryName = categoryName; this.categoryName = categoryName;
this.categoryDescription = categoryDescription; this.categoryType = categoryType;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getCategoryId() {
return id; return categoryId;
} }
public void setId(Long id) { public void setCategoryId(Long categoryId) {
this.id = id; this.categoryId = categoryId;
} }
public String getCategoryName() { public String getCategoryName() {
@@ -56,12 +56,12 @@ public class Category {
this.categoryName = categoryName; this.categoryName = categoryName;
} }
public String getCategoryDescription() { public String getCategoryType() {
return categoryDescription; return categoryType;
} }
public void setCategoryDescription(String categoryDescription) { public void setCategoryType(String categoryType) {
this.categoryDescription = categoryDescription; this.categoryType = categoryType;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -85,20 +85,20 @@ public class Category {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Category category = (Category) o; Category category = (Category) o;
return Objects.equals(id, category.id); return Objects.equals(categoryId, category.categoryId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(categoryId);
} }
@Override @Override
public String toString() { public String toString() {
return "Category{" + return "Category{" +
"id=" + id + "categoryId=" + categoryId +
", categoryName='" + categoryName + '\'' + ", categoryName='" + categoryName + '\'' +
", categoryDescription='" + categoryDescription + '\'' + ", categoryType='" + categoryType + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -8,24 +8,24 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "customers") @Table(name = "customer")
public class Customer { public class Customer {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long customerId;
@Column(name = "customer_name", nullable = false, length = 100) @Column(nullable = false, length = 50)
private String customerName; private String firstName;
@Column(name = "customer_email", length = 100) @Column(nullable = false, length = 50)
private String customerEmail; private String lastName;
@Column(name = "customer_phone", length = 20) @Column(nullable = false, length = 100)
private String customerPhone; private String email;
@Column(name = "customer_address", columnDefinition = "TEXT") @Column(nullable = false, length = 20)
private String customerAddress; private String phone;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -38,54 +38,54 @@ public class Customer {
public Customer() { public Customer() {
} }
public Customer(Long id, String customerName, String customerEmail, String customerPhone, String customerAddress, LocalDateTime createdAt, LocalDateTime updatedAt) { public Customer(Long customerId, String firstName, String lastName, String email, String phone, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.customerId = customerId;
this.customerName = customerName; this.firstName = firstName;
this.customerEmail = customerEmail; this.lastName = lastName;
this.customerPhone = customerPhone; this.email = email;
this.customerAddress = customerAddress; this.phone = phone;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getCustomerId() {
return id; return customerId;
} }
public void setId(Long id) { public void setCustomerId(Long customerId) {
this.id = id; this.customerId = customerId;
} }
public String getCustomerName() { public String getFirstName() {
return customerName; return firstName;
} }
public void setCustomerName(String customerName) { public void setFirstName(String firstName) {
this.customerName = customerName; this.firstName = firstName;
} }
public String getCustomerEmail() { public String getLastName() {
return customerEmail; return lastName;
} }
public void setCustomerEmail(String customerEmail) { public void setLastName(String lastName) {
this.customerEmail = customerEmail; this.lastName = lastName;
} }
public String getCustomerPhone() { public String getEmail() {
return customerPhone; return email;
} }
public void setCustomerPhone(String customerPhone) { public void setEmail(String email) {
this.customerPhone = customerPhone; this.email = email;
} }
public String getCustomerAddress() { public String getPhone() {
return customerAddress; return phone;
} }
public void setCustomerAddress(String customerAddress) { public void setPhone(String phone) {
this.customerAddress = customerAddress; this.phone = phone;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -109,22 +109,22 @@ public class Customer {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Customer customer = (Customer) o; Customer customer = (Customer) o;
return Objects.equals(id, customer.id); return Objects.equals(customerId, customer.customerId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(customerId);
} }
@Override @Override
public String toString() { public String toString() {
return "Customer{" + return "Customer{" +
"id=" + id + "customerId=" + customerId +
", customerName='" + customerName + '\'' + ", firstName='" + firstName + '\'' +
", customerEmail='" + customerEmail + '\'' + ", lastName='" + lastName + '\'' +
", customerPhone='" + customerPhone + '\'' + ", email='" + email + '\'' +
", customerAddress='" + customerAddress + '\'' + ", phone='" + phone + '\'' +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -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 +
'}';
}
}

View File

@@ -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 +
'}';
}
}
}

View File

@@ -8,32 +8,20 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "inventory", uniqueConstraints = { @Table(name = "inventory")
@UniqueConstraint(name = "unique_product_store", columnNames = {"product_id", "store_id"})
})
public class Inventory { public class Inventory {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long inventoryId;
@ManyToOne @ManyToOne
@JoinColumn(name = "product_id", nullable = false) @JoinColumn(name = "prodId", nullable = false)
private Product product; private Product product;
@ManyToOne
@JoinColumn(name = "store_id", nullable = true)
private Store store;
@Column(nullable = false) @Column(nullable = false)
private Integer quantity = 0; private Integer quantity = 0;
@Column(name = "reorder_level")
private Integer reorderLevel = 10;
@Column(name = "last_restocked")
private LocalDateTime lastRestocked;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
private LocalDateTime createdAt; private LocalDateTime createdAt;
@@ -45,23 +33,20 @@ public class Inventory {
public Inventory() { public Inventory() {
} }
public Inventory(Long id, Product product, Store store, Integer quantity, Integer reorderLevel, LocalDateTime lastRestocked, LocalDateTime createdAt, LocalDateTime updatedAt) { public Inventory(Long inventoryId, Product product, Integer quantity, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.inventoryId = inventoryId;
this.product = product; this.product = product;
this.store = store;
this.quantity = quantity; this.quantity = quantity;
this.reorderLevel = reorderLevel;
this.lastRestocked = lastRestocked;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getInventoryId() {
return id; return inventoryId;
} }
public void setId(Long id) { public void setInventoryId(Long inventoryId) {
this.id = id; this.inventoryId = inventoryId;
} }
public Product getProduct() { public Product getProduct() {
@@ -72,14 +57,6 @@ public class Inventory {
this.product = product; this.product = product;
} }
public Store getStore() {
return store;
}
public void setStore(Store store) {
this.store = store;
}
public Integer getQuantity() { public Integer getQuantity() {
return quantity; return quantity;
} }
@@ -88,22 +65,6 @@ public class Inventory {
this.quantity = quantity; 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() { public LocalDateTime getCreatedAt() {
return createdAt; return createdAt;
} }
@@ -125,23 +86,20 @@ public class Inventory {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Inventory inventory = (Inventory) o; Inventory inventory = (Inventory) o;
return Objects.equals(id, inventory.id); return Objects.equals(inventoryId, inventory.inventoryId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(inventoryId);
} }
@Override @Override
public String toString() { public String toString() {
return "Inventory{" + return "Inventory{" +
"id=" + id + "inventoryId=" + inventoryId +
", product=" + product + ", product=" + product +
", store=" + store +
", quantity=" + quantity + ", quantity=" + quantity +
", reorderLevel=" + reorderLevel +
", lastRestocked=" + lastRestocked +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -9,30 +9,29 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "pets") @Table(name = "pet")
public class Pet { public class Pet {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @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; private String petName;
@Column(name = "pet_species", nullable = false, length = 50) @Column(nullable = false, length = 50)
private String petSpecies; private String petSpecies;
@Column(name = "pet_breed", length = 50) @Column(nullable = false, length = 50)
private String petBreed; private String petBreed;
@Column(name = "pet_age") @Column(nullable = false)
private Integer petAge; private Integer petAge;
@Enumerated(EnumType.STRING) @Column(nullable = false, length = 20)
@Column(name = "pet_status", nullable = false) private String petStatus;
private PetStatus petStatus = PetStatus.AVAILABLE;
@Column(name = "pet_price", precision = 10, scale = 2) @Column(nullable = false, precision = 10, scale = 2)
private BigDecimal petPrice; private BigDecimal petPrice;
@CreationTimestamp @CreationTimestamp
@@ -43,15 +42,11 @@ public class Pet {
@Column(name = "updated_at") @Column(name = "updated_at")
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public enum PetStatus {
AVAILABLE, ADOPTED, UNDER_CARE
}
public Pet() { public Pet() {
} }
public Pet(Long id, String petName, String petSpecies, String petBreed, Integer petAge, PetStatus petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) { public Pet(Long petId, String petName, String petSpecies, String petBreed, Integer petAge, String petStatus, BigDecimal petPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.petId = petId;
this.petName = petName; this.petName = petName;
this.petSpecies = petSpecies; this.petSpecies = petSpecies;
this.petBreed = petBreed; this.petBreed = petBreed;
@@ -62,12 +57,12 @@ public class Pet {
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getPetId() {
return id; return petId;
} }
public void setId(Long id) { public void setPetId(Long petId) {
this.id = id; this.petId = petId;
} }
public String getPetName() { public String getPetName() {
@@ -102,11 +97,11 @@ public class Pet {
this.petAge = petAge; this.petAge = petAge;
} }
public PetStatus getPetStatus() { public String getPetStatus() {
return petStatus; return petStatus;
} }
public void setPetStatus(PetStatus petStatus) { public void setPetStatus(String petStatus) {
this.petStatus = petStatus; this.petStatus = petStatus;
} }
@@ -139,23 +134,23 @@ public class Pet {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Pet pet = (Pet) o; Pet pet = (Pet) o;
return Objects.equals(id, pet.id); return Objects.equals(petId, pet.petId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(petId);
} }
@Override @Override
public String toString() { public String toString() {
return "Pet{" + return "Pet{" +
"id=" + id + "petId=" + petId +
", petName='" + petName + '\'' + ", petName='" + petName + '\'' +
", petSpecies='" + petSpecies + '\'' + ", petSpecies='" + petSpecies + '\'' +
", petBreed='" + petBreed + '\'' + ", petBreed='" + petBreed + '\'' +
", petAge=" + petAge + ", petAge=" + petAge +
", petStatus=" + petStatus + ", petStatus='" + petStatus + '\'' +
", petPrice=" + petPrice + ", petPrice=" + petPrice +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +

View File

@@ -9,28 +9,25 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "products") @Table(name = "product")
public class Product { public class Product {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long prodId;
@Column(name = "product_name", nullable = false, length = 100) @Column(nullable = false, length = 100)
private String productName; private String prodName;
@ManyToOne @ManyToOne
@JoinColumn(name = "category_id", nullable = false) @JoinColumn(name = "categoryId", nullable = false)
private Category category; private Category category;
@Column(name = "product_description", columnDefinition = "TEXT") @Column(columnDefinition = "TEXT")
private String productDescription; private String prodDesc;
@Column(name = "product_price", nullable = false, precision = 10, scale = 2) @Column(nullable = false, precision = 10, scale = 2)
private BigDecimal productPrice; private BigDecimal prodPrice;
@Column(nullable = false)
private Boolean active = true;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -43,31 +40,30 @@ public class Product {
public Product() { public Product() {
} }
public Product(Long id, String productName, Category category, String productDescription, BigDecimal productPrice, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { public Product(Long prodId, String prodName, Category category, String prodDesc, BigDecimal prodPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.prodId = prodId;
this.productName = productName; this.prodName = prodName;
this.category = category; this.category = category;
this.productDescription = productDescription; this.prodDesc = prodDesc;
this.productPrice = productPrice; this.prodPrice = prodPrice;
this.active = active;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getProdId() {
return id; return prodId;
} }
public void setId(Long id) { public void setProdId(Long prodId) {
this.id = id; this.prodId = prodId;
} }
public String getProductName() { public String getProdName() {
return productName; return prodName;
} }
public void setProductName(String productName) { public void setProdName(String prodName) {
this.productName = productName; this.prodName = prodName;
} }
public Category getCategory() { public Category getCategory() {
@@ -78,28 +74,20 @@ public class Product {
this.category = category; this.category = category;
} }
public String getProductDescription() { public String getProdDesc() {
return productDescription; return prodDesc;
} }
public void setProductDescription(String productDescription) { public void setProdDesc(String prodDesc) {
this.productDescription = productDescription; this.prodDesc = prodDesc;
} }
public BigDecimal getProductPrice() { public BigDecimal getProdPrice() {
return productPrice; return prodPrice;
} }
public void setProductPrice(BigDecimal productPrice) { public void setProdPrice(BigDecimal prodPrice) {
this.productPrice = productPrice; this.prodPrice = prodPrice;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -123,23 +111,22 @@ public class Product {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Product product = (Product) o; Product product = (Product) o;
return Objects.equals(id, product.id); return Objects.equals(prodId, product.prodId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(prodId);
} }
@Override @Override
public String toString() { public String toString() {
return "Product{" + return "Product{" +
"id=" + id + "prodId=" + prodId +
", productName='" + productName + '\'' + ", prodName='" + prodName + '\'' +
", category=" + category + ", category=" + category +
", productDescription='" + productDescription + '\'' + ", prodDesc='" + prodDesc + '\'' +
", productPrice=" + productPrice + ", prodPrice=" + prodPrice +
", active=" + active +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -10,28 +10,22 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "product_suppliers") @Table(name = "productSupplier")
@IdClass(ProductSupplier.ProductSupplierId.class) @IdClass(ProductSupplier.ProductSupplierId.class)
public class ProductSupplier { public class ProductSupplier {
@Id @Id
@ManyToOne @ManyToOne
@JoinColumn(name = "product_id", nullable = false) @JoinColumn(name = "prodId", nullable = false)
private Product product; private Product product;
@Id @Id
@ManyToOne @ManyToOne
@JoinColumn(name = "supplier_id", nullable = false) @JoinColumn(name = "supId", nullable = false)
private Supplier supplier; private Supplier supplier;
@Column(name = "cost_price", nullable = false, precision = 10, scale = 2) @Column(nullable = false, precision = 10, scale = 2)
private BigDecimal costPrice; private BigDecimal cost;
@Column(name = "lead_time_days")
private Integer leadTimeDays;
@Column(name = "is_preferred")
private Boolean isPreferred = false;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -44,12 +38,10 @@ public class ProductSupplier {
public 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.product = product;
this.supplier = supplier; this.supplier = supplier;
this.costPrice = costPrice; this.cost = cost;
this.leadTimeDays = leadTimeDays;
this.isPreferred = isPreferred;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
@@ -70,28 +62,12 @@ public class ProductSupplier {
this.supplier = supplier; this.supplier = supplier;
} }
public BigDecimal getCostPrice() { public BigDecimal getCost() {
return costPrice; return cost;
} }
public void setCostPrice(BigDecimal costPrice) { public void setCost(BigDecimal cost) {
this.costPrice = costPrice; this.cost = cost;
}
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 LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -128,9 +104,7 @@ public class ProductSupplier {
return "ProductSupplier{" + return "ProductSupplier{" +
"product=" + product + "product=" + product +
", supplier=" + supplier + ", supplier=" + supplier +
", costPrice=" + costPrice + ", cost=" + cost +
", leadTimeDays=" + leadTimeDays +
", isPreferred=" + isPreferred +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -12,35 +12,22 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "purchase_orders") @Table(name = "purchaseOrder")
public class PurchaseOrder { public class PurchaseOrder {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long purchaseOrderId;
@ManyToOne @ManyToOne
@JoinColumn(name = "supplier_id", nullable = false) @JoinColumn(name = "supId", nullable = false)
private Supplier supplier; private Supplier supplier;
@Column(name = "order_date", nullable = false) @Column(nullable = false)
private LocalDate orderDate; private LocalDate orderDate;
@Column(name = "expected_delivery") @Column(nullable = false, length = 50)
private LocalDate expectedDelivery; private String status;
@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<PurchaseOrderItem> items = new ArrayList<>();
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -50,32 +37,24 @@ public class PurchaseOrder {
@Column(name = "updated_at") @Column(name = "updated_at")
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public enum OrderStatus {
Pending, Delivered, Cancelled
}
public PurchaseOrder() { public PurchaseOrder() {
} }
public PurchaseOrder(Long id, Supplier supplier, LocalDate orderDate, LocalDate expectedDelivery, OrderStatus status, BigDecimal totalAmount, String notes, List<PurchaseOrderItem> items, LocalDateTime createdAt, LocalDateTime updatedAt) { public PurchaseOrder(Long purchaseOrderId, Supplier supplier, LocalDate orderDate, String status, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.purchaseOrderId = purchaseOrderId;
this.supplier = supplier; this.supplier = supplier;
this.orderDate = orderDate; this.orderDate = orderDate;
this.expectedDelivery = expectedDelivery;
this.status = status; this.status = status;
this.totalAmount = totalAmount;
this.notes = notes;
this.items = items;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getPurchaseOrderId() {
return id; return purchaseOrderId;
} }
public void setId(Long id) { public void setPurchaseOrderId(Long purchaseOrderId) {
this.id = id; this.purchaseOrderId = purchaseOrderId;
} }
public Supplier getSupplier() { public Supplier getSupplier() {
@@ -94,46 +73,14 @@ public class PurchaseOrder {
this.orderDate = orderDate; this.orderDate = orderDate;
} }
public LocalDate getExpectedDelivery() { public String getStatus() {
return expectedDelivery;
}
public void setExpectedDelivery(LocalDate expectedDelivery) {
this.expectedDelivery = expectedDelivery;
}
public OrderStatus getStatus() {
return status; return status;
} }
public void setStatus(OrderStatus status) { public void setStatus(String status) {
this.status = 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<PurchaseOrderItem> getItems() {
return items;
}
public void setItems(List<PurchaseOrderItem> items) {
this.items = items;
}
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
return createdAt; return createdAt;
} }
@@ -155,25 +102,21 @@ public class PurchaseOrder {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
PurchaseOrder that = (PurchaseOrder) o; PurchaseOrder that = (PurchaseOrder) o;
return Objects.equals(id, that.id); return Objects.equals(purchaseOrderId, that.purchaseOrderId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(purchaseOrderId);
} }
@Override @Override
public String toString() { public String toString() {
return "PurchaseOrder{" + return "PurchaseOrder{" +
"id=" + id + "purchaseOrderId=" + purchaseOrderId +
", supplier=" + supplier + ", supplier=" + supplier +
", orderDate=" + orderDate + ", orderDate=" + orderDate +
", expectedDelivery=" + expectedDelivery + ", status='" + status + '\'' +
", status=" + status +
", totalAmount=" + totalAmount +
", notes='" + notes + '\'' +
", items=" + items +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -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 +
'}';
}
}

View File

@@ -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<RefundItem> 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<RefundItem> 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<RefundItem> getItems() {
return items;
}
public void setItems(List<RefundItem> 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 +
'}';
}
}

View File

@@ -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 +
'}';
}
}

View File

@@ -2,6 +2,7 @@ package com.petshop.backend.entity;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -10,42 +11,36 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "sales") @Table(name = "sale")
public class Sale { public class Sale {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long saleId;
@Column(name = "sale_date", nullable = false) @Column(nullable = false)
private LocalDateTime saleDate = LocalDateTime.now(); private LocalDateTime saleDate = LocalDateTime.now();
@ManyToOne @ManyToOne
@JoinColumn(name = "employee_id", nullable = false) @JoinColumn(name = "employeeId", nullable = false)
private User employee; private Employee employee;
@ManyToOne @ManyToOne
@JoinColumn(name = "customer_id") @JoinColumn(name = "storeId", nullable = false)
private Customer customer; private StoreLocation store;
@ManyToOne
@JoinColumn(name = "store_id")
private Store store;
@Column(nullable = false, precision = 10, scale = 2) @Column(nullable = false, precision = 10, scale = 2)
private BigDecimal subtotal; private BigDecimal totalAmount;
@Column(nullable = false, precision = 10, scale = 2) @Column(nullable = false, length = 50)
private BigDecimal tax = BigDecimal.ZERO;
@Column(nullable = false, precision = 10, scale = 2)
private BigDecimal total;
@Column(name = "payment_method", length = 50)
private String paymentMethod; private String paymentMethod;
@Column(columnDefinition = "TEXT") @Column(nullable = false)
private String notes; private Boolean isRefund = false;
@ManyToOne
@JoinColumn(name = "originalSaleId")
private Sale originalSale;
@OneToMany(mappedBy = "sale", cascade = CascadeType.ALL) @OneToMany(mappedBy = "sale", cascade = CascadeType.ALL)
private List<SaleItem> items = new ArrayList<>(); private List<SaleItem> items = new ArrayList<>();
@@ -54,30 +49,33 @@ public class Sale {
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
private LocalDateTime createdAt; private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at")
private LocalDateTime updatedAt;
public Sale() { 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<SaleItem> items, LocalDateTime createdAt) { public Sale(Long saleId, LocalDateTime saleDate, Employee employee, StoreLocation store, BigDecimal totalAmount, String paymentMethod, Boolean isRefund, Sale originalSale, List<SaleItem> items, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.saleId = saleId;
this.saleDate = saleDate; this.saleDate = saleDate;
this.employee = employee; this.employee = employee;
this.customer = customer;
this.store = store; this.store = store;
this.subtotal = subtotal; this.totalAmount = totalAmount;
this.tax = tax;
this.total = total;
this.paymentMethod = paymentMethod; this.paymentMethod = paymentMethod;
this.notes = notes; this.isRefund = isRefund;
this.originalSale = originalSale;
this.items = items; this.items = items;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt;
} }
public Long getId() { public Long getSaleId() {
return id; return saleId;
} }
public void setId(Long id) { public void setSaleId(Long saleId) {
this.id = id; this.saleId = saleId;
} }
public LocalDateTime getSaleDate() { public LocalDateTime getSaleDate() {
@@ -88,52 +86,28 @@ public class Sale {
this.saleDate = saleDate; this.saleDate = saleDate;
} }
public User getEmployee() { public Employee getEmployee() {
return employee; return employee;
} }
public void setEmployee(User employee) { public void setEmployee(Employee employee) {
this.employee = employee; this.employee = employee;
} }
public Customer getCustomer() { public StoreLocation getStore() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public Store getStore() {
return store; return store;
} }
public void setStore(Store store) { public void setStore(StoreLocation store) {
this.store = store; this.store = store;
} }
public BigDecimal getSubtotal() { public BigDecimal getTotalAmount() {
return subtotal; return totalAmount;
} }
public void setSubtotal(BigDecimal subtotal) { public void setTotalAmount(BigDecimal totalAmount) {
this.subtotal = subtotal; this.totalAmount = totalAmount;
}
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 String getPaymentMethod() { public String getPaymentMethod() {
@@ -144,12 +118,20 @@ public class Sale {
this.paymentMethod = paymentMethod; this.paymentMethod = paymentMethod;
} }
public String getNotes() { public Boolean getIsRefund() {
return notes; return isRefund;
} }
public void setNotes(String notes) { public void setIsRefund(Boolean isRefund) {
this.notes = notes; this.isRefund = isRefund;
}
public Sale getOriginalSale() {
return originalSale;
}
public void setOriginalSale(Sale originalSale) {
this.originalSale = originalSale;
} }
public List<SaleItem> getItems() { public List<SaleItem> getItems() {
@@ -168,34 +150,41 @@ public class Sale {
this.createdAt = createdAt; this.createdAt = createdAt;
} }
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Sale sale = (Sale) o; Sale sale = (Sale) o;
return Objects.equals(id, sale.id); return Objects.equals(saleId, sale.saleId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(saleId);
} }
@Override @Override
public String toString() { public String toString() {
return "Sale{" + return "Sale{" +
"id=" + id + "saleId=" + saleId +
", saleDate=" + saleDate + ", saleDate=" + saleDate +
", employee=" + employee + ", employee=" + employee +
", customer=" + customer +
", store=" + store + ", store=" + store +
", subtotal=" + subtotal + ", totalAmount=" + totalAmount +
", tax=" + tax +
", total=" + total +
", paymentMethod='" + paymentMethod + '\'' + ", paymentMethod='" + paymentMethod + '\'' +
", notes='" + notes + '\'' + ", isRefund=" + isRefund +
", originalSale=" + originalSale +
", items=" + items + ", items=" + items +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}'; '}';
} }
} }

View File

@@ -1,53 +1,62 @@
package com.petshop.backend.entity; package com.petshop.backend.entity;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "sale_items") @Table(name = "saleItem")
public class SaleItem { public class SaleItem {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long saleItemId;
@ManyToOne @ManyToOne
@JoinColumn(name = "sale_id", nullable = false) @JoinColumn(name = "saleId", nullable = false)
private Sale sale; private Sale sale;
@ManyToOne @ManyToOne
@JoinColumn(name = "product_id", nullable = false) @JoinColumn(name = "prodId", nullable = false)
private Product product; private Product product;
@Column(nullable = false) @Column(nullable = false)
private Integer quantity; private Integer quantity;
@Column(name = "unit_price", nullable = false, precision = 10, scale = 2) @Column(nullable = false, precision = 10, scale = 2)
private BigDecimal unitPrice; private BigDecimal unitPrice;
@Column(nullable = false, precision = 10, scale = 2) @CreationTimestamp
private BigDecimal subtotal; @Column(name = "created_at", updatable = false)
private LocalDateTime createdAt;
@UpdateTimestamp
@Column(name = "updated_at")
private LocalDateTime updatedAt;
public SaleItem() { public SaleItem() {
} }
public SaleItem(Long id, Sale sale, Product product, Integer quantity, BigDecimal unitPrice, BigDecimal subtotal) { public SaleItem(Long saleItemId, Sale sale, Product product, Integer quantity, BigDecimal unitPrice, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.saleItemId = saleItemId;
this.sale = sale; this.sale = sale;
this.product = product; this.product = product;
this.quantity = quantity; this.quantity = quantity;
this.unitPrice = unitPrice; this.unitPrice = unitPrice;
this.subtotal = subtotal; this.createdAt = createdAt;
this.updatedAt = updatedAt;
} }
public Long getId() { public Long getSaleItemId() {
return id; return saleItemId;
} }
public void setId(Long id) { public void setSaleItemId(Long saleItemId) {
this.id = id; this.saleItemId = saleItemId;
} }
public Sale getSale() { public Sale getSale() {
@@ -82,12 +91,20 @@ public class SaleItem {
this.unitPrice = unitPrice; this.unitPrice = unitPrice;
} }
public BigDecimal getSubtotal() { public LocalDateTime getCreatedAt() {
return subtotal; return createdAt;
} }
public void setSubtotal(BigDecimal subtotal) { public void setCreatedAt(LocalDateTime createdAt) {
this.subtotal = subtotal; this.createdAt = createdAt;
}
public LocalDateTime getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
} }
@Override @Override
@@ -95,23 +112,24 @@ public class SaleItem {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
SaleItem saleItem = (SaleItem) o; SaleItem saleItem = (SaleItem) o;
return Objects.equals(id, saleItem.id); return Objects.equals(saleItemId, saleItem.saleItemId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(saleItemId);
} }
@Override @Override
public String toString() { public String toString() {
return "SaleItem{" + return "SaleItem{" +
"id=" + id + "saleItemId=" + saleItemId +
", sale=" + sale + ", sale=" + sale +
", product=" + product + ", product=" + product +
", quantity=" + quantity + ", quantity=" + quantity +
", unitPrice=" + unitPrice + ", unitPrice=" + unitPrice +
", subtotal=" + subtotal + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}'; '}';
} }
} }

View File

@@ -9,27 +9,24 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "services") @Table(name = "service")
public class Service { public class Service {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @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; private String serviceName;
@Column(name = "service_description", columnDefinition = "TEXT") @Column(columnDefinition = "TEXT")
private String serviceDescription; private String serviceDesc;
@Column(name = "service_price", nullable = false, precision = 10, scale = 2) @Column(nullable = false, precision = 10, scale = 2)
private BigDecimal servicePrice; private BigDecimal servicePrice;
@Column(name = "service_duration_minutes")
private Integer serviceDurationMinutes;
@Column(nullable = false) @Column(nullable = false)
private Boolean active = true; private Integer serviceDuration;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -42,23 +39,22 @@ public class Service {
public Service() { public Service() {
} }
public Service(Long id, String serviceName, String serviceDescription, BigDecimal servicePrice, Integer serviceDurationMinutes, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { public Service(Long serviceId, String serviceName, String serviceDesc, BigDecimal servicePrice, Integer serviceDuration, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.serviceId = serviceId;
this.serviceName = serviceName; this.serviceName = serviceName;
this.serviceDescription = serviceDescription; this.serviceDesc = serviceDesc;
this.servicePrice = servicePrice; this.servicePrice = servicePrice;
this.serviceDurationMinutes = serviceDurationMinutes; this.serviceDuration = serviceDuration;
this.active = active;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getServiceId() {
return id; return serviceId;
} }
public void setId(Long id) { public void setServiceId(Long serviceId) {
this.id = id; this.serviceId = serviceId;
} }
public String getServiceName() { public String getServiceName() {
@@ -69,12 +65,12 @@ public class Service {
this.serviceName = serviceName; this.serviceName = serviceName;
} }
public String getServiceDescription() { public String getServiceDesc() {
return serviceDescription; return serviceDesc;
} }
public void setServiceDescription(String serviceDescription) { public void setServiceDesc(String serviceDesc) {
this.serviceDescription = serviceDescription; this.serviceDesc = serviceDesc;
} }
public BigDecimal getServicePrice() { public BigDecimal getServicePrice() {
@@ -85,20 +81,12 @@ public class Service {
this.servicePrice = servicePrice; this.servicePrice = servicePrice;
} }
public Integer getServiceDurationMinutes() { public Integer getServiceDuration() {
return serviceDurationMinutes; return serviceDuration;
} }
public void setServiceDurationMinutes(Integer serviceDurationMinutes) { public void setServiceDuration(Integer serviceDuration) {
this.serviceDurationMinutes = serviceDurationMinutes; this.serviceDuration = serviceDuration;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -122,23 +110,22 @@ public class Service {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Service service = (Service) o; Service service = (Service) o;
return Objects.equals(id, service.id); return Objects.equals(serviceId, service.serviceId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(serviceId);
} }
@Override @Override
public String toString() { public String toString() {
return "Service{" + return "Service{" +
"id=" + id + "serviceId=" + serviceId +
", serviceName='" + serviceName + '\'' + ", serviceName='" + serviceName + '\'' +
", serviceDescription='" + serviceDescription + '\'' + ", serviceDesc='" + serviceDesc + '\'' +
", servicePrice=" + servicePrice + ", servicePrice=" + servicePrice +
", serviceDurationMinutes=" + serviceDurationMinutes + ", serviceDuration=" + serviceDuration +
", active=" + active +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -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 +
'}';
}
}

View File

@@ -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 +
'}';
}
}

View File

@@ -8,30 +8,27 @@ import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
@Entity @Entity
@Table(name = "suppliers") @Table(name = "supplier")
public class Supplier { public class Supplier {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long supId;
@Column(name = "supplier_name", nullable = false, length = 100) @Column(nullable = false, length = 100)
private String supplierName; private String supCompany;
@Column(name = "supplier_contact", length = 100) @Column(nullable = false, length = 50)
private String supplierContact; private String supContactFirstName;
@Column(name = "supplier_email", length = 100) @Column(nullable = false, length = 50)
private String supplierEmail; private String supContactLastName;
@Column(name = "supplier_phone", length = 20) @Column(nullable = false, length = 100)
private String supplierPhone; private String supEmail;
@Column(name = "supplier_address", columnDefinition = "TEXT") @Column(nullable = false, length = 20)
private String supplierAddress; private String supPhone;
@Column(nullable = false)
private Boolean active = true;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
@@ -44,72 +41,63 @@ public class Supplier {
public Supplier() { public Supplier() {
} }
public Supplier(Long id, String supplierName, String supplierContact, String supplierEmail, String supplierPhone, String supplierAddress, Boolean active, LocalDateTime createdAt, LocalDateTime updatedAt) { public Supplier(Long supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone, LocalDateTime createdAt, LocalDateTime updatedAt) {
this.id = id; this.supId = supId;
this.supplierName = supplierName; this.supCompany = supCompany;
this.supplierContact = supplierContact; this.supContactFirstName = supContactFirstName;
this.supplierEmail = supplierEmail; this.supContactLastName = supContactLastName;
this.supplierPhone = supplierPhone; this.supEmail = supEmail;
this.supplierAddress = supplierAddress; this.supPhone = supPhone;
this.active = active;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
public Long getId() { public Long getSupId() {
return id; return supId;
} }
public void setId(Long id) { public void setSupId(Long supId) {
this.id = id; this.supId = supId;
} }
public String getSupplierName() { public String getSupCompany() {
return supplierName; return supCompany;
} }
public void setSupplierName(String supplierName) { public void setSupCompany(String supCompany) {
this.supplierName = supplierName; this.supCompany = supCompany;
} }
public String getSupplierContact() { public String getSupContactFirstName() {
return supplierContact; return supContactFirstName;
} }
public void setSupplierContact(String supplierContact) { public void setSupContactFirstName(String supContactFirstName) {
this.supplierContact = supplierContact; this.supContactFirstName = supContactFirstName;
} }
public String getSupplierEmail() { public String getSupContactLastName() {
return supplierEmail; return supContactLastName;
} }
public void setSupplierEmail(String supplierEmail) { public void setSupContactLastName(String supContactLastName) {
this.supplierEmail = supplierEmail; this.supContactLastName = supContactLastName;
} }
public String getSupplierPhone() { public String getSupEmail() {
return supplierPhone; return supEmail;
} }
public void setSupplierPhone(String supplierPhone) { public void setSupEmail(String supEmail) {
this.supplierPhone = supplierPhone; this.supEmail = supEmail;
} }
public String getSupplierAddress() { public String getSupPhone() {
return supplierAddress; return supPhone;
} }
public void setSupplierAddress(String supplierAddress) { public void setSupPhone(String supPhone) {
this.supplierAddress = supplierAddress; this.supPhone = supPhone;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
} }
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
@@ -133,24 +121,23 @@ public class Supplier {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Supplier supplier = (Supplier) o; Supplier supplier = (Supplier) o;
return Objects.equals(id, supplier.id); return Objects.equals(supId, supplier.supId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(supId);
} }
@Override @Override
public String toString() { public String toString() {
return "Supplier{" + return "Supplier{" +
"id=" + id + "supId=" + supId +
", supplierName='" + supplierName + '\'' + ", supCompany='" + supCompany + '\'' +
", supplierContact='" + supplierContact + '\'' + ", supContactFirstName='" + supContactFirstName + '\'' +
", supplierEmail='" + supplierEmail + '\'' + ", supContactLastName='" + supContactLastName + '\'' +
", supplierPhone='" + supplierPhone + '\'' + ", supEmail='" + supEmail + '\'' +
", supplierAddress='" + supplierAddress + '\'' + ", supPhone='" + supPhone + '\'' +
", active=" + active +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -21,19 +21,10 @@ public class User {
@Column(nullable = false) @Column(nullable = false)
private String password; private String password;
@Column(name = "full_name", nullable = false, length = 100)
private String fullName;
@Column(length = 100)
private String email;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(nullable = false) @Column(nullable = false, length = 20, columnDefinition = "VARCHAR(20)")
private Role role; private Role role;
@Column(nullable = false)
private Boolean active = true;
@CreationTimestamp @CreationTimestamp
@Column(name = "created_at", updatable = false) @Column(name = "created_at", updatable = false)
private LocalDateTime createdAt; private LocalDateTime createdAt;
@@ -43,20 +34,17 @@ public class User {
private LocalDateTime updatedAt; private LocalDateTime updatedAt;
public enum Role { public enum Role {
STAFF, ADMIN, CUSTOMER STAFF, ADMIN
} }
public User() { 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.id = id;
this.username = username; this.username = username;
this.password = password; this.password = password;
this.fullName = fullName;
this.email = email;
this.role = role; this.role = role;
this.active = active;
this.createdAt = createdAt; this.createdAt = createdAt;
this.updatedAt = updatedAt; this.updatedAt = updatedAt;
} }
@@ -85,22 +73,6 @@ public class User {
this.password = password; 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() { public Role getRole() {
return role; return role;
} }
@@ -109,14 +81,6 @@ public class User {
this.role = role; this.role = role;
} }
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
public LocalDateTime getCreatedAt() { public LocalDateTime getCreatedAt() {
return createdAt; return createdAt;
} }
@@ -152,10 +116,7 @@ public class User {
"id=" + id + "id=" + id +
", username='" + username + '\'' + ", username='" + username + '\'' +
", password='" + password + '\'' + ", password='" + password + '\'' +
", fullName='" + fullName + '\'' +
", email='" + email + '\'' +
", role=" + role + ", role=" + role +
", active=" + active +
", createdAt=" + createdAt + ", createdAt=" + createdAt +
", updatedAt=" + updatedAt + ", updatedAt=" + updatedAt +
'}'; '}';

View File

@@ -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<ActivityLog, Long> {
}

View File

@@ -12,7 +12,8 @@ import org.springframework.stereotype.Repository;
public interface AdoptionRepository extends JpaRepository<Adoption, Long> { public interface AdoptionRepository extends JpaRepository<Adoption, Long> {
@Query("SELECT a FROM Adoption a WHERE " + @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, '%'))") "LOWER(a.pet.petName) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Adoption> searchAdoptions(@Param("q") String query, Pageable pageable); Page<Adoption> searchAdoptions(@Param("q") String query, Pageable pageable);
} }

View File

@@ -18,11 +18,12 @@ public interface AppointmentRepository extends JpaRepository<Appointment, Long>
@Query("SELECT a FROM Appointment a WHERE a.appointmentDate = :date AND a.appointmentTime = :time") @Query("SELECT a FROM Appointment a WHERE a.appointmentDate = :date AND a.appointmentTime = :time")
List<Appointment> findByDateAndTime(@Param("date") LocalDate date, @Param("time") LocalTime time); List<Appointment> 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<Appointment> findByServiceAndDate(@Param("serviceId") Long serviceId, @Param("date") LocalDate date); List<Appointment> findByServiceAndDate(@Param("serviceId") Long serviceId, @Param("date") LocalDate date);
@Query("SELECT DISTINCT a FROM Appointment a LEFT JOIN a.pets p WHERE " + @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(a.service.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(p.petName) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Appointment> searchAppointments(@Param("q") String query, Pageable pageable); Page<Appointment> searchAppointments(@Param("q") String query, Pageable pageable);

View File

@@ -17,6 +17,6 @@ public interface CategoryRepository extends JpaRepository<Category, Long> {
@Query("SELECT c FROM Category c WHERE " + @Query("SELECT c FROM Category c WHERE " +
"LOWER(c.categoryName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(c.categoryName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(c.categoryDescription) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(c.categoryType) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Category> searchCategories(@Param("q") String query, Pageable pageable); Page<Category> searchCategories(@Param("q") String query, Pageable pageable);
} }

View File

@@ -12,8 +12,9 @@ import org.springframework.stereotype.Repository;
public interface CustomerRepository extends JpaRepository<Customer, Long> { public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Query("SELECT c FROM Customer c WHERE " + @Query("SELECT c FROM Customer c WHERE " +
"LOWER(c.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(c.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(c.customerEmail) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(c.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(c.customerPhone) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(c.email) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(c.phone) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Customer> searchCustomers(@Param("q") String query, Pageable pageable); Page<Customer> searchCustomers(@Param("q") String query, Pageable pageable);
} }

View File

@@ -1,9 +1,9 @@
package com.petshop.backend.repository; 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface RefundRepository extends JpaRepository<Refund, Long> { public interface EmployeeRepository extends JpaRepository<Employee, Long> {
} }

View File

@@ -13,11 +13,11 @@ import java.util.Optional;
@Repository @Repository
public interface InventoryRepository extends JpaRepository<Inventory, Long> { public interface InventoryRepository extends JpaRepository<Inventory, Long> {
@Query("SELECT i FROM Inventory i WHERE i.product.id = :productId AND i.store.id = :storeId") @Query("SELECT i FROM Inventory i WHERE i.product.prodId = :productId")
Optional<Inventory> findByProductIdAndStoreId(@Param("productId") Long productId, @Param("storeId") Long storeId); Optional<Inventory> findByProductId(@Param("productId") Long productId);
@Query("SELECT i FROM Inventory i WHERE " + @Query("SELECT i FROM Inventory i WHERE " +
"LOWER(i.product.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(i.product.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(i.store.storeName) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(i.product.category.categoryName) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Inventory> searchInventory(@Param("q") String query, Pageable pageable); Page<Inventory> searchInventory(@Param("q") String query, Pageable pageable);
} }

View File

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository;
public interface ProductRepository extends JpaRepository<Product, Long> { public interface ProductRepository extends JpaRepository<Product, Long> {
@Query("SELECT p FROM Product p WHERE " + @Query("SELECT p FROM Product p WHERE " +
"LOWER(p.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(p.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(p.productDescription) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(p.prodDesc) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Product> searchProducts(@Param("q") String query, Pageable pageable); Page<Product> searchProducts(@Param("q") String query, Pageable pageable);
} }

View File

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository;
public interface ProductSupplierRepository extends JpaRepository<ProductSupplier, ProductSupplier.ProductSupplierId> { public interface ProductSupplierRepository extends JpaRepository<ProductSupplier, ProductSupplier.ProductSupplierId> {
@Query("SELECT ps FROM ProductSupplier ps WHERE " + @Query("SELECT ps FROM ProductSupplier ps WHERE " +
"LOWER(ps.product.productName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(ps.product.prodName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(ps.supplier.supplierName) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(ps.supplier.supCompany) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<ProductSupplier> searchProductSuppliers(@Param("q") String query, Pageable pageable); Page<ProductSupplier> searchProductSuppliers(@Param("q") String query, Pageable pageable);
} }

View File

@@ -12,7 +12,6 @@ import org.springframework.stereotype.Repository;
public interface PurchaseOrderRepository extends JpaRepository<PurchaseOrder, Long> { public interface PurchaseOrderRepository extends JpaRepository<PurchaseOrder, Long> {
@Query("SELECT po FROM PurchaseOrder po WHERE " + @Query("SELECT po FROM PurchaseOrder po WHERE " +
"LOWER(po.supplier.supplierName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(po.supplier.supCompany) LIKE LOWER(CONCAT('%', :q, '%'))")
"LOWER(po.notes) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<PurchaseOrder> searchPurchaseOrders(@Param("q") String query, Pageable pageable); Page<PurchaseOrder> searchPurchaseOrders(@Param("q") String query, Pageable pageable);
} }

View File

@@ -12,8 +12,8 @@ import org.springframework.stereotype.Repository;
public interface SaleRepository extends JpaRepository<Sale, Long> { public interface SaleRepository extends JpaRepository<Sale, Long> {
@Query("SELECT s FROM Sale s WHERE " + @Query("SELECT s FROM Sale s WHERE " +
"LOWER(s.customer.customerName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(s.employee.firstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(s.employee.fullName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(s.employee.lastName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(s.store.storeName) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(s.store.storeName) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Sale> searchSales(@Param("q") String query, Pageable pageable); Page<Sale> searchSales(@Param("q") String query, Pageable pageable);
} }

View File

@@ -13,6 +13,6 @@ public interface ServiceRepository extends JpaRepository<Service, Long> {
@Query("SELECT s FROM Service s WHERE " + @Query("SELECT s FROM Service s WHERE " +
"LOWER(s.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(s.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(s.serviceDescription) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(s.serviceDesc) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Service> searchServices(@Param("q") String query, Pageable pageable); Page<Service> searchServices(@Param("q") String query, Pageable pageable);
} }

View File

@@ -1,6 +1,6 @@
package com.petshop.backend.repository; 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.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
@@ -9,10 +9,10 @@ import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface StoreRepository extends JpaRepository<Store, Long> { public interface StoreRepository extends JpaRepository<StoreLocation, Long> {
@Query("SELECT s FROM Store s WHERE " + @Query("SELECT s FROM StoreLocation s WHERE " +
"LOWER(s.storeName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(s.storeName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(s.storeLocation) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(s.address) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Store> searchStores(@Param("q") String query, Pageable pageable); Page<StoreLocation> searchStores(@Param("q") String query, Pageable pageable);
} }

View File

@@ -12,7 +12,8 @@ import org.springframework.stereotype.Repository;
public interface SupplierRepository extends JpaRepository<Supplier, Long> { public interface SupplierRepository extends JpaRepository<Supplier, Long> {
@Query("SELECT s FROM Supplier s WHERE " + @Query("SELECT s FROM Supplier s WHERE " +
"LOWER(s.supplierName) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(s.supCompany) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(s.supplierContact) LIKE LOWER(CONCAT('%', :q, '%'))") "LOWER(s.supContactFirstName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(s.supContactLastName) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<Supplier> searchSuppliers(@Param("q") String query, Pageable pageable); Page<Supplier> searchSuppliers(@Param("q") String query, Pageable pageable);
} }

View File

@@ -16,8 +16,6 @@ public interface UserRepository extends JpaRepository<User, Long> {
boolean existsByUsername(String username); boolean existsByUsername(String username);
@Query("SELECT u FROM User u WHERE " + @Query("SELECT u FROM User u WHERE " +
"LOWER(u.username) LIKE LOWER(CONCAT('%', :q, '%')) OR " + "LOWER(u.username) LIKE LOWER(CONCAT('%', :q, '%'))")
"LOWER(u.fullName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
"LOWER(u.email) LIKE LOWER(CONCAT('%', :q, '%'))")
Page<User> searchUsers(@Param("q") String query, Pageable pageable); Page<User> searchUsers(@Param("q") String query, Pageable pageable);
} }

View File

@@ -36,7 +36,7 @@ public class SecurityConfig {
http http
.csrf(AbstractHttpConfigurer::disable) .csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth -> auth .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("/swagger-ui/**", "/v3/api-docs/**", "/swagger-ui.html").permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/dropdowns/suppliers").hasRole("ADMIN") .requestMatchers(HttpMethod.GET, "/api/v1/dropdowns/suppliers").hasRole("ADMIN")
.requestMatchers("/api/v1/inventory/**").hasRole("ADMIN") .requestMatchers("/api/v1/inventory/**").hasRole("ADMIN")

View File

@@ -24,10 +24,6 @@ public class UserDetailsServiceImpl implements UserDetailsService {
User user = userRepository.findByUsername(username) User user = userRepository.findByUsername(username)
.orElseThrow(() -> new UsernameNotFoundException("User not found: " + 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( return new org.springframework.security.core.userdetails.User(
user.getUsername(), user.getUsername(),
user.getPassword(), user.getPassword(),

View File

@@ -56,8 +56,7 @@ public class AdoptionService {
adoption.setPet(pet); adoption.setPet(pet);
adoption.setCustomer(customer); adoption.setCustomer(customer);
adoption.setAdoptionDate(request.getAdoptionDate()); adoption.setAdoptionDate(request.getAdoptionDate());
adoption.setAdoptionFee(request.getAdoptionFee()); adoption.setAdoptionStatus(request.getAdoptionStatus());
adoption.setNotes(request.getNotes());
adoption = adoptionRepository.save(adoption); adoption = adoptionRepository.save(adoption);
return mapToResponse(adoption); return mapToResponse(adoption);
@@ -77,8 +76,7 @@ public class AdoptionService {
adoption.setPet(pet); adoption.setPet(pet);
adoption.setCustomer(customer); adoption.setCustomer(customer);
adoption.setAdoptionDate(request.getAdoptionDate()); adoption.setAdoptionDate(request.getAdoptionDate());
adoption.setAdoptionFee(request.getAdoptionFee()); adoption.setAdoptionStatus(request.getAdoptionStatus());
adoption.setNotes(request.getNotes());
adoption = adoptionRepository.save(adoption); adoption = adoptionRepository.save(adoption);
return mapToResponse(adoption); return mapToResponse(adoption);
@@ -99,14 +97,13 @@ public class AdoptionService {
private AdoptionResponse mapToResponse(Adoption adoption) { private AdoptionResponse mapToResponse(Adoption adoption) {
return new AdoptionResponse( return new AdoptionResponse(
adoption.getId(), adoption.getAdoptionId(),
adoption.getPet().getId(), adoption.getPet().getPetId(),
adoption.getPet().getPetName(), adoption.getPet().getPetName(),
adoption.getCustomer().getId(), adoption.getCustomer().getCustomerId(),
adoption.getCustomer().getCustomerName(), adoption.getCustomer().getFirstName() + " " + adoption.getCustomer().getLastName(),
adoption.getAdoptionDate(), adoption.getAdoptionDate(),
adoption.getAdoptionFee(), adoption.getAdoptionStatus(),
adoption.getNotes(),
adoption.getCreatedAt(), adoption.getCreatedAt(),
adoption.getUpdatedAt() adoption.getUpdatedAt()
); );

View File

@@ -3,11 +3,9 @@ package com.petshop.backend.service;
import com.petshop.backend.dto.analytics.DashboardResponse; import com.petshop.backend.dto.analytics.DashboardResponse;
import com.petshop.backend.entity.Inventory; import com.petshop.backend.entity.Inventory;
import com.petshop.backend.entity.Product; import com.petshop.backend.entity.Product;
import com.petshop.backend.entity.Refund;
import com.petshop.backend.entity.Sale; import com.petshop.backend.entity.Sale;
import com.petshop.backend.repository.InventoryRepository; import com.petshop.backend.repository.InventoryRepository;
import com.petshop.backend.repository.ProductRepository; import com.petshop.backend.repository.ProductRepository;
import com.petshop.backend.repository.RefundRepository;
import com.petshop.backend.repository.SaleRepository; import com.petshop.backend.repository.SaleRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -22,14 +20,12 @@ import java.util.stream.Collectors;
public class AnalyticsService { public class AnalyticsService {
private final SaleRepository saleRepository; private final SaleRepository saleRepository;
private final RefundRepository refundRepository;
private final InventoryRepository inventoryRepository; private final InventoryRepository inventoryRepository;
private final ProductRepository productRepository; private final ProductRepository productRepository;
public AnalyticsService(SaleRepository saleRepository, RefundRepository refundRepository, public AnalyticsService(SaleRepository saleRepository,
InventoryRepository inventoryRepository, ProductRepository productRepository) { InventoryRepository inventoryRepository, ProductRepository productRepository) {
this.saleRepository = saleRepository; this.saleRepository = saleRepository;
this.refundRepository = refundRepository;
this.inventoryRepository = inventoryRepository; this.inventoryRepository = inventoryRepository;
this.productRepository = productRepository; this.productRepository = productRepository;
} }
@@ -41,11 +37,7 @@ public class AnalyticsService {
.filter(sale -> sale.getSaleDate().isAfter(startDate)) .filter(sale -> sale.getSaleDate().isAfter(startDate))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Refund> refunds = refundRepository.findAll().stream() DashboardResponse.SalesSummary salesSummary = calculateSalesSummary(sales);
.filter(refund -> refund.getRefundDate().isAfter(startDate))
.collect(Collectors.toList());
DashboardResponse.SalesSummary salesSummary = calculateSalesSummary(sales, refunds);
DashboardResponse.InventorySummary inventorySummary = calculateInventorySummary(); DashboardResponse.InventorySummary inventorySummary = calculateInventorySummary();
List<DashboardResponse.TopProduct> topProducts = calculateTopProducts(sales, top); List<DashboardResponse.TopProduct> topProducts = calculateTopProducts(sales, top);
List<DashboardResponse.DailySales> dailySales = calculateDailySales(sales, days); List<DashboardResponse.DailySales> dailySales = calculateDailySales(sales, days);
@@ -53,18 +45,24 @@ public class AnalyticsService {
return new DashboardResponse(salesSummary, inventorySummary, topProducts, dailySales); return new DashboardResponse(salesSummary, inventorySummary, topProducts, dailySales);
} }
private DashboardResponse.SalesSummary calculateSalesSummary(List<Sale> sales, List<Refund> refunds) { private DashboardResponse.SalesSummary calculateSalesSummary(List<Sale> sales) {
BigDecimal totalRevenue = sales.stream() BigDecimal totalRevenue = sales.stream()
.map(Sale::getTotal) .filter(sale -> !sale.getIsRefund())
.map(Sale::getTotalAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
Long totalSales = (long) sales.size(); Long totalSales = sales.stream()
.filter(sale -> !sale.getIsRefund())
.count();
BigDecimal totalRefunds = refunds.stream() BigDecimal totalRefunds = sales.stream()
.map(Refund::getRefundAmount) .filter(Sale::getIsRefund)
.map(Sale::getTotalAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add); .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); return new DashboardResponse.SalesSummary(totalRevenue, totalSales, totalRefunds, totalRefundCount);
} }
@@ -75,14 +73,14 @@ public class AnalyticsService {
Long totalProducts = productRepository.count(); Long totalProducts = productRepository.count();
Long lowStockProducts = allInventory.stream() Long lowStockProducts = allInventory.stream()
.filter(inv -> inv.getQuantity() > 0 && inv.getQuantity() <= inv.getReorderLevel()) .filter(inv -> inv.getQuantity() > 0 && inv.getQuantity() <= 10)
.map(inv -> inv.getProduct().getId()) .map(inv -> inv.getProduct().getProdId())
.distinct() .distinct()
.count(); .count();
Long outOfStockProducts = allInventory.stream() Long outOfStockProducts = allInventory.stream()
.filter(inv -> inv.getQuantity() == 0) .filter(inv -> inv.getQuantity() == 0)
.map(inv -> inv.getProduct().getId()) .map(inv -> inv.getProduct().getProdId())
.distinct() .distinct()
.count(); .count();
@@ -94,10 +92,10 @@ public class AnalyticsService {
for (Sale sale : sales) { for (Sale sale : sales) {
for (var item : sale.getItems()) { for (var item : sale.getItems()) {
Long productId = item.getProduct().getId(); Long productId = item.getProduct().getProdId();
String productName = item.getProduct().getProductName(); String productName = item.getProduct().getProdName();
Long quantitySold = Long.valueOf(item.getQuantity()); Long quantitySold = Long.valueOf(item.getQuantity());
BigDecimal revenue = item.getSubtotal(); BigDecimal revenue = item.getUnitPrice().multiply(BigDecimal.valueOf(item.getQuantity()));
productSalesMap.compute(productId, (key, existing) -> { productSalesMap.compute(productId, (key, existing) -> {
if (existing == null) { if (existing == null) {
@@ -131,7 +129,7 @@ public class AnalyticsService {
LocalDate saleDate = sale.getSaleDate().toLocalDate(); LocalDate saleDate = sale.getSaleDate().toLocalDate();
if (dailySalesMap.containsKey(saleDate)) { if (dailySalesMap.containsKey(saleDate)) {
DashboardResponse.DailySales dailySale = dailySalesMap.get(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); dailySale.setSalesCount(dailySale.getSalesCount() + 1);
} }
} }

View File

@@ -70,9 +70,8 @@ public class AppointmentService {
appointment.setService(service); appointment.setService(service);
appointment.setAppointmentDate(request.getAppointmentDate()); appointment.setAppointmentDate(request.getAppointmentDate());
appointment.setAppointmentTime(request.getAppointmentTime()); appointment.setAppointmentTime(request.getAppointmentTime());
appointment.setStatus(request.getStatus()); appointment.setAppointmentStatus(request.getAppointmentStatus());
appointment.setPets(pets); appointment.setPets(pets);
appointment.setNotes(request.getNotes());
appointment = appointmentRepository.save(appointment); appointment = appointmentRepository.save(appointment);
return mapToResponse(appointment); return mapToResponse(appointment);
@@ -95,9 +94,8 @@ public class AppointmentService {
appointment.setService(service); appointment.setService(service);
appointment.setAppointmentDate(request.getAppointmentDate()); appointment.setAppointmentDate(request.getAppointmentDate());
appointment.setAppointmentTime(request.getAppointmentTime()); appointment.setAppointmentTime(request.getAppointmentTime());
appointment.setStatus(request.getStatus()); appointment.setAppointmentStatus(request.getAppointmentStatus());
appointment.setPets(pets); appointment.setPets(pets);
appointment.setNotes(request.getNotes());
appointment = appointmentRepository.save(appointment); appointment = appointmentRepository.save(appointment);
return mapToResponse(appointment); return mapToResponse(appointment);
@@ -156,21 +154,20 @@ public class AppointmentService {
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Long> petIds = appointment.getPets().stream() List<Long> petIds = appointment.getPets().stream()
.map(Pet::getId) .map(Pet::getPetId)
.collect(Collectors.toList()); .collect(Collectors.toList());
return new AppointmentResponse( return new AppointmentResponse(
appointment.getId(), appointment.getAppointmentId(),
appointment.getCustomer().getId(), appointment.getCustomer().getCustomerId(),
appointment.getCustomer().getCustomerName(), appointment.getCustomer().getFirstName() + " " + appointment.getCustomer().getLastName(),
appointment.getService().getId(), appointment.getService().getServiceId(),
appointment.getService().getServiceName(), appointment.getService().getServiceName(),
appointment.getAppointmentDate(), appointment.getAppointmentDate(),
appointment.getAppointmentTime(), appointment.getAppointmentTime(),
appointment.getStatus() != null ? appointment.getStatus().toString() : null, appointment.getAppointmentStatus(),
petNames, petNames,
petIds, petIds,
appointment.getNotes(),
appointment.getCreatedAt(), appointment.getCreatedAt(),
appointment.getUpdatedAt() appointment.getUpdatedAt()
); );

View File

@@ -40,7 +40,7 @@ public class CategoryService {
public CategoryResponse createCategory(CategoryRequest request) { public CategoryResponse createCategory(CategoryRequest request) {
Category category = new Category(); Category category = new Category();
category.setCategoryName(request.getCategoryName()); category.setCategoryName(request.getCategoryName());
category.setCategoryDescription(request.getCategoryDescription()); category.setCategoryType(request.getCategoryType());
category = categoryRepository.save(category); category = categoryRepository.save(category);
return mapToResponse(category); return mapToResponse(category);
@@ -52,7 +52,7 @@ public class CategoryService {
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + id)); .orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + id));
category.setCategoryName(request.getCategoryName()); category.setCategoryName(request.getCategoryName());
category.setCategoryDescription(request.getCategoryDescription()); category.setCategoryType(request.getCategoryType());
category = categoryRepository.save(category); category = categoryRepository.save(category);
return mapToResponse(category); return mapToResponse(category);
@@ -73,9 +73,9 @@ public class CategoryService {
private CategoryResponse mapToResponse(Category category) { private CategoryResponse mapToResponse(Category category) {
return new CategoryResponse( return new CategoryResponse(
category.getId(), category.getCategoryId(),
category.getCategoryName(), category.getCategoryName(),
category.getCategoryDescription(), category.getCategoryType(),
category.getCreatedAt(), category.getCreatedAt(),
category.getUpdatedAt() category.getUpdatedAt()
); );

View File

@@ -39,10 +39,10 @@ public class CustomerService {
@Transactional @Transactional
public CustomerResponse createCustomer(CustomerRequest request) { public CustomerResponse createCustomer(CustomerRequest request) {
Customer customer = new Customer(); Customer customer = new Customer();
customer.setCustomerName(request.getCustomerName()); customer.setFirstName(request.getFirstName());
customer.setCustomerEmail(request.getCustomerEmail()); customer.setLastName(request.getLastName());
customer.setCustomerPhone(request.getCustomerPhone()); customer.setEmail(request.getEmail());
customer.setCustomerAddress(request.getCustomerAddress()); customer.setPhone(request.getPhone());
customer = customerRepository.save(customer); customer = customerRepository.save(customer);
return mapToResponse(customer); return mapToResponse(customer);
@@ -53,10 +53,10 @@ public class CustomerService {
Customer customer = customerRepository.findById(id) Customer customer = customerRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Customer not found with id: " + id)); .orElseThrow(() -> new ResourceNotFoundException("Customer not found with id: " + id));
customer.setCustomerName(request.getCustomerName()); customer.setFirstName(request.getFirstName());
customer.setCustomerEmail(request.getCustomerEmail()); customer.setLastName(request.getLastName());
customer.setCustomerPhone(request.getCustomerPhone()); customer.setEmail(request.getEmail());
customer.setCustomerAddress(request.getCustomerAddress()); customer.setPhone(request.getPhone());
customer = customerRepository.save(customer); customer = customerRepository.save(customer);
return mapToResponse(customer); return mapToResponse(customer);
@@ -77,11 +77,11 @@ public class CustomerService {
private CustomerResponse mapToResponse(Customer customer) { private CustomerResponse mapToResponse(Customer customer) {
return new CustomerResponse( return new CustomerResponse(
customer.getId(), customer.getCustomerId(),
customer.getCustomerName(), customer.getFirstName(),
customer.getCustomerEmail(), customer.getLastName(),
customer.getCustomerPhone(), customer.getEmail(),
customer.getCustomerAddress(), customer.getPhone(),
customer.getCreatedAt(), customer.getCreatedAt(),
customer.getUpdatedAt() customer.getUpdatedAt()
); );

View File

@@ -5,29 +5,23 @@ import com.petshop.backend.dto.inventory.InventoryRequest;
import com.petshop.backend.dto.inventory.InventoryResponse; import com.petshop.backend.dto.inventory.InventoryResponse;
import com.petshop.backend.entity.Inventory; import com.petshop.backend.entity.Inventory;
import com.petshop.backend.entity.Product; import com.petshop.backend.entity.Product;
import com.petshop.backend.entity.Store;
import com.petshop.backend.exception.ResourceNotFoundException; import com.petshop.backend.exception.ResourceNotFoundException;
import com.petshop.backend.repository.InventoryRepository; import com.petshop.backend.repository.InventoryRepository;
import com.petshop.backend.repository.ProductRepository; import com.petshop.backend.repository.ProductRepository;
import com.petshop.backend.repository.StoreRepository;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
@Service @Service
public class InventoryService { public class InventoryService {
private final InventoryRepository inventoryRepository; private final InventoryRepository inventoryRepository;
private final ProductRepository productRepository; 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.inventoryRepository = inventoryRepository;
this.productRepository = productRepository; this.productRepository = productRepository;
this.storeRepository = storeRepository;
} }
public Page<InventoryResponse> getAllInventory(String query, Pageable pageable) { public Page<InventoryResponse> getAllInventory(String query, Pageable pageable) {
@@ -51,18 +45,9 @@ public class InventoryService {
Product product = productRepository.findById(request.getProdId()) Product product = productRepository.findById(request.getProdId())
.orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + 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 inventory = new Inventory();
inventory.setProduct(product); inventory.setProduct(product);
inventory.setStore(store);
inventory.setQuantity(request.getQuantity()); inventory.setQuantity(request.getQuantity());
inventory.setReorderLevel(request.getReorderLevel());
inventory.setLastRestocked(LocalDateTime.now());
inventory = inventoryRepository.save(inventory); inventory = inventoryRepository.save(inventory);
return mapToResponse(inventory); return mapToResponse(inventory);
@@ -76,17 +61,8 @@ public class InventoryService {
Product product = productRepository.findById(request.getProdId()) Product product = productRepository.findById(request.getProdId())
.orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + 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.setProduct(product);
inventory.setStore(store);
inventory.setQuantity(request.getQuantity()); inventory.setQuantity(request.getQuantity());
inventory.setReorderLevel(request.getReorderLevel());
inventory.setLastRestocked(LocalDateTime.now());
inventory = inventoryRepository.save(inventory); inventory = inventoryRepository.save(inventory);
return mapToResponse(inventory); return mapToResponse(inventory);
@@ -107,15 +83,11 @@ public class InventoryService {
private InventoryResponse mapToResponse(Inventory inventory) { private InventoryResponse mapToResponse(Inventory inventory) {
return new InventoryResponse( return new InventoryResponse(
inventory.getId(), inventory.getInventoryId(),
inventory.getProduct().getId(), inventory.getProduct().getProdId(),
inventory.getProduct().getProductName(), inventory.getProduct().getProdName(),
inventory.getProduct().getCategory().getCategoryName(), inventory.getProduct().getCategory().getCategoryName(),
inventory.getStore() != null ? inventory.getStore().getId() : null,
inventory.getStore() != null ? inventory.getStore().getStoreName() : null,
inventory.getQuantity(), inventory.getQuantity(),
inventory.getReorderLevel(),
inventory.getLastRestocked(),
inventory.getCreatedAt(), inventory.getCreatedAt(),
inventory.getUpdatedAt() inventory.getUpdatedAt()
); );

View File

@@ -81,12 +81,12 @@ public class PetService {
private PetResponse mapToResponse(Pet pet) { private PetResponse mapToResponse(Pet pet) {
return new PetResponse( return new PetResponse(
pet.getId(), pet.getPetId(),
pet.getPetName(), pet.getPetName(),
pet.getPetSpecies(), pet.getPetSpecies(),
pet.getPetBreed(), pet.getPetBreed(),
pet.getPetAge(), pet.getPetAge(),
pet.getPetStatus() != null ? pet.getPetStatus().toString() : null, pet.getPetStatus(),
pet.getPetPrice(), pet.getPetPrice(),
pet.getCreatedAt(), pet.getCreatedAt(),
pet.getUpdatedAt() pet.getUpdatedAt()

View File

@@ -46,11 +46,10 @@ public class ProductService {
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId())); .orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId()));
Product product = new Product(); Product product = new Product();
product.setProductName(request.getProdName()); product.setProdName(request.getProdName());
product.setCategory(category); product.setCategory(category);
product.setProductDescription(request.getProdDesc()); product.setProdDesc(request.getProdDesc());
product.setProductPrice(request.getProdPrice()); product.setProdPrice(request.getProdPrice());
product.setActive(request.getActive() != null ? request.getActive() : true);
product = productRepository.save(product); product = productRepository.save(product);
return mapToResponse(product); return mapToResponse(product);
@@ -64,11 +63,10 @@ public class ProductService {
Category category = categoryRepository.findById(request.getCategoryId()) Category category = categoryRepository.findById(request.getCategoryId())
.orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId())); .orElseThrow(() -> new ResourceNotFoundException("Category not found with id: " + request.getCategoryId()));
product.setProductName(request.getProdName()); product.setProdName(request.getProdName());
product.setCategory(category); product.setCategory(category);
product.setProductDescription(request.getProdDesc()); product.setProdDesc(request.getProdDesc());
product.setProductPrice(request.getProdPrice()); product.setProdPrice(request.getProdPrice());
product.setActive(request.getActive() != null ? request.getActive() : true);
product = productRepository.save(product); product = productRepository.save(product);
return mapToResponse(product); return mapToResponse(product);
@@ -89,13 +87,12 @@ public class ProductService {
private ProductResponse mapToResponse(Product product) { private ProductResponse mapToResponse(Product product) {
return new ProductResponse( return new ProductResponse(
product.getId(), product.getProdId(),
product.getProductName(), product.getProdName(),
product.getCategory().getId(), product.getCategory().getCategoryId(),
product.getCategory().getCategoryName(), product.getCategory().getCategoryName(),
product.getProductDescription(), product.getProdDesc(),
product.getProductPrice(), product.getProdPrice(),
product.getActive(),
product.getCreatedAt(), product.getCreatedAt(),
product.getUpdatedAt() product.getUpdatedAt()
); );

View File

@@ -57,9 +57,7 @@ public class ProductSupplierService {
ProductSupplier productSupplier = new ProductSupplier(); ProductSupplier productSupplier = new ProductSupplier();
productSupplier.setProduct(product); productSupplier.setProduct(product);
productSupplier.setSupplier(supplier); productSupplier.setSupplier(supplier);
productSupplier.setCostPrice(request.getCostPrice()); productSupplier.setCost(request.getCost());
productSupplier.setLeadTimeDays(request.getLeadTimeDays());
productSupplier.setIsPreferred(request.getIsPreferred());
productSupplier = productSupplierRepository.save(productSupplier); productSupplier = productSupplierRepository.save(productSupplier);
return mapToResponse(productSupplier); return mapToResponse(productSupplier);
@@ -72,9 +70,7 @@ public class ProductSupplierService {
.orElseThrow(() -> new ResourceNotFoundException( .orElseThrow(() -> new ResourceNotFoundException(
"ProductSupplier not found with productId: " + productId + " and supplierId: " + supplierId)); "ProductSupplier not found with productId: " + productId + " and supplierId: " + supplierId));
productSupplier.setCostPrice(request.getCostPrice()); productSupplier.setCost(request.getCost());
productSupplier.setLeadTimeDays(request.getLeadTimeDays());
productSupplier.setIsPreferred(request.getIsPreferred());
productSupplier = productSupplierRepository.save(productSupplier); productSupplier = productSupplierRepository.save(productSupplier);
return mapToResponse(productSupplier); return mapToResponse(productSupplier);
@@ -101,13 +97,11 @@ public class ProductSupplierService {
private ProductSupplierResponse mapToResponse(ProductSupplier productSupplier) { private ProductSupplierResponse mapToResponse(ProductSupplier productSupplier) {
return new ProductSupplierResponse( return new ProductSupplierResponse(
productSupplier.getProduct().getId(), productSupplier.getProduct().getProdId(),
productSupplier.getProduct().getProductName(), productSupplier.getProduct().getProdName(),
productSupplier.getSupplier().getId(), productSupplier.getSupplier().getSupId(),
productSupplier.getSupplier().getSupplierName(), productSupplier.getSupplier().getSupCompany(),
productSupplier.getCostPrice(), productSupplier.getCost(),
productSupplier.getLeadTimeDays(),
productSupplier.getIsPreferred(),
productSupplier.getCreatedAt(), productSupplier.getCreatedAt(),
productSupplier.getUpdatedAt() productSupplier.getUpdatedAt()
); );

View File

@@ -1,18 +1,13 @@
package com.petshop.backend.service; package com.petshop.backend.service;
import com.petshop.backend.dto.purchaseorder.PurchaseOrderResponse; 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.PurchaseOrder;
import com.petshop.backend.entity.PurchaseOrderItem;
import com.petshop.backend.exception.ResourceNotFoundException; import com.petshop.backend.exception.ResourceNotFoundException;
import com.petshop.backend.repository.PurchaseOrderRepository; import com.petshop.backend.repository.PurchaseOrderRepository;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service @Service
public class PurchaseOrderService { public class PurchaseOrderService {
@@ -39,33 +34,14 @@ public class PurchaseOrderService {
} }
private PurchaseOrderResponse mapToResponse(PurchaseOrder purchaseOrder) { private PurchaseOrderResponse mapToResponse(PurchaseOrder purchaseOrder) {
List<PurchaseOrderItemResponse> items = purchaseOrder.getItems().stream()
.map(this::mapItemToResponse)
.collect(Collectors.toList());
return new PurchaseOrderResponse( return new PurchaseOrderResponse(
purchaseOrder.getId(), purchaseOrder.getPurchaseOrderId(),
purchaseOrder.getSupplier().getId(), purchaseOrder.getSupplier().getSupId(),
purchaseOrder.getSupplier().getSupplierName(), purchaseOrder.getSupplier().getSupCompany(),
purchaseOrder.getOrderDate(), purchaseOrder.getOrderDate(),
purchaseOrder.getExpectedDelivery(), purchaseOrder.getStatus(),
purchaseOrder.getStatus().toString(),
purchaseOrder.getTotalAmount(),
purchaseOrder.getNotes(),
items,
purchaseOrder.getCreatedAt(), purchaseOrder.getCreatedAt(),
purchaseOrder.getUpdatedAt() purchaseOrder.getUpdatedAt()
); );
} }
private PurchaseOrderItemResponse mapItemToResponse(PurchaseOrderItem item) {
return new PurchaseOrderItemResponse(
item.getId(),
item.getProduct().getId(),
item.getProduct().getProductName(),
item.getQuantity(),
item.getUnitCost(),
item.getSubtotal()
);
}
} }

View File

@@ -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<RefundItem> 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<RefundResponse.RefundItemResponse> 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;
}
}

View File

@@ -22,18 +22,16 @@ public class SaleService {
private final SaleRepository saleRepository; private final SaleRepository saleRepository;
private final ProductRepository productRepository; private final ProductRepository productRepository;
private final CustomerRepository customerRepository;
private final StoreRepository storeRepository; private final StoreRepository storeRepository;
private final InventoryRepository inventoryRepository; 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.saleRepository = saleRepository;
this.productRepository = productRepository; this.productRepository = productRepository;
this.customerRepository = customerRepository;
this.storeRepository = storeRepository; this.storeRepository = storeRepository;
this.inventoryRepository = inventoryRepository; this.inventoryRepository = inventoryRepository;
this.userRepository = userRepository; this.employeeRepository = employeeRepository;
} }
public Page<SaleResponse> getAllSales(String query, Pageable pageable) { public Page<SaleResponse> getAllSales(String query, Pageable pageable) {
@@ -54,62 +52,58 @@ public class SaleService {
@Transactional @Transactional
public SaleResponse createSale(SaleRequest request) { public SaleResponse createSale(SaleRequest request) {
String username = SecurityContextHolder.getContext().getAuthentication().getName(); Employee employee = employeeRepository.findAll().stream()
User employee = userRepository.findByUsername(username) .findFirst()
.orElseThrow(() -> new ResourceNotFoundException("User not found: " + username)); .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())); .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 sale = new Sale();
sale.setSaleDate(LocalDateTime.now()); sale.setSaleDate(LocalDateTime.now());
sale.setEmployee(employee); sale.setEmployee(employee);
sale.setCustomer(customer);
sale.setStore(store); sale.setStore(store);
sale.setPaymentMethod(request.getPaymentMethod()); sale.setPaymentMethod(request.getPaymentMethod());
sale.setTax(request.getTax()); sale.setIsRefund(request.getIsRefund() != null ? request.getIsRefund() : false);
sale.setNotes(request.getNotes());
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<SaleItem> saleItems = new ArrayList<>(); List<SaleItem> saleItems = new ArrayList<>();
for (var itemRequest : request.getItems()) { for (var itemRequest : request.getItems()) {
Product product = productRepository.findById(itemRequest.getProductId()) Product product = productRepository.findById(itemRequest.getProdId())
.orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + itemRequest.getProductId())); .orElseThrow(() -> new ResourceNotFoundException("Product not found with id: " + itemRequest.getProdId()));
Inventory inventory = inventoryRepository.findByProductIdAndStoreId(itemRequest.getProductId(), request.getStoreId()) Inventory inventory = inventoryRepository.findByProductId(itemRequest.getProdId())
.orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " + itemRequest.getProductId() + " at store " + request.getStoreId())); .orElseThrow(() -> new ResourceNotFoundException("Inventory not found for product " + itemRequest.getProdId()));
if (inventory.getQuantity() < itemRequest.getQuantity()) { 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()); ". Available: " + inventory.getQuantity() + ", requested: " + itemRequest.getQuantity());
} }
inventory.setQuantity(inventory.getQuantity() - itemRequest.getQuantity()); inventory.setQuantity(inventory.getQuantity() - itemRequest.getQuantity());
inventoryRepository.save(inventory); inventoryRepository.save(inventory);
BigDecimal unitPrice = product.getProductPrice(); BigDecimal unitPrice = product.getProdPrice();
BigDecimal itemSubtotal = unitPrice.multiply(BigDecimal.valueOf(itemRequest.getQuantity())); BigDecimal itemTotal = unitPrice.multiply(BigDecimal.valueOf(itemRequest.getQuantity()));
SaleItem saleItem = new SaleItem(); SaleItem saleItem = new SaleItem();
saleItem.setSale(sale); saleItem.setSale(sale);
saleItem.setProduct(product); saleItem.setProduct(product);
saleItem.setQuantity(itemRequest.getQuantity()); saleItem.setQuantity(itemRequest.getQuantity());
saleItem.setUnitPrice(unitPrice); saleItem.setUnitPrice(unitPrice);
saleItem.setSubtotal(itemSubtotal);
saleItems.add(saleItem); saleItems.add(saleItem);
subtotal = subtotal.add(itemSubtotal); totalAmount = totalAmount.add(itemTotal);
} }
sale.setSubtotal(subtotal); sale.setTotalAmount(totalAmount);
sale.setTotal(subtotal.add(sale.getTax()));
sale.setItems(saleItems); sale.setItems(saleItems);
Sale savedSale = saleRepository.save(sale); Sale savedSale = saleRepository.save(sale);
@@ -118,37 +112,32 @@ public class SaleService {
private SaleResponse mapToResponse(Sale sale) { private SaleResponse mapToResponse(Sale sale) {
SaleResponse response = new SaleResponse(); SaleResponse response = new SaleResponse();
response.setId(sale.getId()); response.setSaleId(sale.getSaleId());
response.setSaleDate(sale.getSaleDate()); response.setSaleDate(sale.getSaleDate());
response.setEmployeeId(sale.getEmployee().getId()); response.setEmployeeId(sale.getEmployee().getEmployeeId());
response.setEmployeeName(sale.getEmployee().getFullName()); response.setEmployeeName(sale.getEmployee().getFirstName() + " " + sale.getEmployee().getLastName());
if (sale.getCustomer() != null) {
response.setCustomerId(sale.getCustomer().getId());
response.setCustomerName(sale.getCustomer().getCustomerName());
}
if (sale.getStore() != null) { if (sale.getStore() != null) {
response.setStoreId(sale.getStore().getId()); response.setStoreId(sale.getStore().getStoreId());
response.setStoreName(sale.getStore().getStoreName()); response.setStoreName(sale.getStore().getStoreName());
} }
response.setSubtotal(sale.getSubtotal()); response.setTotalAmount(sale.getTotalAmount());
response.setTax(sale.getTax());
response.setTotal(sale.getTotal());
response.setPaymentMethod(sale.getPaymentMethod()); 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()); response.setCreatedAt(sale.getCreatedAt());
List<SaleResponse.SaleItemResponse> itemResponses = new ArrayList<>(); List<SaleResponse.SaleItemResponse> itemResponses = new ArrayList<>();
for (SaleItem item : sale.getItems()) { for (SaleItem item : sale.getItems()) {
SaleResponse.SaleItemResponse itemResponse = new SaleResponse.SaleItemResponse(); SaleResponse.SaleItemResponse itemResponse = new SaleResponse.SaleItemResponse();
itemResponse.setId(item.getId()); itemResponse.setSaleItemId(item.getSaleItemId());
itemResponse.setProductId(item.getProduct().getId()); itemResponse.setProdId(item.getProduct().getProdId());
itemResponse.setProductName(item.getProduct().getProductName()); itemResponse.setProductName(item.getProduct().getProdName());
itemResponse.setQuantity(item.getQuantity()); itemResponse.setQuantity(item.getQuantity());
itemResponse.setUnitPrice(item.getUnitPrice()); itemResponse.setUnitPrice(item.getUnitPrice());
itemResponse.setSubtotal(item.getSubtotal());
itemResponses.add(itemResponse); itemResponses.add(itemResponse);
} }
response.setItems(itemResponses); response.setItems(itemResponses);

View File

@@ -39,10 +39,9 @@ public class ServiceService {
public ServiceResponse createService(ServiceRequest request) { public ServiceResponse createService(ServiceRequest request) {
com.petshop.backend.entity.Service service = new com.petshop.backend.entity.Service(); com.petshop.backend.entity.Service service = new com.petshop.backend.entity.Service();
service.setServiceName(request.getServiceName()); service.setServiceName(request.getServiceName());
service.setServiceDescription(request.getServiceDescription()); service.setServiceDesc(request.getServiceDesc());
service.setServicePrice(request.getServicePrice()); service.setServicePrice(request.getServicePrice());
service.setServiceDurationMinutes(request.getServiceDurationMinutes()); service.setServiceDuration(request.getServiceDuration());
service.setActive(request.getActive() != null ? request.getActive() : true);
service = serviceRepository.save(service); service = serviceRepository.save(service);
return mapToResponse(service); return mapToResponse(service);
@@ -54,10 +53,9 @@ public class ServiceService {
.orElseThrow(() -> new ResourceNotFoundException("Service not found with id: " + id)); .orElseThrow(() -> new ResourceNotFoundException("Service not found with id: " + id));
service.setServiceName(request.getServiceName()); service.setServiceName(request.getServiceName());
service.setServiceDescription(request.getServiceDescription()); service.setServiceDesc(request.getServiceDesc());
service.setServicePrice(request.getServicePrice()); service.setServicePrice(request.getServicePrice());
service.setServiceDurationMinutes(request.getServiceDurationMinutes()); service.setServiceDuration(request.getServiceDuration());
service.setActive(request.getActive() != null ? request.getActive() : true);
service = serviceRepository.save(service); service = serviceRepository.save(service);
return mapToResponse(service); return mapToResponse(service);
@@ -78,12 +76,11 @@ public class ServiceService {
private ServiceResponse mapToResponse(com.petshop.backend.entity.Service service) { private ServiceResponse mapToResponse(com.petshop.backend.entity.Service service) {
return new ServiceResponse( return new ServiceResponse(
service.getId(), service.getServiceId(),
service.getServiceName(), service.getServiceName(),
service.getServiceDescription(), service.getServiceDesc(),
service.getServicePrice(), service.getServicePrice(),
service.getServiceDurationMinutes(), service.getServiceDuration(),
service.getActive(),
service.getCreatedAt(), service.getCreatedAt(),
service.getUpdatedAt() service.getUpdatedAt()
); );

View File

@@ -1,7 +1,7 @@
package com.petshop.backend.service; package com.petshop.backend.service;
import com.petshop.backend.dto.store.StoreResponse; 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 com.petshop.backend.repository.StoreRepository;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@@ -17,7 +17,7 @@ public class StoreService {
} }
public Page<StoreResponse> getAllStores(String query, Pageable pageable) { public Page<StoreResponse> getAllStores(String query, Pageable pageable) {
Page<Store> stores; Page<StoreLocation> stores;
if (query != null && !query.trim().isEmpty()) { if (query != null && !query.trim().isEmpty()) {
stores = storeRepository.searchStores(query, pageable); stores = storeRepository.searchStores(query, pageable);
} else { } else {
@@ -26,11 +26,13 @@ public class StoreService {
return stores.map(this::mapToResponse); return stores.map(this::mapToResponse);
} }
private StoreResponse mapToResponse(Store store) { private StoreResponse mapToResponse(StoreLocation store) {
return new StoreResponse( return new StoreResponse(
store.getId(), store.getStoreId(),
store.getStoreName(), store.getStoreName(),
store.getStoreLocation(), store.getAddress(),
store.getPhone(),
store.getEmail(),
store.getCreatedAt() store.getCreatedAt()
); );
} }

View File

@@ -39,12 +39,11 @@ public class SupplierService {
@Transactional @Transactional
public SupplierResponse createSupplier(SupplierRequest request) { public SupplierResponse createSupplier(SupplierRequest request) {
Supplier supplier = new Supplier(); Supplier supplier = new Supplier();
supplier.setSupplierName(request.getSupName()); supplier.setSupCompany(request.getSupCompany());
supplier.setSupplierContact(request.getSupContact()); supplier.setSupContactFirstName(request.getSupContactFirstName());
supplier.setSupplierEmail(request.getSupEmail()); supplier.setSupContactLastName(request.getSupContactLastName());
supplier.setSupplierPhone(request.getSupPhone()); supplier.setSupEmail(request.getSupEmail());
supplier.setSupplierAddress(request.getSupAddress()); supplier.setSupPhone(request.getSupPhone());
supplier.setActive(request.getActive());
supplier = supplierRepository.save(supplier); supplier = supplierRepository.save(supplier);
return mapToResponse(supplier); return mapToResponse(supplier);
@@ -55,12 +54,11 @@ public class SupplierService {
Supplier supplier = supplierRepository.findById(id) Supplier supplier = supplierRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Supplier not found with id: " + id)); .orElseThrow(() -> new ResourceNotFoundException("Supplier not found with id: " + id));
supplier.setSupplierName(request.getSupName()); supplier.setSupCompany(request.getSupCompany());
supplier.setSupplierContact(request.getSupContact()); supplier.setSupContactFirstName(request.getSupContactFirstName());
supplier.setSupplierEmail(request.getSupEmail()); supplier.setSupContactLastName(request.getSupContactLastName());
supplier.setSupplierPhone(request.getSupPhone()); supplier.setSupEmail(request.getSupEmail());
supplier.setSupplierAddress(request.getSupAddress()); supplier.setSupPhone(request.getSupPhone());
supplier.setActive(request.getActive());
supplier = supplierRepository.save(supplier); supplier = supplierRepository.save(supplier);
return mapToResponse(supplier); return mapToResponse(supplier);
@@ -81,13 +79,12 @@ public class SupplierService {
private SupplierResponse mapToResponse(Supplier supplier) { private SupplierResponse mapToResponse(Supplier supplier) {
return new SupplierResponse( return new SupplierResponse(
supplier.getId(), supplier.getSupId(),
supplier.getSupplierName(), supplier.getSupCompany(),
supplier.getSupplierContact(), supplier.getSupContactFirstName(),
supplier.getSupplierEmail(), supplier.getSupContactLastName(),
supplier.getSupplierPhone(), supplier.getSupEmail(),
supplier.getSupplierAddress(), supplier.getSupPhone(),
supplier.getActive(),
supplier.getCreatedAt(), supplier.getCreatedAt(),
supplier.getUpdatedAt() supplier.getUpdatedAt()
); );

View File

@@ -44,10 +44,7 @@ public class UserService {
User user = new User(); User user = new User();
user.setUsername(request.getUsername()); user.setUsername(request.getUsername());
user.setPassword(passwordEncoder.encode(request.getPassword())); user.setPassword(passwordEncoder.encode(request.getPassword()));
user.setFullName(request.getFullName());
user.setEmail(request.getEmail());
user.setRole(request.getRole()); user.setRole(request.getRole());
user.setActive(request.getActive());
user = userRepository.save(user); user = userRepository.save(user);
return mapToResponse(user); return mapToResponse(user);
@@ -62,10 +59,7 @@ public class UserService {
if (request.getPassword() != null && !request.getPassword().trim().isEmpty()) { if (request.getPassword() != null && !request.getPassword().trim().isEmpty()) {
user.setPassword(passwordEncoder.encode(request.getPassword())); user.setPassword(passwordEncoder.encode(request.getPassword()));
} }
user.setFullName(request.getFullName());
user.setEmail(request.getEmail());
user.setRole(request.getRole()); user.setRole(request.getRole());
user.setActive(request.getActive());
user = userRepository.save(user); user = userRepository.save(user);
return mapToResponse(user); return mapToResponse(user);
@@ -85,15 +79,10 @@ public class UserService {
} }
private UserResponse mapToResponse(User user) { private UserResponse mapToResponse(User user) {
return new UserResponse( UserResponse response = new UserResponse();
user.getId(), response.setId(user.getId());
user.getUsername(), response.setUsername(user.getUsername());
user.getFullName(), response.setRole(user.getRole().toString());
user.getEmail(), return response;
user.getRole().toString(),
user.getActive(),
user.getCreatedAt(),
user.getUpdatedAt()
);
} }
} }

View File

@@ -10,7 +10,9 @@ spring:
jpa: jpa:
hibernate: hibernate:
ddl-auto: update ddl-auto: validate
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
show-sql: ${JPA_SHOW_SQL:false} show-sql: ${JPA_SHOW_SQL:false}
properties: properties:
hibernate: hibernate:

View File

@@ -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"