blob: 053d7906ee0aa571e3cc4fb412074dae3fdad32a [file] [log] [blame]
Matthias Andreas Benkard2f0b3702020-01-12 15:46:34 +01001package eu.mulk.entity;
2
3import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
4import java.util.Objects;
5import javax.persistence.Basic;
6import javax.persistence.Column;
7import javax.persistence.Entity;
8import javax.persistence.Id;
9import javax.persistence.IdClass;
10import javax.persistence.JoinColumn;
11import javax.persistence.ManyToOne;
12import javax.persistence.Table;
13
14@Entity
15@Table(name = "user_permissions", schema = "public", catalog = "mulkcms")
16@IdClass(UserPermissionPK.class)
17public class UserPermission extends PanacheEntityBase {
18
19 private int userId;
20 private String permission;
21 private Boolean status;
22 private User user;
23
24 @Id
25 @Column(name = "user", nullable = false)
26 public int getUserId() {
27 return userId;
28 }
29
30 public void setUserId(int userId) {
31 this.userId = userId;
32 }
33
34 @Id
35 @Column(name = "permission", nullable = false, length = -1)
36 public String getPermission() {
37 return permission;
38 }
39
40 public void setPermission(String permission) {
41 this.permission = permission;
42 }
43
44 @Basic
45 @Column(name = "status", nullable = true)
46 public Boolean getStatus() {
47 return status;
48 }
49
50 public void setStatus(Boolean status) {
51 this.status = status;
52 }
53
54 @Override
55 public boolean equals(Object o) {
56 if (this == o) {
57 return true;
58 }
59 if (o == null || getClass() != o.getClass()) {
60 return false;
61 }
62 UserPermission that = (UserPermission) o;
63 return userId == that.userId &&
64 Objects.equals(permission, that.permission) &&
65 Objects.equals(status, that.status);
66 }
67
68 @Override
69 public int hashCode() {
70 return Objects.hash(userId, permission, status);
71 }
72
73 @ManyToOne
74 @JoinColumn(name = "user", referencedColumnName = "id", nullable = false, insertable = false, updatable = false)
75 public User getUser() {
76 return user;
77 }
78
79 public void setUser(User user) {
80 this.user = user;
81 }
82}