diff --git a/src/main/java/com/wellsfargo/counselor/entity/Client.java b/src/main/java/com/wellsfargo/counselor/entity/Client.java new file mode 100644 index 00000000..bf24fa4a --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Client.java @@ -0,0 +1,41 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; + +@Entity +public class Client { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long clientId; + + private String name; + private String email; + private String phoneNumber; + + @ManyToOne + @JoinColumn(name = "advisor_id", nullable = false) + private FinancialAdvisor advisor; + + @OneToOne(mappedBy = "client", cascade = CascadeType.ALL, orphanRemoval = true) + private Portfolio portfolio; + + public Client() {} + + public Client(String name, String email, String phoneNumber, FinancialAdvisor advisor) { + this.name = name; + this.email = email; + this.phoneNumber = phoneNumber; + this.advisor = advisor; + } + + public Long getClientId() { return clientId; } + public String getName() { return name; } + public String getEmail() { return email; } + public String getPhoneNumber() { return phoneNumber; } + public FinancialAdvisor getAdvisor() { return advisor; } + public Portfolio getPortfolio() { return portfolio; } + + public void setName(String name) { this.name = name; } + public void setEmail(String email) { this.email = email; } + public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } +} diff --git a/src/main/java/com/wellsfargo/counselor/entity/FinancialAdvisor.java b/src/main/java/com/wellsfargo/counselor/entity/FinancialAdvisor.java new file mode 100644 index 00000000..507094cb --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/FinancialAdvisor.java @@ -0,0 +1,36 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; +import java.util.List; + +@Entity +public class FinancialAdvisor { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long advisorId; + + private String name; + private String email; + private String phoneNumber; + + @OneToMany(mappedBy = "advisor", cascade = CascadeType.ALL, orphanRemoval = true) + private List clients; + + public FinancialAdvisor() {} + + public FinancialAdvisor(String name, String email, String phoneNumber) { + this.name = name; + this.email = email; + this.phoneNumber = phoneNumber; + } + + public Long getAdvisorId() { return advisorId; } + public String getName() { return name; } + public String getEmail() { return email; } + public String getPhoneNumber() { return phoneNumber; } + public List getClients() { return clients; } + + public void setName(String name) { this.name = name; } + public void setEmail(String email) { this.email = email; } + public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } +} diff --git a/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java b/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java new file mode 100644 index 00000000..f696da6f --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Portfolio.java @@ -0,0 +1,29 @@ +package com.wellsfargo.counselor.entity; + +import jakarta.persistence.*; +import java.util.List; + +@Entity +public class Portfolio { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long portfolioId; + + @OneToOne + @JoinColumn(name = "client_id", nullable = false) + private Client client; + + @OneToMany(mappedBy = "portfolio", cascade = CascadeType.ALL, orphanRemoval = true) + private List securities; + + public Portfolio() {} + + public Portfolio(Client client) { + this.client = client; + } + + public Long getPortfolioId() { return portfolioId; } + public Client getClient() { return client; } + public List getSecurities() { return securities; } +} + diff --git a/src/main/java/com/wellsfargo/counselor/entity/Security.java b/src/main/java/com/wellsfargo/counselor/entity/Security.java new file mode 100644 index 00000000..e22d7424 --- /dev/null +++ b/src/main/java/com/wellsfargo/counselor/entity/Security.java @@ -0,0 +1,42 @@ +package com.wellsfargo.counselor.entity; + + +import jakarta.persistence.*; +import java.time.LocalDate; + +@Entity +public class Security { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long securityId; + + private String name; + private String category; + private LocalDate purchaseDate; + private double purchasePrice; + private int quantity; + + @ManyToOne + @JoinColumn(name = "portfolio_id", nullable = false) + private Portfolio portfolio; + + public Security() {} + + public Security(String name, String category, LocalDate purchaseDate, double purchasePrice, int quantity, Portfolio portfolio) { + this.name = name; + this.category = category; + this.purchaseDate = purchaseDate; + this.purchasePrice = purchasePrice; + this.quantity = quantity; + this.portfolio = portfolio; + } + + public Long getSecurityId() { return securityId; } + public String getName() { return name; } + public String getCategory() { return category; } + public LocalDate getPurchaseDate() { return purchaseDate; } + public double getPurchasePrice() { return purchasePrice; } + public int getQuantity() { return quantity; } + public Portfolio getPortfolio() { return portfolio; } +} +