Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
haroun08 committed Dec 28, 2024
2 parents f355a67 + d72079c commit 608351e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down
10 changes: 10 additions & 0 deletions shipping/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 10 additions & 11 deletions shipping/src/main/java/org/shipping/api/AddressResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();

Expand All @@ -62,7 +61,7 @@ public Response addAddress(@Valid AddressDTO addressDTO) {
@GET
public Response getUserAddresses() {
try {
List<Address> addresses = addressService.getAddressesByUserId();
List<org.shipping.model.Address> addresses = addressService.getAddressesByUserId();
return Response.ok(addresses).build();

} catch (IllegalArgumentException e) {
Expand All @@ -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) {
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion shipping/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 608351e

Please sign in to comment.