diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 2d8f96bf..543a4bd3 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,13 +1,13 @@ - + postgresql true true $PROJECT_DIR$/order/src/main/resources/application-dev.yml org.postgresql.Driver - jdbc:postgresql://localhost:5432/order_service + jdbc:postgresql://localhost:5432/db_order diff --git a/.idea/modules.xml b/.idea/modules.xml index ffed9f1c..3428257d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,6 @@ - diff --git a/order/src/main/java/com/microservices/order_service/dto/Address.java b/order/src/main/java/com/microservices/order_service/dto/Address.java index 47dad702..7ee282fb 100644 --- a/order/src/main/java/com/microservices/order_service/dto/Address.java +++ b/order/src/main/java/com/microservices/order_service/dto/Address.java @@ -1,8 +1,5 @@ package com.microservices.order_service.dto; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/shipping/docker-compose.yml b/shipping/docker-compose.yml new file mode 100644 index 00000000..a4e58ead --- /dev/null +++ b/shipping/docker-compose.yml @@ -0,0 +1,10 @@ +services: + + db_shipping: + image: pgvector/pgvector:pg15 + environment: + POSTGRES_DB: db_shipping + POSTGRES_USER: postgres + POSTGRES_PASSWORD: azerty + ports: + - 5442:5432 \ No newline at end of file diff --git a/shipping/src/main/java/org/shipping/api/AddressResource.java b/shipping/src/main/java/org/shipping/api/AddressResource.java index f612c128..ad3f64ae 100755 --- a/shipping/src/main/java/org/shipping/api/AddressResource.java +++ b/shipping/src/main/java/org/shipping/api/AddressResource.java @@ -10,9 +10,8 @@ import jakarta.ws.rs.core.Response; import org.jboss.logging.Logger; -import org.shipping.dto.AddressDTO; +import org.shipping.dto.Address; import org.shipping.dto.AddressUpdateDTO; -import org.shipping.model.Address; import org.shipping.service.AddressService; import java.util.List; @@ -32,13 +31,13 @@ public class AddressResource { @POST @Path("/add") @Transactional - public Response addAddress(@Valid AddressDTO addressDTO) { + public Response addAddress(@Valid Address address) { try { - Address createdAddress = addressService.addAddress( - addressDTO.getStreet(), - addressDTO.getPostalCode(), - addressDTO.getCity(), - addressDTO.getCountry()); + org.shipping.model.Address createdAddress = addressService.addAddress( + address.getStreet(), + address.getPostalCode(), + address.getCity(), + address.getCountry()); return Response.status(Response.Status.CREATED).entity(createdAddress).build(); @@ -62,7 +61,7 @@ public Response addAddress(@Valid AddressDTO addressDTO) { @GET public Response getUserAddresses() { try { - List
addresses = addressService.getAddressesByUserId(); + List addresses = addressService.getAddressesByUserId(); return Response.ok(addresses).build(); } catch (IllegalArgumentException e) { @@ -83,7 +82,7 @@ public Response getUserAddresses() { @Path("/{addressId}") public Response getAddressById(@PathParam("addressId") UUID addressId) { try { - Address address = addressService.getAddressById(addressId); + org.shipping.model.Address address = addressService.getAddressById(addressId); return Response.status(Response.Status.OK).entity(address).build(); } catch (IllegalArgumentException e) { @@ -104,7 +103,7 @@ public Response getAddressById(@PathParam("addressId") UUID addressId) { @Transactional public Response updateAddress(@PathParam("addressId") UUID addressId, @Valid AddressUpdateDTO addressDTO) { try { - Address updatedAddress = addressService.updateAddress( + org.shipping.model.Address updatedAddress = addressService.updateAddress( addressId, addressDTO.getStreet(), addressDTO.getPostalCode(), diff --git a/shipping/src/main/java/org/shipping/dto/AddressDTO.java b/shipping/src/main/java/org/shipping/dto/Address.java old mode 100755 new mode 100644 similarity index 92% rename from shipping/src/main/java/org/shipping/dto/AddressDTO.java rename to shipping/src/main/java/org/shipping/dto/Address.java index 4eeebbf5..84101fbc --- a/shipping/src/main/java/org/shipping/dto/AddressDTO.java +++ b/shipping/src/main/java/org/shipping/dto/Address.java @@ -6,7 +6,7 @@ import java.util.UUID; -public class AddressDTO { +public class Address { private UUID addressId; // Utilisé pour l'identifiant de l'adresse (lecture seule) @@ -27,11 +27,11 @@ public class AddressDTO { private String country; // Pays // Constructeur sans paramètres - public AddressDTO() { + public Address() { } // Constructeur avec paramètres - public AddressDTO(UUID addressId, String street, String postalCode, String city, String country) { + public Address(UUID addressId, String street, String postalCode, String city, String country) { this.addressId = addressId; this.street = street; this.postalCode = postalCode; diff --git a/shipping/src/main/java/org/shipping/messaging/OrderEventConsumer.java b/shipping/src/main/java/org/shipping/messaging/OrderEventConsumer.java index 1b045310..bdf62fab 100755 --- a/shipping/src/main/java/org/shipping/messaging/OrderEventConsumer.java +++ b/shipping/src/main/java/org/shipping/messaging/OrderEventConsumer.java @@ -15,6 +15,7 @@ public class OrderEventConsumer { @Incoming("order-paid") // Correspond au topic configuré public void consumeOrderPaidEvent(OrderPaidEvent event) { + System.out.println("Order paid event with address: " + event.getAddressId()); // Créez une livraison à partir des données reçues shippingService.createShipment(event.getOrderId(), event.getAddressId()); } diff --git a/shipping/src/main/resources/application.properties b/shipping/src/main/resources/application.properties index 0268094c..bca79bcc 100755 --- a/shipping/src/main/resources/application.properties +++ b/shipping/src/main/resources/application.properties @@ -9,7 +9,7 @@ quarkus.datasource.password=azerty quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5442/db_shipping # drop and create the database at startup (use `update` to only update the schema) -quarkus.hibernate-orm.database.generation=create +quarkus.hibernate-orm.database.generation=update %dev.quarkus.hibernate-orm.log.sql=true %dev.quarkus.hibernate-orm.log.format-sql=true %dev.quarkus.hibernate-orm.statistics=true