Advertisement
ImHungryHi

user entity

Sep 17th, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. package cc.serviceops.account;
  2. import cc.serviceops.account.helpers.UserRole;
  3. import cc.serviceops.organisation.Organisation;
  4. import cc.serviceops.organisation.Team;
  5. import cc.serviceops.ticket.Ticket;
  6. import cc.serviceops.ticket.TicketAction;
  7. import lombok.Getter;
  8. import lombok.Setter;
  9. import org.springframework.lang.Nullable;
  10. import javax.persistence.*;
  11. import java.util.Objects;
  12. import java.util.List;
  13.  
  14. @Entity @Table(name = "account")
  15. @Getter @Setter
  16. public class User {
  17. @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
  18. private int id;
  19.  
  20. private String password;
  21. private String email;
  22.  
  23. @Column(name ="first_name", nullable = true)
  24. private String firstName;
  25.  
  26. @Column(name ="last_name", nullable = true)
  27. private String lastName;
  28.  
  29. @Nullable
  30. private String telephone;
  31.  
  32. private boolean enabled = true;
  33.  
  34. @Enumerated(EnumType.STRING)
  35. private UserRole role = UserRole.GUEST;
  36.  
  37. @ManyToOne(optional = true) @JoinColumn(name = "team_id")
  38. private Team team;
  39.  
  40. @ManyToOne(optional = true) @JoinColumn(name = "organisation_id")
  41. private Organisation organisation;
  42.  
  43. @OneToMany(mappedBy = "user")
  44. private List<Ticket> ticketList;
  45.  
  46. @OneToMany(mappedBy = "creator")
  47. private List<Ticket> createdTicketList;
  48.  
  49. @OneToMany(mappedBy = "user")
  50. private List<TicketAction> actionList;
  51.  
  52. @Override
  53. public boolean equals(Object o) {
  54. if (this == o) return true;
  55. if (o == null || getClass() != o.getClass()) return false;
  56. User user = (User) o;
  57. return id == user.id;
  58. }
  59.  
  60. @Override
  61. public int hashCode() {
  62. return Objects.hash(id);
  63. }
  64. }
  65.  
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement