diff --git a/src/main/java/auth/api/model/product/ProductRequestDTO.java b/src/main/java/auth/api/model/product/ProductRequestDTO.java new file mode 100644 index 0000000..25d1694 --- /dev/null +++ b/src/main/java/auth/api/model/product/ProductRequestDTO.java @@ -0,0 +1,40 @@ +package auth.api.model.product; + +public class ProductRequestDTO { + + private String title; + private double price; + + public ProductRequestDTO(String title, double price) { + setTitle(title); + setPrice(price); + } + + // Getters + public String getTitle() { + return title; + } + + public double getPrice() { + return price; + } + + // Setters + + public void setTitle(String title) { + if (title == null || title.trim().isBlank()) { + throw new IllegalArgumentException("O nome do produto não deve ser vazio ou nulo."); + } + + this.title = title; + } + + public void setPrice(double price) { + if (price <= 0) { + throw new IllegalArgumentException("O preço do produto não deve ser zerado."); + } + + this.price = price; + } + +} diff --git a/src/main/java/auth/api/model/product/ProductResponseDTO.java b/src/main/java/auth/api/model/product/ProductResponseDTO.java new file mode 100644 index 0000000..5e93053 --- /dev/null +++ b/src/main/java/auth/api/model/product/ProductResponseDTO.java @@ -0,0 +1,39 @@ +package auth.api.model.product; + +public class ProductResponseDTO { + private Long id; + private String title; + private double price; + + public ProductResponseDTO(Long id, String title, double price) { + this.id = id; + this.title = title; + this.price = price; + } + + // Getters + public Long getId() { + return id; + } + + public String getTitle() { + return title; + } + + public double getPrice() { + return price; + } + + // Setters + public void setId(Long id) { + this.id = id; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setPrice(double price) { + this.price = price; + } +}