Преглед изворни кода

About to change the Chat class

JaseG256 пре 6 година
родитељ
комит
d87e3ecf3f

+ 13
- 12
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Config/AuditingConfig.java Прегледај датотеку

@@ -20,22 +20,23 @@ public class AuditingConfig {
20 20
     public AuditorAware<Long> auditorProvider() {
21 21
         return new SpringSecurityAuditAwareImpl();
22 22
     }
23
-}
24 23
 
25
-class SpringSecurityAuditAwareImpl implements AuditorAware<Long> {
26 24
 
27
-    @Override
28
-    public Optional<Long> getCurrentAuditor() {
29
-        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
25
+    class SpringSecurityAuditAwareImpl implements AuditorAware<Long> {
30 26
 
31
-        if (authentication == null ||
32
-                !authentication.isAuthenticated() ||
33
-                authentication instanceof AnonymousAuthenticationToken) {
34
-            return Optional.empty();
35
-        }
27
+        @Override
28
+        public Optional<Long> getCurrentAuditor() {
29
+            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
36 30
 
37
-        UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
31
+            if (authentication == null ||
32
+                    !authentication.isAuthenticated() ||
33
+                    authentication instanceof AnonymousAuthenticationToken) {
34
+                return Optional.empty();
35
+            }
38 36
 
39
-        return Optional.ofNullable(userPrincipal.getId());
37
+            UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
38
+
39
+            return Optional.ofNullable(userPrincipal.getId());
40
+        }
40 41
     }
41 42
 }

+ 52
- 52
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Model/Chat.java Прегледај датотеку

@@ -1,52 +1,52 @@
1
-//package ZipTeamOrange.model;
2
-//
3
-//import ZipTeamOrange.model.Message;
4
-//import ZipTeamOrange.model.User;
5
-//import javax.persistence.*;
6
-//import java.util.Set;
7
-//
8
-//@Entity
9
-//public class Chat {
10
-//
11
-//    @Id
12
-//    @GeneratedValue(strategy = GenerationType.IDENTITY)
13
-//    private Long id;
14
-//    private String name;
15
-//
16
-//    @OneToMany(mappedBy = "chat")
17
-//    private Set<Message> messages;
18
-//
19
-//    @ManyToMany(mappedBy = "chat")
20
-//    private Set<User> users;
21
-//
22
-//    public Chat(String name, Set<User> users) {
23
-//        this.name = name;
24
-//        this.users = users;
25
-//    }
26
-//
27
-//    public Chat(){}
28
-//
29
-//    public Long getId() {
30
-//        return id;
31
-//    }
32
-//
33
-//    public void setId(Long id) {
34
-//        this.id = id;
35
-//    }
36
-//
37
-//    public String getName() {
38
-//        return name;
39
-//    }
40
-//
41
-//    public void setName(String name) {
42
-//        this.name = name;
43
-//    }
44
-//
45
-//    public Set<User> getUsers() {
46
-//        return users;
47
-//    }
48
-//
49
-//    public void setUsers(Set<User> users) {
50
-//        this.users = users;
51
-//    }
52
-//}
1
+package ZipTeamOrange.model;
2
+
3
+import ZipTeamOrange.model.Message;
4
+import ZipTeamOrange.model.User;
5
+import javax.persistence.*;
6
+import java.util.Set;
7
+
8
+@Entity
9
+public class Chat {
10
+
11
+    @Id
12
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
13
+    private Long id;
14
+    private String name;
15
+
16
+    @OneToMany(mappedBy = "chat")
17
+    private Set<Message> messages;
18
+
19
+    @ManyToMany(mappedBy = "chat")
20
+    private Set<User> users;
21
+
22
+    public Chat(String name, Set<User> users) {
23
+        this.name = name;
24
+        this.users = users;
25
+    }
26
+
27
+    public Chat(){}
28
+
29
+    public Long getId() {
30
+        return id;
31
+    }
32
+
33
+    public void setId(Long id) {
34
+        this.id = id;
35
+    }
36
+
37
+    public String getName() {
38
+        return name;
39
+    }
40
+
41
+    public void setName(String name) {
42
+        this.name = name;
43
+    }
44
+
45
+    public Set<User> getUsers() {
46
+        return users;
47
+    }
48
+
49
+    public void setUsers(Set<User> users) {
50
+        this.users = users;
51
+    }
52
+}