From d4e532a798891a745dada3ecee65c1216ae869c9 Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Sun, 8 Mar 2026 22:01:10 -0600 Subject: [PATCH] Fix desktop ProductSupplier to use composite keys - Remove id field from ProductSupplierResponse - Rename supplierPrice to cost in ProductSupplierResponse and ProductSupplierRequest - Update ProductSupplierApi to use composite keys (productId, supplierId) for update and delete - Update ProductSupplierController delete logic to iterate and delete with composite keys - Update ProductSupplierController mapping to use getCost() instead of getSupplierPrice() - Update ProductSupplierDialogController to pass both productId and supplierId to update - Update ProductSupplierDialogController to use setCost() instead of setSupplierPrice() - Remove unused selectedId field from ProductSupplierDialogController --- log.txt | 67 +++++++++++++++++++ .../api/dto/adoption/AdoptionRequest.java | 3 + .../api/dto/adoption/AdoptionResponse.java | 3 + .../api/dto/analytics/DailySales.java | 3 + .../api/dto/analytics/DashboardResponse.java | 3 + .../api/dto/analytics/TopProduct.java | 3 + .../dto/appointment/AppointmentRequest.java | 3 + .../dto/appointment/AppointmentResponse.java | 3 + .../api/dto/auth/LoginResponse.java | 3 + .../api/dto/auth/UserInfoResponse.java | 3 + .../api/dto/common/DropdownOption.java | 3 + .../api/dto/common/PageResponse.java | 12 ++++ .../api/dto/inventory/InventoryRequest.java | 3 + .../api/dto/inventory/InventoryResponse.java | 3 + .../api/dto/pet/PetRequest.java | 3 + .../api/dto/pet/PetResponse.java | 3 + .../api/dto/product/ProductRequest.java | 3 + .../api/dto/product/ProductResponse.java | 3 + .../ProductSupplierRequest.java | 13 ++-- .../ProductSupplierResponse.java | 18 ++--- .../purchaseorder/PurchaseOrderResponse.java | 3 + .../api/dto/sale/SaleItemRequest.java | 3 + .../api/dto/sale/SaleItemResponse.java | 3 + .../api/dto/sale/SaleRequest.java | 3 + .../api/dto/sale/SaleResponse.java | 3 + .../api/dto/service/ServiceRequest.java | 3 + .../api/dto/service/ServiceResponse.java | 3 + .../api/dto/supplier/SupplierRequest.java | 3 + .../api/dto/supplier/SupplierResponse.java | 3 + .../api/dto/user/UserRequest.java | 3 + .../api/dto/user/UserResponse.java | 3 + .../api/endpoints/ProductSupplierApi.java | 8 +-- .../ProductSupplierController.java | 40 +++++++---- .../ProductSupplierDialogController.java | 6 +- 34 files changed, 206 insertions(+), 39 deletions(-) diff --git a/log.txt b/log.txt index d142919d..485318d5 100644 --- a/log.txt +++ b/log.txt @@ -49,3 +49,70 @@ The last packet sent successfully to the server was 0 milliseconds ago. The driv at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Authentication attempt for username: staff [2026-03-07 17:50:34] [ERROR] EXCEPTION | Location: LoginController.btnLoginClicked | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`) at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Authentication attempt for username: staff +[2026-03-07 17:55:02] [ERROR] EXCEPTION | Location: LoginController.btnLoginClicked | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Authentication attempt for username: staff +[2026-03-07 17:55:16] [ERROR] EXCEPTION | Location: LoginController.btnLoginClicked | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Authentication attempt for username: staff +[2026-03-07 18:11:05] [ERROR] EXCEPTION | Location: LoginController.btnLoginClicked | Type: ConnectException | Message: null | Context: Authentication attempt for username: staff +[2026-03-07 18:11:42] [ERROR] EXCEPTION | Location: LoginController.btnLoginClicked | Type: RuntimeException | Message: Authentication failed. Please log in again. | Context: Authentication attempt for username: staff +[2026-03-07 18:11:48] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:11:52] [ERROR] EXCEPTION | Location: SaleController.setupCreateSale | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Loading products +[2026-03-07 18:11:52] [ERROR] EXCEPTION | Location: SaleController.refreshSales | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Loading sales +[2026-03-07 18:11:53] [ERROR] EXCEPTION | Location: AppointmentController.loadAppointments | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Loading appointments for table display +[2026-03-07 18:11:53] [ERROR] EXCEPTION | Location: ServiceController.displayServices | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Fetching service data for table display +[2026-03-07 18:11:54] [ERROR] EXCEPTION | Location: ServiceController.displayServices | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Fetching service data for table display +[2026-03-07 18:11:56] [ERROR] EXCEPTION | Location: PetController.displayPets | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Fetching pet data for table display +[2026-03-07 18:11:56] [ERROR] EXCEPTION | Location: PetController.displayPets | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Fetching pet data for table display +[2026-03-07 18:11:56] [ERROR] EXCEPTION | Location: AdoptionController.displayAdoptions | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Fetching adoption data for table display +[2026-03-07 18:11:57] [ERROR] EXCEPTION | Location: ProductController.displayProduct | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1] | Context: Fetching product data for table display +[2026-03-07 18:11:58] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:47:48] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:48:01] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:48:05] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:48:05] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:51:14] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:51:14] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:51:28] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-07 18:51:30] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-08 10:03:43] [ERROR] EXCEPTION | Location: SaleController.setupCreateSale | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.product.ProductResponse.getId()" is null | Context: Loading products +[2026-03-08 10:03:43] [ERROR] EXCEPTION | Location: SaleController.refreshSales | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.sale.SaleResponse.getId()" is null | Context: Loading sales +[2026-03-08 10:03:44] [ERROR] EXCEPTION | Location: AppointmentController.loadAppointments | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 219] (through reference chain: org.example.petshopdesktop.api.dto.common.PageResponse["content"]->java.util.ArrayList[0]->org.example.petshopdesktop.api.dto.appointment.AppointmentResponse["petNames"]) | Context: Loading appointments for table display +[2026-03-08 10:03:44] [ERROR] EXCEPTION | Location: ServiceController.displayServices | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.service.ServiceResponse.getId()" is null | Context: Fetching service data for table display +[2026-03-08 10:03:45] [ERROR] EXCEPTION | Location: ServiceController.displayServices | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.service.ServiceResponse.getId()" is null | Context: Fetching service data for table display +[2026-03-08 10:03:46] [ERROR] EXCEPTION | Location: PetController.displayPets | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.pet.PetResponse.getId()" is null | Context: Fetching pet data for table display +[2026-03-08 10:03:46] [ERROR] EXCEPTION | Location: AdoptionController.displayAdoptions | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.adoption.AdoptionResponse.getId()" is null | Context: Fetching adoption data for table display +[2026-03-08 10:03:47] [ERROR] EXCEPTION | Location: AdoptionController.displayAdoptions | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.adoption.AdoptionResponse.getId()" is null | Context: Fetching adoption data for table display +[2026-03-08 10:03:47] [ERROR] EXCEPTION | Location: ProductController.displayProduct | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.product.ProductResponse.getId()" is null | Context: Fetching product data for table display +[2026-03-08 10:03:48] [ERROR] EXCEPTION | Location: InventoryController.displayInventory | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.inventory.InventoryResponse.getId()" is null | Context: Fetching inventory data for table display +[2026-03-08 10:03:48] [ERROR] EXCEPTION | Location: ProductSupplierController.displayProductSupplier | Type: NullPointerException | Message: Cannot invoke "java.math.BigDecimal.doubleValue()" because the return value of "org.example.petshopdesktop.api.dto.productsupplier.ProductSupplierResponse.getSupplierPrice()" is null | Context: Fetching product-supplier data for table display +[2026-03-08 10:03:49] [ERROR] EXCEPTION | Location: SupplierController.displaySupplier | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.supplier.SupplierResponse.getId()" is null | Context: Fetching supplier data for table display +[2026-03-08 10:03:50] [ERROR] EXCEPTION | Location: PurchaseOrderController.loadPurchaseOrders | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.longValue()" because the return value of "org.example.petshopdesktop.api.dto.purchaseorder.PurchaseOrderResponse.getId()" is null | Context: Loading purchase orders for table display +[2026-03-08 10:04:02] [ERROR] EXCEPTION | Location: SaleController.setupCreateSale | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.product.ProductResponse.getId()" is null | Context: Loading products +[2026-03-08 10:04:02] [ERROR] EXCEPTION | Location: SaleController.refreshSales | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.sale.SaleResponse.getId()" is null | Context: Loading sales +[2026-03-08 10:04:03] [ERROR] EXCEPTION | Location: SaleController.refreshSales | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.sale.SaleResponse.getId()" is null | Context: Loading sales +[2026-03-08 10:05:41] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-08 10:05:44] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-08 10:05:46] [ERROR] EXCEPTION | Location: SaleController.setupCreateSale | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.product.ProductResponse.getId()" is null | Context: Loading products +[2026-03-08 10:05:46] [ERROR] EXCEPTION | Location: SaleController.refreshSales | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.sale.SaleResponse.getId()" is null | Context: Loading sales +[2026-03-08 10:05:47] [ERROR] EXCEPTION | Location: SaleController.setupCreateSale | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.product.ProductResponse.getId()" is null | Context: Loading products +[2026-03-08 10:05:47] [ERROR] EXCEPTION | Location: SaleController.refreshSales | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.sale.SaleResponse.getId()" is null | Context: Loading sales +[2026-03-08 10:05:47] [ERROR] EXCEPTION | Location: AppointmentController.loadAppointments | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 219] (through reference chain: org.example.petshopdesktop.api.dto.common.PageResponse["content"]->java.util.ArrayList[0]->org.example.petshopdesktop.api.dto.appointment.AppointmentResponse["petNames"]) | Context: Loading appointments for table display +[2026-03-08 10:05:48] [ERROR] EXCEPTION | Location: AppointmentController.loadAppointments | Type: MismatchedInputException | Message: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`) + at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 219] (through reference chain: org.example.petshopdesktop.api.dto.common.PageResponse["content"]->java.util.ArrayList[0]->org.example.petshopdesktop.api.dto.appointment.AppointmentResponse["petNames"]) | Context: Loading appointments for table display +[2026-03-08 10:12:33] [ERROR] EXCEPTION | Location: LoginController.btnLoginClicked | Type: ConnectException | Message: null | Context: Authentication attempt for username: admin +[2026-03-08 10:55:59] [ERROR] EXCEPTION | Location: AnalyticsController.loadAnalyticsData | Type: RuntimeException | Message: Access restricted. You don't have permission to perform this action. | Context: Loading analytics data +[2026-03-08 10:56:02] [ERROR] EXCEPTION | Location: SaleController.setupCreateSale | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.product.ProductResponse.getId()" is null | Context: Loading products +[2026-03-08 10:56:02] [ERROR] EXCEPTION | Location: SaleController.refreshSales | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.sale.SaleResponse.getId()" is null | Context: Loading sales +[2026-03-08 10:56:04] [ERROR] EXCEPTION | Location: ServiceController.displayServices | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.service.ServiceResponse.getId()" is null | Context: Fetching service data for table display +[2026-03-08 10:56:04] [ERROR] EXCEPTION | Location: PetController.displayPets | Type: NullPointerException | Message: Cannot invoke "java.lang.Long.intValue()" because the return value of "org.example.petshopdesktop.api.dto.pet.PetResponse.getId()" is null | Context: Fetching pet data for table display diff --git a/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionRequest.java index 230d5413..5bea7090 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionRequest.java @@ -8,6 +8,9 @@ public class AdoptionRequest { private LocalDate adoptionDate; private String adoptionStatus; + public AdoptionRequest() { + } + public Long getPetId() { return petId; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionResponse.java index 2466a287..151a76da 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/adoption/AdoptionResponse.java @@ -9,6 +9,9 @@ public class AdoptionResponse { private LocalDate adoptionDate; private String adoptionStatus; + public AdoptionResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/analytics/DailySales.java b/src/main/java/org/example/petshopdesktop/api/dto/analytics/DailySales.java index 602fc8be..5c249452 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/analytics/DailySales.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/analytics/DailySales.java @@ -7,6 +7,9 @@ public class DailySales { private LocalDate date; private BigDecimal totalSales; + public DailySales() { + } + public LocalDate getDate() { return date; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/analytics/DashboardResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/analytics/DashboardResponse.java index 0618419b..0497f48e 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/analytics/DashboardResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/analytics/DashboardResponse.java @@ -11,6 +11,9 @@ public class DashboardResponse { private List dailySales; private List topProducts; + public DashboardResponse() { + } + public BigDecimal getTotalRevenue() { return totalRevenue; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/analytics/TopProduct.java b/src/main/java/org/example/petshopdesktop/api/dto/analytics/TopProduct.java index bc63265a..29c1f7f6 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/analytics/TopProduct.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/analytics/TopProduct.java @@ -7,6 +7,9 @@ public class TopProduct { private Integer quantitySold; private BigDecimal totalRevenue; + public TopProduct() { + } + public String getProductName() { return productName; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentRequest.java index e675834c..fe4f7faa 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentRequest.java @@ -12,6 +12,9 @@ public class AppointmentRequest { private LocalTime appointmentTime; private String appointmentStatus; + public AppointmentRequest() { + } + public List getPetIds() { return petIds; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentResponse.java index bbe42bd1..5c9415d0 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/appointment/AppointmentResponse.java @@ -12,6 +12,9 @@ public class AppointmentResponse { private LocalTime appointmentTime; private String appointmentStatus; + public AppointmentResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/auth/LoginResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/auth/LoginResponse.java index 18eb8449..50354d48 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/auth/LoginResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/auth/LoginResponse.java @@ -5,6 +5,9 @@ public class LoginResponse { private String username; private String role; + public LoginResponse() { + } + public String getToken() { return token; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/auth/UserInfoResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/auth/UserInfoResponse.java index 35192de5..16ee1204 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/auth/UserInfoResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/auth/UserInfoResponse.java @@ -5,6 +5,9 @@ public class UserInfoResponse { private String username; private String role; + public UserInfoResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/common/DropdownOption.java b/src/main/java/org/example/petshopdesktop/api/dto/common/DropdownOption.java index b1f24b9c..08678e53 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/common/DropdownOption.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/common/DropdownOption.java @@ -4,6 +4,9 @@ public class DropdownOption { private Long id; private String label; + public DropdownOption() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/common/PageResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/common/PageResponse.java index 9676a55d..bbcc467c 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/common/PageResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/common/PageResponse.java @@ -1,15 +1,27 @@ package org.example.petshopdesktop.api.dto.common; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.List; +@JsonIgnoreProperties(ignoreUnknown = true) public class PageResponse { private List content; + + @JsonProperty("number") private int pageNumber; + + @JsonProperty("size") private int pageSize; + private long totalElements; private int totalPages; private boolean last; + public PageResponse() { + } + public List getContent() { return content; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryRequest.java index 4eb99cd0..03abd005 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryRequest.java @@ -6,6 +6,9 @@ public class InventoryRequest { private Integer stockQuantity; private Integer reorderLevel; + public InventoryRequest() { + } + public Long getProductId() { return productId; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryResponse.java index 7a9ac8b7..15250c74 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/inventory/InventoryResponse.java @@ -8,6 +8,9 @@ public class InventoryResponse { private Integer stockQuantity; private Integer reorderLevel; + public InventoryResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/pet/PetRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/pet/PetRequest.java index a67d3e45..78a9ebfb 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/pet/PetRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/pet/PetRequest.java @@ -13,6 +13,9 @@ public class PetRequest { private BigDecimal price; private String petStatus; + public PetRequest() { + } + public String getPetName() { return petName; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/pet/PetResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/pet/PetResponse.java index 5565e583..f865e58d 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/pet/PetResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/pet/PetResponse.java @@ -14,6 +14,9 @@ public class PetResponse { private BigDecimal price; private String petStatus; + public PetResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/product/ProductRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/product/ProductRequest.java index a51ee4d0..7591a279 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/product/ProductRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/product/ProductRequest.java @@ -8,6 +8,9 @@ public class ProductRequest { private BigDecimal price; private String description; + public ProductRequest() { + } + public String getProductName() { return productName; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/product/ProductResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/product/ProductResponse.java index 07efa236..11f84b1f 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/product/ProductResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/product/ProductResponse.java @@ -9,6 +9,9 @@ public class ProductResponse { private BigDecimal price; private String description; + public ProductResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierRequest.java index e57d3801..69f4ad61 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierRequest.java @@ -5,7 +5,10 @@ import java.math.BigDecimal; public class ProductSupplierRequest { private Long productId; private Long supplierId; - private BigDecimal supplierPrice; + private BigDecimal cost; + + public ProductSupplierRequest() { + } public Long getProductId() { return productId; @@ -23,11 +26,11 @@ public class ProductSupplierRequest { this.supplierId = supplierId; } - public BigDecimal getSupplierPrice() { - return supplierPrice; + public BigDecimal getCost() { + return cost; } - public void setSupplierPrice(BigDecimal supplierPrice) { - this.supplierPrice = supplierPrice; + public void setCost(BigDecimal cost) { + this.cost = cost; } } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierResponse.java index 55478763..b601efe3 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/productsupplier/ProductSupplierResponse.java @@ -3,19 +3,13 @@ package org.example.petshopdesktop.api.dto.productsupplier; import java.math.BigDecimal; public class ProductSupplierResponse { - private Long id; private Long productId; private Long supplierId; private String productName; private String supplierName; - private BigDecimal supplierPrice; + private BigDecimal cost; - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; + public ProductSupplierResponse() { } public Long getProductId() { @@ -50,11 +44,11 @@ public class ProductSupplierResponse { this.supplierName = supplierName; } - public BigDecimal getSupplierPrice() { - return supplierPrice; + public BigDecimal getCost() { + return cost; } - public void setSupplierPrice(BigDecimal supplierPrice) { - this.supplierPrice = supplierPrice; + public void setCost(BigDecimal cost) { + this.cost = cost; } } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/purchaseorder/PurchaseOrderResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/purchaseorder/PurchaseOrderResponse.java index 8bc1c13c..e9148015 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/purchaseorder/PurchaseOrderResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/purchaseorder/PurchaseOrderResponse.java @@ -11,6 +11,9 @@ public class PurchaseOrderResponse { private String orderStatus; private BigDecimal totalAmount; + public PurchaseOrderResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemRequest.java index a853a608..aef71134 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemRequest.java @@ -7,6 +7,9 @@ public class SaleItemRequest { private Integer quantity; private BigDecimal unitPrice; + public SaleItemRequest() { + } + public Long getProductId() { return productId; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemResponse.java index 98d989bf..74205c73 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleItemResponse.java @@ -9,6 +9,9 @@ public class SaleItemResponse { private BigDecimal unitPrice; private BigDecimal lineTotal; + public SaleItemResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleRequest.java index cb856e06..991f7810 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleRequest.java @@ -9,6 +9,9 @@ public class SaleRequest { private Boolean isRefund; private Long originalSaleId; + public SaleRequest() { + } + public Long getStoreId() { return storeId; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleResponse.java index e2ed8111..13444fb8 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/sale/SaleResponse.java @@ -15,6 +15,9 @@ public class SaleResponse { private Long originalSaleId; private List items; + public SaleResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceRequest.java index 11d7659a..7eed5022 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceRequest.java @@ -7,6 +7,9 @@ public class ServiceRequest { private BigDecimal price; private String description; + public ServiceRequest() { + } + public String getServiceName() { return serviceName; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceResponse.java index e3e61a08..339fe7e0 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/service/ServiceResponse.java @@ -8,6 +8,9 @@ public class ServiceResponse { private BigDecimal price; private String description; + public ServiceResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierRequest.java index 51b31b96..9d2c861e 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierRequest.java @@ -7,6 +7,9 @@ public class SupplierRequest { private String email; private String address; + public SupplierRequest() { + } + public String getSupplierName() { return supplierName; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierResponse.java index 5aebfbab..56aa76e4 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/supplier/SupplierResponse.java @@ -8,6 +8,9 @@ public class SupplierResponse { private String email; private String address; + public SupplierResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/user/UserRequest.java b/src/main/java/org/example/petshopdesktop/api/dto/user/UserRequest.java index faa63bcf..72156ac9 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/user/UserRequest.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/user/UserRequest.java @@ -8,6 +8,9 @@ public class UserRequest { private String role; private Boolean active; + public UserRequest() { + } + public String getUsername() { return username; } diff --git a/src/main/java/org/example/petshopdesktop/api/dto/user/UserResponse.java b/src/main/java/org/example/petshopdesktop/api/dto/user/UserResponse.java index 74776269..b26d4830 100644 --- a/src/main/java/org/example/petshopdesktop/api/dto/user/UserResponse.java +++ b/src/main/java/org/example/petshopdesktop/api/dto/user/UserResponse.java @@ -10,6 +10,9 @@ public class UserResponse { private Boolean active; private LocalDateTime createdAt; + public UserResponse() { + } + public Long getId() { return id; } diff --git a/src/main/java/org/example/petshopdesktop/api/endpoints/ProductSupplierApi.java b/src/main/java/org/example/petshopdesktop/api/endpoints/ProductSupplierApi.java index ea65becf..74143c0f 100644 --- a/src/main/java/org/example/petshopdesktop/api/endpoints/ProductSupplierApi.java +++ b/src/main/java/org/example/petshopdesktop/api/endpoints/ProductSupplierApi.java @@ -43,11 +43,11 @@ public class ProductSupplierApi { return apiClient.post("/api/v1/product-suppliers", request, ProductSupplierResponse.class); } - public ProductSupplierResponse updateProductSupplier(Long id, ProductSupplierRequest request) throws Exception { - return apiClient.put("/api/v1/product-suppliers/" + id, request, ProductSupplierResponse.class); + public ProductSupplierResponse updateProductSupplier(Long productId, Long supplierId, ProductSupplierRequest request) throws Exception { + return apiClient.put("/api/v1/product-suppliers/" + productId + "/" + supplierId, request, ProductSupplierResponse.class); } - public void deleteProductSuppliers(List ids) throws Exception { - apiClient.deleteWithBody("/api/v1/product-suppliers", new BulkDeleteRequest(ids)); + public void deleteProductSupplier(Long productId, Long supplierId) throws Exception { + apiClient.delete("/api/v1/product-suppliers/" + productId + "/" + supplierId); } } diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java index e3e50d09..63bba3ae 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java @@ -192,24 +192,36 @@ public class ProductSupplierController { //if confirmed, start deletion if (result.isPresent() && result.get() == ButtonType.OK) { - List ids = selectedProductSuppliers.stream() - .map(ps -> (long) ps.getSupId()) - .collect(Collectors.toList()); + int deleteCount = 0; + Exception lastException = null; - try { - ProductSupplierApi.getInstance().deleteProductSuppliers(ids); + for (ProductSupplierDTO ps : selectedProductSuppliers) { + try { + ProductSupplierApi.getInstance().deleteProductSupplier( + (long) ps.getProdId(), + (long) ps.getSupId() + ); + deleteCount++; + } catch (Exception e) { + lastException = e; + ActivityLogger.getInstance().logException( + "ProductSupplierController.btnDeleteClicked", + e, + "Deleting product-supplier with productId=" + ps.getProdId() + ", supplierId=" + ps.getSupId()); + } + } + + if (deleteCount > 0) { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setHeaderText("Database Operation Confirmed"); - alert.setContentText("Successfully deleted " + ids.size() + " product-supplier(s)"); + alert.setContentText("Successfully deleted " + deleteCount + " product-supplier(s)"); alert.showAndWait(); - } catch (Exception e) { - ActivityLogger.getInstance().logException( - "ProductSupplierController.btnDeleteClicked", - e, - "Deleting product-suppliers"); + } + + if (lastException != null && deleteCount < selectedProductSuppliers.size()) { Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setHeaderText("Delete Operation Failed"); - alert.setContentText(e.getMessage()); + alert.setHeaderText("Delete Operation Partially Failed"); + alert.setContentText("Deleted " + deleteCount + " of " + selectedProductSuppliers.size() + " product-supplier(s). Last error: " + lastException.getMessage()); alert.showAndWait(); } @@ -286,7 +298,7 @@ public class ProductSupplierController { response.getProductId().intValue(), response.getSupplierName(), response.getProductName(), - response.getSupplierPrice().doubleValue() + response.getCost().doubleValue() ); } diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java index 3b67fc54..2348b43b 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java @@ -46,7 +46,6 @@ public class ProductSupplierDialogController { private String mode = null; private int selectedSupId = -1; private int selectedProdId = -1; - private Long selectedId = null; /** * add event listeners to buttons and set up combobox @@ -169,7 +168,7 @@ public class ProductSupplierDialogController { if (mode.equals("Add")) { ProductSupplierApi.getInstance().createProductSupplier(request); } else { - ProductSupplierApi.getInstance().updateProductSupplier(selectedId, request); + ProductSupplierApi.getInstance().updateProductSupplier((long) selectedProdId, (long) selectedSupId, request); } Platform.runLater(() -> { @@ -209,7 +208,7 @@ public class ProductSupplierDialogController { request.setSupplierId(cbSupplier.getSelectionModel().getSelectedItem().getId()); request.setProductId(cbProduct.getSelectionModel().getSelectedItem().getId()); try { - request.setSupplierPrice(new BigDecimal(txtCost.getText())); + request.setCost(new BigDecimal(txtCost.getText())); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid cost format"); } @@ -266,7 +265,6 @@ public class ProductSupplierDialogController { public void setSelectedIds(int supId, int prodId){ this.selectedSupId = supId; this.selectedProdId = prodId; - this.selectedId = (long) supId; } }