-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add(product dtos): dto's involved in request and response
- Loading branch information
1 parent
2cd0ae8
commit ca88115
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/auth/api/model/product/ProductRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/auth/api/model/product/ProductResponseDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |