|
17 | 17 |
|
18 | 18 | package tools.dynamia.modules.saas.domain; |
19 | 19 |
|
| 20 | +import jakarta.persistence.*; |
20 | 21 | import org.hibernate.annotations.BatchSize; |
21 | 22 | import tools.dynamia.domain.contraints.NotEmpty; |
22 | 23 | import tools.dynamia.domain.jpa.BaseEntity; |
23 | 24 | import tools.dynamia.domain.jpa.ContactInfo; |
24 | 25 | import tools.dynamia.domain.util.DomainUtils; |
25 | 26 |
|
26 | | -import jakarta.persistence.Entity; |
27 | | -import jakarta.persistence.OneToOne; |
28 | | -import jakarta.persistence.Table; |
| 27 | +import java.util.ArrayList; |
| 28 | +import java.util.Date; |
| 29 | +import java.util.List; |
29 | 30 |
|
30 | 31 | @Entity |
31 | 32 | @Table(name = "saas_resellers") |
32 | 33 | @BatchSize(size = 20) |
33 | 34 | public class AccountReseller extends BaseEntity { |
34 | 35 |
|
35 | 36 |
|
36 | | - public static AccountReseller findByMainAccount(Long accountId){ |
37 | | - return DomainUtils.lookupCrudService().findSingle(AccountReseller.class,"mainAccount.id",accountId); |
38 | | - } |
39 | | - |
40 | 37 | @NotEmpty |
41 | 38 | private String name; |
42 | 39 | private String identification; |
43 | 40 | private String idType; |
44 | 41 | private ContactInfo contactInfo = new ContactInfo(); |
45 | 42 | private boolean enabled; |
46 | 43 | private Long externalId; |
47 | | - @OneToOne |
| 44 | + @ManyToOne |
48 | 45 | private Account mainAccount; |
49 | 46 | private double comissionRate; |
| 47 | + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true, mappedBy = "reseller") |
| 48 | + private List<AccountResellerAgent> agents = new ArrayList<>(); |
| 49 | + @Temporal(TemporalType.DATE) |
| 50 | + private Date startDate = new Date(); |
| 51 | + @Temporal(TemporalType.DATE) |
| 52 | + private Date endDate = null; |
| 53 | + @Column(length = 1000) |
| 54 | + private String comments; |
50 | 55 |
|
51 | 56 |
|
52 | 57 | public String getName() { |
@@ -74,7 +79,7 @@ public void setIdType(String idType) { |
74 | 79 | } |
75 | 80 |
|
76 | 81 | public ContactInfo getContactInfo() { |
77 | | - if(contactInfo==null){ |
| 82 | + if (contactInfo == null) { |
78 | 83 | contactInfo = new ContactInfo(); |
79 | 84 | } |
80 | 85 | return contactInfo; |
@@ -116,6 +121,38 @@ public void setComissionRate(double comissionRate) { |
116 | 121 | this.comissionRate = comissionRate; |
117 | 122 | } |
118 | 123 |
|
| 124 | + public List<AccountResellerAgent> getAgents() { |
| 125 | + return agents; |
| 126 | + } |
| 127 | + |
| 128 | + public void setAgents(List<AccountResellerAgent> agents) { |
| 129 | + this.agents = agents; |
| 130 | + } |
| 131 | + |
| 132 | + public Date getStartDate() { |
| 133 | + return startDate; |
| 134 | + } |
| 135 | + |
| 136 | + public void setStartDate(Date startDate) { |
| 137 | + this.startDate = startDate; |
| 138 | + } |
| 139 | + |
| 140 | + public Date getEndDate() { |
| 141 | + return endDate; |
| 142 | + } |
| 143 | + |
| 144 | + public void setEndDate(Date endDate) { |
| 145 | + this.endDate = endDate; |
| 146 | + } |
| 147 | + |
| 148 | + public String getComments() { |
| 149 | + return comments; |
| 150 | + } |
| 151 | + |
| 152 | + public void setComments(String comments) { |
| 153 | + this.comments = comments; |
| 154 | + } |
| 155 | + |
119 | 156 | @Override |
120 | 157 | public String toString() { |
121 | 158 | return name; |
|
0 commit comments