@@ -6,6 +6,8 @@ import com.ffii.tsms.modules.user.entity.User; | |||||
import jakarta.persistence.*; | import jakarta.persistence.*; | ||||
import jakarta.validation.constraints.NotNull; | import jakarta.validation.constraints.NotNull; | ||||
import com.fasterxml.jackson.annotation.JsonInclude; | import com.fasterxml.jackson.annotation.JsonInclude; | ||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo; | |||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators; | |||||
import java.time.LocalDate; | import java.time.LocalDate; | ||||
import java.util.HashSet; | import java.util.HashSet; | ||||
@@ -49,6 +51,7 @@ public class Staff extends BaseEntity<Long> { | |||||
private Grade grade; | private Grade grade; | ||||
@ManyToOne | @ManyToOne | ||||
@JsonManagedReference | |||||
@JoinColumn(name = "teamId") | @JoinColumn(name = "teamId") | ||||
private Team team; | private Team team; | ||||
@@ -22,10 +22,14 @@ public class Team extends BaseEntity<Long> { | |||||
@NotNull | @NotNull | ||||
@OneToOne | @OneToOne | ||||
@JsonBackReference("staff-team") | |||||
@JsonBackReference | |||||
@JoinColumn(name = "teamLead", unique = true) | @JoinColumn(name = "teamLead", unique = true) | ||||
private Staff staff; | private Staff staff; | ||||
// @NotNull | |||||
@OneToOne(mappedBy = "team", cascade = CascadeType.ALL, orphanRemoval = true) | |||||
private Staff teamLead; | |||||
public String getDescription() { | public String getDescription() { | ||||
return description; | return description; | ||||
} | } | ||||
@@ -53,4 +57,6 @@ public class Team extends BaseEntity<Long> { | |||||
public Staff getStaff() { return staff;} | public Staff getStaff() { return staff;} | ||||
public void setStaff(Staff staff) { this.staff = staff; } | public void setStaff(Staff staff) { this.staff = staff; } | ||||
public Staff getTeamLead() { return teamLead;} | |||||
} | } |