From a24bb309272745bb93139cea16d5d8e82b77d225 Mon Sep 17 00:00:00 2001 From: yasmineLafhim <yasmine.lafhim@marketingconfort.com> Date: Tue, 27 Aug 2024 14:57:33 +0100 Subject: [PATCH 1/5] add id to productDTO because needed in the front --- CHANGELOG.md | 2 +- pom.xml | 2 +- .../mydressin/controller/SupplierOrderController.java | 9 +++++++-- .../com/marketingconfort/mydressin/dto/ProductDTO.java | 2 +- .../mydressin/exceptions/GlobalExceptionHandler.java | 1 + .../mydressin/mappers/ProductMapper.java | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e570f..9f4c28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -274,7 +274,7 @@ - New features that have been added. ### Changed -- Changes in existing functionality. +- added id to the product enity for creation because it's needed in the front ### Deprecated - Soon-to-be removed features. diff --git a/pom.xml b/pom.xml index 216c9c7..1e8134e 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ <dependency> <groupId>com.marketingconfort</groupId> <artifactId>mydressin-common</artifactId> - <version>1.0.57-RELEASE</version> + <version>1.0.61-RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/src/main/java/com/marketingconfort/mydressin/controller/SupplierOrderController.java b/src/main/java/com/marketingconfort/mydressin/controller/SupplierOrderController.java index 5a061b4..c19aa11 100644 --- a/src/main/java/com/marketingconfort/mydressin/controller/SupplierOrderController.java +++ b/src/main/java/com/marketingconfort/mydressin/controller/SupplierOrderController.java @@ -42,8 +42,13 @@ public class SupplierOrderController { @PostMapping("/new") public ResponseEntity<SupplierOrderDTO> createSupplierOrder(@RequestBody SupplierOrderDTO supplierOrderDTO) { - SupplierOrderDTO createdSupplierOrderDTO = supplierOrderService.saveSupplierOrder(supplierOrderDTO); - return ResponseEntity.status(HttpStatus.CREATED).body(createdSupplierOrderDTO); + try { + SupplierOrderDTO createdSupplierOrderDTO = supplierOrderService.saveSupplierOrder(supplierOrderDTO); + return ResponseEntity.status(HttpStatus.CREATED).body(createdSupplierOrderDTO); + } catch (Exception e) { + System.out.println(e.getMessage()); + return ResponseEntity.badRequest().body(null); + } } @GetMapping("/all") diff --git a/src/main/java/com/marketingconfort/mydressin/dto/ProductDTO.java b/src/main/java/com/marketingconfort/mydressin/dto/ProductDTO.java index c9ec1b4..243db5d 100644 --- a/src/main/java/com/marketingconfort/mydressin/dto/ProductDTO.java +++ b/src/main/java/com/marketingconfort/mydressin/dto/ProductDTO.java @@ -11,7 +11,7 @@ import java.util.Set; @ToString public class ProductDTO { - + private Long id; private String ugs; private String name; private String nameUri; diff --git a/src/main/java/com/marketingconfort/mydressin/exceptions/GlobalExceptionHandler.java b/src/main/java/com/marketingconfort/mydressin/exceptions/GlobalExceptionHandler.java index ac442d9..3dae9a0 100644 --- a/src/main/java/com/marketingconfort/mydressin/exceptions/GlobalExceptionHandler.java +++ b/src/main/java/com/marketingconfort/mydressin/exceptions/GlobalExceptionHandler.java @@ -21,6 +21,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(RuntimeException.class) public ResponseEntity<String> handleRuntimeException(RuntimeException ex) { + System.out.println("An error occurred: " + ex.getMessage()); return new ResponseEntity<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); } diff --git a/src/main/java/com/marketingconfort/mydressin/mappers/ProductMapper.java b/src/main/java/com/marketingconfort/mydressin/mappers/ProductMapper.java index 478e9e5..3fa7672 100644 --- a/src/main/java/com/marketingconfort/mydressin/mappers/ProductMapper.java +++ b/src/main/java/com/marketingconfort/mydressin/mappers/ProductMapper.java @@ -24,6 +24,7 @@ public class ProductMapper { public ProductDTO toDto(Product product) { return ProductDTO.builder() + .id(product.getId()) .ugs(product.getUgs()) .name(product.getName()) .nameUri(product.getNameUri()) @@ -60,7 +61,6 @@ public class ProductMapper { public Product toEntity(ProductDTO dto) { return Product.builder() - .ugs(dto.getUgs()) .name(dto.getName()) .nameUri(dto.getNameUri()) -- GitLab From a1c425b946e84fa260618938516253fdaa6dbaff Mon Sep 17 00:00:00 2001 From: yasmineLafhim <yasmine.lafhim@marketingconfort.com> Date: Wed, 28 Aug 2024 10:26:12 +0100 Subject: [PATCH 2/5] fixes --- .../mydressin/mappers/SupplierOrderMapper.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/marketingconfort/mydressin/mappers/SupplierOrderMapper.java b/src/main/java/com/marketingconfort/mydressin/mappers/SupplierOrderMapper.java index 6e64c8e..f6257da 100644 --- a/src/main/java/com/marketingconfort/mydressin/mappers/SupplierOrderMapper.java +++ b/src/main/java/com/marketingconfort/mydressin/mappers/SupplierOrderMapper.java @@ -25,7 +25,7 @@ public class SupplierOrderMapper { .deliveryDate(supplierOrder.getDeliveryDate()) .total(supplierOrder.getTotal()) .status(supplierOrder.getOrderStatus()) - .idSupplier(supplierOrder.getIdSupplier()) + .idSupplier(supplierOrder.getSupplier().getId()) .idDriver(supplierOrder.getIdDriver()) .orderItems( supplierOrder.getOrderItems() @@ -46,7 +46,7 @@ public class SupplierOrderMapper { supplierOrder.setDeliveryDate(supplierOrderDTO.getDeliveryDate()); supplierOrder.setTotal(supplierOrderDTO.getTotal()); supplierOrder.setOrderStatus(supplierOrderDTO.getStatus()); - supplierOrder.setIdSupplier(supplierOrderDTO.getIdSupplier()); + supplierOrder.getSupplier().setId(supplierOrderDTO.getIdSupplier()); supplierOrder.setIdDriver(supplierOrderDTO.getIdDriver()); supplierOrder.setOrderItems( supplierOrderDTO.getOrderItems() @@ -67,7 +67,7 @@ public class SupplierOrderMapper { .id(supplierOrder.getId()) .creationDate(supplierOrder.getCreationDate()) .deliveryDate(supplierOrder.getDeliveryDate()) - .idSupplier(supplierOrder.getIdSupplier()) + .idSupplier(supplierOrder.getSupplier().getId()) .build(); } @@ -81,7 +81,7 @@ public class SupplierOrderMapper { .creationDate(supplierOrder.getCreationDate()) .deliveryDate(supplierOrder.getDeliveryDate()) .total(supplierOrder.getTotal()) - .supplierId(supplierOrder.getIdSupplier()) + .supplierId(supplierOrder.getSupplier().getId()) .orderItems( supplierOrder.getOrderItems().stream() .map(this::toOrderItemDTO) @@ -118,7 +118,7 @@ public class SupplierOrderMapper { public void updateEntity(SupplierOrder supplierOrder, SupplierOrderUpdateDTO updateDTO) { if (updateDTO.getSupplierId() != null) { - supplierOrder.setIdSupplier(updateDTO.getSupplierId()); + supplierOrder.getSupplier().setId(updateDTO.getSupplierId()); } if (updateDTO.getDeliveryDate() != null) { supplierOrder.setDeliveryDate(updateDTO.getDeliveryDate()); -- GitLab From ce1d5036ea1fbddbb11a6258f835b78f164e954a Mon Sep 17 00:00:00 2001 From: yasmineLafhim <yasmine.lafhim@marketingconfort.com> Date: Wed, 28 Aug 2024 11:20:34 +0100 Subject: [PATCH 3/5] fixes concerning supplierOrder --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0ec101..15b56c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -256,7 +256,7 @@ - Integrate generating nameUri value in createProduct method. ### Changed -- Changes in existing functionality. +- Changes in supplier order . ### Deprecated - Soon-to-be removed features. -- GitLab From 3841e144fc2155146823737a04a15e2abee4d275 Mon Sep 17 00:00:00 2001 From: yasmineLafhim <yasmine.lafhim@marketingconfort.com> Date: Wed, 28 Aug 2024 11:57:17 +0100 Subject: [PATCH 4/5] fixes --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bfc7e2f..9839ffb 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ <dependency> <groupId>com.marketingconfort</groupId> <artifactId>mydressin-common</artifactId> - <version>1.0.62-RELEASE</version> + <version>1.0.63-RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> -- GitLab From 2c2acfafed7b7aa4f42b2d3961b3d9cd1cff0330 Mon Sep 17 00:00:00 2001 From: yasmineLafhim <yasmine.lafhim@marketingconfort.com> Date: Wed, 28 Aug 2024 15:26:05 +0100 Subject: [PATCH 5/5] fixes --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9839ffb..bfc7e2f 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ <dependency> <groupId>com.marketingconfort</groupId> <artifactId>mydressin-common</artifactId> - <version>1.0.63-RELEASE</version> + <version>1.0.62-RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> -- GitLab