MCPcopy Create free account
hub / github.com/Fernanda-Kipper/orderhub / Customer

Class Customer

src/main/java/com/kipperdev/orderhub/entity/Customer.java:13–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import java.util.List;
12
13@Entity
14@Table(name = "customers")
15@Data
16@NoArgsConstructor
17@AllArgsConstructor
18public class Customer {
19
20 @Id
21 @GeneratedValue(strategy = GenerationType.IDENTITY)
22 private Long id;
23
24 @NotBlank(message = "Nome é obrigatório")
25 @Column(nullable = false)
26 private String name;
27
28 @Email(message = "Email deve ter formato válido")
29 @NotBlank(message = "Email é obrigatório")
30 @Column(nullable = false, unique = true)
31 private String email;
32
33 @NotBlank(message = "Documento é obrigatório")
34 @Column(nullable = false, unique = true)
35 private String document;
36
37 @NotBlank(message = "Telefone é obrigatório")
38 @Column(nullable = false)
39 private String phone;
40
41 @Column(name = "created_at", nullable = false)
42 private LocalDateTime createdAt;
43
44 @Column(name = "updated_at")
45 private LocalDateTime updatedAt;
46
47 @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
48 private List<Order> orders;
49
50 @PrePersist
51 protected void onCreate() {
52 createdAt = LocalDateTime.now();
53 updatedAt = LocalDateTime.now();
54 }
55
56 @PreUpdate
57 protected void onUpdate() {
58 updatedAt = LocalDateTime.now();
59 }
60}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected