diff --git a/src/main/java/com/zufar/onlinestore/product/dto/PriceDetailsDto.java b/src/main/java/com/zufar/onlinestore/product/dto/PriceDetailsDto.java index c64880c8..fd998961 100644 --- a/src/main/java/com/zufar/onlinestore/product/dto/PriceDetailsDto.java +++ b/src/main/java/com/zufar/onlinestore/product/dto/PriceDetailsDto.java @@ -8,11 +8,12 @@ import java.math.BigDecimal; public record PriceDetailsDto( - @NotNull(message = "Price is mandatory") - @DecimalMin(value = "0.0", message = "Price minimum value should be more than 0.0") + + @NotNull(message = "Price is the mandatory attribute") + @DecimalMin(value = "0.0", message = "Price minimum value must be more than 0.0") BigDecimal price, - @NotBlank(message = "Currency is mandatory") + @NotBlank(message = "Currency the mandatory attribute") @Size(max = 55, message = "Currency length must be less than 55 characters") String currency ) { diff --git a/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoDto.java b/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoDto.java index 488a991e..88116f6d 100644 --- a/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoDto.java +++ b/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoDto.java @@ -7,18 +7,18 @@ import java.util.UUID; public record ProductInfoDto( - @NotNull(message = "Id is mandatory") + @NotNull(message = "Id is the mandatory attribute") UUID id, - @NotBlank(message = "Name is mandatory") + @NotBlank(message = "Name is the mandatory attribute") @Size(max = 100, message = "Name length must be less than 100 characters") String name, - @NotBlank(message = "Description is mandatory") + @NotBlank(message = "Description is the mandatory attribute") @Size(max = 1000, message = "Description length must be less than 1000 characters") String description, - @NotNull(message = "Price details is mandatory") + @NotNull(message = "Price details is the mandatory attribute") PriceDetailsDto priceDetails ) { } diff --git a/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoFullDto.java b/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoFullDto.java index 22e8bf55..a2c6c85f 100644 --- a/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoFullDto.java +++ b/src/main/java/com/zufar/onlinestore/product/dto/ProductInfoFullDto.java @@ -7,24 +7,25 @@ import java.util.UUID; public record ProductInfoFullDto( - @NotNull(message = "Id is mandatory") + + @NotNull(message = "Id is the mandatory attribute") UUID id, - @NotBlank(message = "Name is mandatory") + @NotBlank(message = "Name is the mandatory attribute") @Size(max = 100, message = "Name length must be less than 100 characters") String name, - @NotBlank(message = "Description is mandatory") + @NotBlank(message = "Description is the mandatory attribute") @Size(max = 1000, message = "Description length must be less than 1000 characters") String description, - @NotNull(message = "PriceDetails is mandatory") + @NotNull(message = "PriceDetails is the mandatory attribute") PriceDetailsDto priceDetails, - @NotNull(message = "Quantity is mandatory") + @NotNull(message = "Quantity is the mandatory attribute") Integer quantity, - @NotNull(message = "Active is mandatory") + @NotNull(message = "Active is the mandatory attribute") Boolean active ) { } diff --git a/src/main/java/com/zufar/onlinestore/product/endpoint/ProductsEndpoint.java b/src/main/java/com/zufar/onlinestore/product/endpoint/ProductsEndpoint.java index 858004c6..5fd78c23 100644 --- a/src/main/java/com/zufar/onlinestore/product/endpoint/ProductsEndpoint.java +++ b/src/main/java/com/zufar/onlinestore/product/endpoint/ProductsEndpoint.java @@ -29,7 +29,6 @@ public class ProductsEndpoint { private final ProductInfoDtoConverter productInfoDtoConverter; @GetMapping("/{id}") - @ResponseBody public ResponseEntity getProductInfoById(@PathVariable("id") final String id) { log.info("Received request to get the ProductInfo with id - {}.", id); Optional ProductInfo = productInfoRepository.findById(Integer.parseInt(id)); @@ -45,7 +44,6 @@ public ResponseEntity getProductInfoById(@PathVariable("id") fin } @GetMapping - @ResponseBody public ResponseEntity> getAllProducts() { log.info("Received request to get all ProductInfos"); Collection productInfoCollection = productInfoRepository.findAll(); diff --git a/src/main/java/com/zufar/onlinestore/product/entity/ProductInfo.java b/src/main/java/com/zufar/onlinestore/product/entity/ProductInfo.java index 3a0bf152..330fd896 100644 --- a/src/main/java/com/zufar/onlinestore/product/entity/ProductInfo.java +++ b/src/main/java/com/zufar/onlinestore/product/entity/ProductInfo.java @@ -6,6 +6,7 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -17,6 +18,7 @@ @Getter @Setter @NoArgsConstructor +@AllArgsConstructor @Entity @Table(name = "product") public class ProductInfo { @@ -43,16 +45,6 @@ public class ProductInfo { @Column(name = "active", nullable = false) private Boolean active; - public ProductInfo(UUID id, String name, String description, BigDecimal price, String currency, Integer quantity, Boolean active) { - this.id = id; - this.name = name; - this.description = description; - this.price = price; - this.currency = currency; - this.quantity = quantity; - this.active = active; - } - @Override public boolean equals(Object object) { if (this == object)