-
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.
feat(customer/addCustomer): update the add customer functionality to …
…use NewCustomerDto while adding new customers
- Loading branch information
Showing
6 changed files
with
126 additions
and
25 deletions.
There are no files selected for viewing
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
84 changes: 84 additions & 0 deletions
84
src/main/java/com/vedasole/ekartecommercebackend/payload/NewCustomerDto.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,84 @@ | ||
package com.vedasole.ekartecommercebackend.payload; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonIncludeProperties; | ||
import com.vedasole.ekartecommercebackend.entity.Customer; | ||
import com.vedasole.ekartecommercebackend.utility.AppConstant.Role; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.hateoas.server.core.Relation; | ||
|
||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.validation.constraints.*; | ||
import java.io.Serial; | ||
import java.io.Serializable; | ||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* DTO for new {@link Customer} | ||
*/ | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Data | ||
@Relation(itemRelation = "customer", collectionRelation = "customers") | ||
public class NewCustomerDto implements Serializable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -4970632778733952870L; | ||
|
||
private long customerId; | ||
|
||
@NotBlank(message = "First name is required") | ||
@Size( | ||
min = 3, | ||
max = 20, | ||
message = "First name must be between minimum of 3 characters and maximum of 20 characters" | ||
) | ||
private String firstName; | ||
|
||
@NotBlank(message = "Last name is required") | ||
@Size( | ||
min = 3, | ||
max = 20, | ||
message = "Last name must be between minimum of 3 characters " + | ||
"and maximum of 20 characters" | ||
) | ||
private String lastName; | ||
|
||
@NotBlank(message = "Email address is required") | ||
@Email(message = "Email address is not valid", | ||
regexp = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$" | ||
) | ||
private String email; | ||
|
||
@NotBlank(message = "Password cannot be blank") | ||
@Size( | ||
min = 3, | ||
max = 20, | ||
message = "Password must be between minimum of 3 characters " + | ||
"and maximum of 20 characters" | ||
) | ||
private String password; | ||
|
||
@NotNull(message = "Phone number is required") | ||
@Pattern( | ||
regexp = "^(\\+\\d{1,3}[- ]?)?\\d{10}$", | ||
message = "Phone number must be a valid 10-digit number" | ||
) | ||
private String phoneNumber; | ||
|
||
@NotNull(message = "Role is required") | ||
@Enumerated(EnumType.STRING) | ||
private Role role; | ||
|
||
@JsonIncludeProperties({"cartId"}) | ||
private ShoppingCartDto shoppingCart; | ||
|
||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") | ||
private LocalDateTime createdAt; | ||
|
||
} |
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
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
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
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