|
@@ -1,30 +1,38 @@
|
1
|
1
|
package ZipTeamOrange.model;
|
2
|
2
|
|
|
3
|
+import ZipTeamOrange.model.Audit.UserDateAudit;
|
3
|
4
|
import ZipTeamOrange.model.Message;
|
4
|
5
|
import ZipTeamOrange.model.User;
|
5
|
6
|
import javax.persistence.*;
|
|
7
|
+import javax.validation.constraints.NotBlank;
|
6
|
8
|
import java.util.Set;
|
7
|
9
|
|
8
|
10
|
@Entity
|
9
|
|
-public class Chat {
|
|
11
|
+@Table(name = "chats")
|
|
12
|
+public class Chat extends UserDateAudit {
|
10
|
13
|
|
11
|
14
|
@Id
|
12
|
15
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
13
|
16
|
private Long id;
|
14
|
|
- private String name;
|
15
|
17
|
|
16
|
|
- @OneToMany(mappedBy = "chat")
|
|
18
|
+ @NotBlank
|
|
19
|
+ private String topic;
|
|
20
|
+
|
|
21
|
+ @OneToMany(mappedBy = "chat",
|
|
22
|
+ cascade = CascadeType.ALL,
|
|
23
|
+ fetch = FetchType.EAGER,
|
|
24
|
+ orphanRemoval = true)
|
17
|
25
|
private Set<Message> messages;
|
18
|
26
|
|
19
|
|
- @ManyToMany(mappedBy = "chat")
|
20
|
|
- private Set<User> users;
|
|
27
|
+// @ManyToMany(mappedBy = "chat")
|
|
28
|
+// private Set<User> users;
|
21
|
29
|
|
22
|
|
- public Chat(String name, Set<User> users) {
|
23
|
|
- this.name = name;
|
24
|
|
- this.users = users;
|
|
30
|
+ public Chat(String topic, Set<Message> messages) {
|
|
31
|
+ this.topic = topic;
|
|
32
|
+ this.messages = messages;
|
25
|
33
|
}
|
26
|
34
|
|
27
|
|
- public Chat(){}
|
|
35
|
+ public Chat() { }
|
28
|
36
|
|
29
|
37
|
public Long getId() {
|
30
|
38
|
return id;
|
|
@@ -34,19 +42,27 @@ public class Chat {
|
34
|
42
|
this.id = id;
|
35
|
43
|
}
|
36
|
44
|
|
37
|
|
- public String getName() {
|
38
|
|
- return name;
|
|
45
|
+ public String getTopic() {
|
|
46
|
+ return topic;
|
39
|
47
|
}
|
40
|
48
|
|
41
|
|
- public void setName(String name) {
|
42
|
|
- this.name = name;
|
|
49
|
+ public void setTopic(String topic) {
|
|
50
|
+ this.topic = topic;
|
43
|
51
|
}
|
44
|
52
|
|
45
|
|
- public Set<User> getUsers() {
|
46
|
|
- return users;
|
|
53
|
+ public Set<Message> getMessages() {
|
|
54
|
+ return messages;
|
47
|
55
|
}
|
48
|
56
|
|
49
|
|
- public void setUsers(Set<User> users) {
|
50
|
|
- this.users = users;
|
|
57
|
+ public void setMessages(Set<Message> messages) {
|
|
58
|
+ this.messages = messages;
|
51
|
59
|
}
|
|
60
|
+
|
|
61
|
+ // public Set<User> getUsers() {
|
|
62
|
+// return users;
|
|
63
|
+// }
|
|
64
|
+//
|
|
65
|
+// public void setUsers(Set<User> users) {
|
|
66
|
+// this.users = users;
|
|
67
|
+// }
|
52
|
68
|
}
|