Просмотр исходного кода

Working out the Chat and Message entities

JaseG256 6 лет назад
Родитель
Сommit
ae7398b270
18 измененных файлов: 358 добавлений и 204 удалений
  1. 2
    2
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Config/AuditingConfig.java
  2. 41
    30
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Controller/ChatController.java
  3. 38
    33
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Controller/MessageController.java
  4. 54
    10
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Model/Chat.java
  5. 31
    12
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Model/Message.java
  6. 27
    27
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Repository/ChatRepository.java
  7. 34
    34
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Repository/MessageRepository.java
  8. 4
    5
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/controller/AuthController.java
  9. 0
    46
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/ChatRequest.java
  10. 50
    0
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/UserProfile.java
  11. 49
    0
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/ChatRequest.java
  12. 1
    1
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/LoginRequest.java
  13. 14
    1
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/MessageRequest.java
  14. 1
    1
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/SignUpRequest.java
  15. 1
    1
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/ApiResponse.java
  16. 4
    0
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/ChatResonse.java
  17. 6
    0
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/ChatResponse.java
  18. 1
    1
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/JwtAuthenticationResponse.java

+ 2
- 2
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Config/AuditingConfig.java Просмотреть файл

@@ -20,7 +20,7 @@ public class AuditingConfig {
20 20
     public AuditorAware<Long> auditorProvider() {
21 21
         return new SpringSecurityAuditAwareImpl();
22 22
     }
23
-
23
+}
24 24
 
25 25
     class SpringSecurityAuditAwareImpl implements AuditorAware<Long> {
26 26
 
@@ -39,4 +39,4 @@ public class AuditingConfig {
39 39
             return Optional.ofNullable(userPrincipal.getId());
40 40
         }
41 41
     }
42
-}
42
+

+ 41
- 30
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Controller/ChatController.java Просмотреть файл

@@ -1,30 +1,41 @@
1
-//package ZipTeamOrange.controller;
2
-//
3
-//import ZipTeamOrange.model.Chat;
4
-//import ZipTeamOrange.repository.ChatRepository;
5
-//import org.springframework.beans.factory.annotation.Autowired;
6
-//import org.springframework.stereotype.controller;
7
-//import org.springframework.web.bind.annotation.*;
8
-//
9
-//@controller
10
-//@RequestMapping(path = "/chat")
11
-//@CrossOrigin(origins = {"http://localhost:8103"})
12
-//public class ChatController {
13
-//
14
-//    @Autowired
15
-//    private ChatRepository chatRepository;
16
-//
17
-//    @PostMapping(path="/add")
18
-//    public @ResponseBody
19
-//    Chat addNewChat(@RequestBody Chat chat){
20
-//        chatRepository.save(chat);
21
-//        return  chat;
22
-//    }
23
-//
24
-//    @GetMapping(path="/all")
25
-//    public @ResponseBody Iterable<Chat> getAllChat() {
26
-//        //this returns a JSON or XML with chats
27
-//        return chatRepository.findAll();
28
-//
29
-//    }
30
-//}
1
+package ZipTeamOrange.controller;
2
+
3
+import ZipTeamOrange.model.Chat;
4
+import ZipTeamOrange.repository.ChatRepository;
5
+import ZipTeamOrange.repository.MessageRepository;
6
+import ZipTeamOrange.repository.UserRepository;
7
+import org.slf4j.Logger;
8
+import org.slf4j.LoggerFactory;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.web.bind.annotation.*;
11
+
12
+@RestController
13
+@RequestMapping("/api/chat")
14
+@CrossOrigin(origins = {"http://localhost:8103"})
15
+public class ChatController {
16
+
17
+    @Autowired
18
+    private ChatRepository chatRepository;
19
+
20
+    @Autowired
21
+    private MessageRepository messageRepository;
22
+
23
+    @Autowired
24
+    private UserRepository userRepository;
25
+
26
+    private static final Logger logger = LoggerFactory.getLogger(ChatController.class);
27
+
28
+    @PostMapping(path="/add")
29
+    public @ResponseBody
30
+    Chat addNewChat(@RequestBody Chat chat){
31
+        chatRepository.save(chat);
32
+        return  chat;
33
+    }
34
+
35
+    @GetMapping(path="/all")
36
+    public @ResponseBody Iterable<Chat> getAllChat() {
37
+        //this returns a JSON or XML with chats
38
+        return chatRepository.findAll();
39
+
40
+    }
41
+}

+ 38
- 33
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Controller/MessageController.java Просмотреть файл

@@ -1,33 +1,38 @@
1
-//package ZipTeamOrange.controller;
2
-//
3
-//import ZipTeamOrange.model.Message;
4
-//import ZipTeamOrange.repository.MessageRepository;
5
-//import com.fasterxml.jackson.core.JsonProcessingException;
6
-//import com.fasterxml.jackson.databind.ObjectMapper;
7
-//import org.springframework.beans.factory.annotation.Autowired;
8
-//import org.springframework.web.bind.annotation.*;
9
-//
10
-//@RestController
11
-//@RequestMapping(path = "/message")
12
-//@CrossOrigin("http://localhost:8100")
13
-//public class MessageController {
14
-//    ObjectMapper ob = new ObjectMapper();
15
-//
16
-//    @Autowired
17
-//    private MessageRepository messageRepository;
18
-//    @PostMapping(path = "/add")
19
-//    public String postMessage(@RequestBody Message message) throws JsonProcessingException {
20
-//
21
-//        messageRepository.save(message);
22
-//
23
-//        return ob.writeValueAsString(message);
24
-//
25
-//    }
26
-//
27
-//    @GetMapping(path = "/all")
28
-//    public @ResponseBody Iterable<Message> getAllMessages(){
29
-//        return messageRepository.findAll();
30
-//    }
31
-//
32
-//
33
-//}
1
+package ZipTeamOrange.controller;
2
+
3
+import ZipTeamOrange.model.Message;
4
+import ZipTeamOrange.repository.MessageRepository;
5
+import com.fasterxml.jackson.core.JsonProcessingException;
6
+import com.fasterxml.jackson.databind.ObjectMapper;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.security.access.prepost.PreAuthorize;
9
+import org.springframework.web.bind.annotation.*;
10
+
11
+import javax.annotation.security.RolesAllowed;
12
+
13
+@RestController
14
+@RequestMapping(path = "/message")
15
+@CrossOrigin("http://localhost:8100")
16
+public class MessageController {
17
+    ObjectMapper ob = new ObjectMapper();
18
+
19
+    @Autowired
20
+    private MessageRepository messageRepository;
21
+
22
+    @PostMapping(path = "/add")
23
+    @RolesAllowed("ROLE_USER")
24
+    public String postMessage(@RequestBody Message message) throws JsonProcessingException {
25
+
26
+        messageRepository.save(message);
27
+
28
+        return ob.writeValueAsString(message);
29
+
30
+    }
31
+
32
+    @GetMapping(path = "/all")
33
+    public @ResponseBody Iterable<Message> getAllMessages(){
34
+        return messageRepository.findAll();
35
+    }
36
+
37
+
38
+}

+ 54
- 10
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Model/Chat.java Просмотреть файл

@@ -3,6 +3,11 @@ package ZipTeamOrange.model;
3 3
 import ZipTeamOrange.model.Audit.UserDateAudit;
4 4
 import ZipTeamOrange.model.Message;
5 5
 import ZipTeamOrange.model.User;
6
+import org.springframework.data.annotation.CreatedBy;
7
+import org.springframework.data.annotation.CreatedDate;
8
+import org.springframework.data.annotation.LastModifiedBy;
9
+import org.springframework.data.annotation.LastModifiedDate;
10
+
6 11
 import javax.persistence.*;
7 12
 import javax.validation.constraints.NotBlank;
8 13
 import java.util.Set;
@@ -24,12 +29,33 @@ public class Chat extends UserDateAudit {
24 29
     orphanRemoval = true)
25 30
     private Set<Message> messages;
26 31
 
27
-//    @ManyToMany(mappedBy = "chat")
28
-//    private Set<User> users;
32
+    @ManyToMany(fetch = FetchType.EAGER,
33
+    cascade = CascadeType.ALL)
34
+    @JoinTable(name = "chat_users",
35
+            joinColumns = @JoinColumn(name = "chat_id"),
36
+            inverseJoinColumns = @JoinColumn(name = "user_id"))
37
+    private Set<User> users;
38
+
39
+    @Column(name = "created_date", nullable = false, updatable = false)
40
+    @CreatedDate
41
+    private long createdDate;
42
+
43
+    @Column(name = "modified_date")
44
+    @LastModifiedDate
45
+    private long modifiedDate;
46
+
47
+    @Column(name = "created_by")
48
+    @CreatedBy
49
+    private String createdBy;
29 50
 
30
-    public Chat(String topic, Set<Message> messages) {
51
+    @Column(name = "modified_by")
52
+    @LastModifiedBy
53
+    private String modifiedBy;
54
+
55
+    public Chat(String topic, Set<Message> messages, Set<User> user) {
31 56
         this.topic = topic;
32 57
         this.messages = messages;
58
+        this.users = user;
33 59
     }
34 60
 
35 61
     public Chat() { }
@@ -58,11 +84,29 @@ public class Chat extends UserDateAudit {
58 84
         this.messages = messages;
59 85
     }
60 86
 
61
-    //    public Set<User> getUsers() {
62
-//        return users;
63
-//    }
64
-//
65
-//    public void setUsers(Set<User> users) {
66
-//        this.users = users;
67
-//    }
87
+        public Set<User> getUsers() {
88
+        return users;
89
+    }
90
+
91
+    public void setUsers(Set<User> users) {
92
+        this.users = users;
93
+    }
94
+
95
+    public void addMessage(Message message) {
96
+        messages.add(message);
97
+        message.setChat(this);
98
+    }
99
+
100
+    public void removeMessage(Message message) {
101
+        messages.remove(message);
102
+        message.setChat(null);
103
+    }
104
+
105
+    public void addUser(User user) {
106
+        users.add(user);
107
+    }
108
+
109
+    public void removeUser(User user) {
110
+        users.remove(user);
111
+    }
68 112
 }

+ 31
- 12
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Model/Message.java Просмотреть файл

@@ -2,6 +2,10 @@ package ZipTeamOrange.model;
2 2
 
3 3
 import ZipTeamOrange.model.Audit.DateAudit;
4 4
 import ZipTeamOrange.model.Audit.UserDateAudit;
5
+import org.springframework.data.annotation.CreatedBy;
6
+import org.springframework.data.annotation.CreatedDate;
7
+import org.springframework.data.annotation.LastModifiedBy;
8
+import org.springframework.data.annotation.LastModifiedDate;
5 9
 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
6 10
 
7 11
 import javax.persistence.*;
@@ -15,19 +19,34 @@ public class Message extends UserDateAudit {
15 19
 
16 20
     String text;
17 21
 
18
-//    @ManyToOne
19
-//    @JoinColumn(name="user_id")
20
-//    User user;
21
-
22 22
     @ManyToOne(fetch = FetchType.LAZY, optional = false)
23 23
     @JoinColumn(name = "chat_id", nullable = false)
24 24
     private Chat chat;
25 25
 
26
+    @ManyToOne(fetch = FetchType.LAZY, optional = false)
27
+    @JoinColumn(name = "user_id", nullable = false)
28
+    private User user;
29
+
30
+    @Column(name = "created_date", nullable = false, updatable = false)
31
+    @CreatedDate
32
+    private long createdDate;
33
+
34
+    @Column(name = "modified_date")
35
+    @LastModifiedDate
36
+    private long modifiedDate;
37
+
38
+    @Column(name = "created_by")
39
+    @CreatedBy
40
+    private String createdBy;
41
+
42
+    @Column(name = "modified_by")
43
+    @LastModifiedBy
44
+    private String modifiedBy;
45
+
26 46
     public Message() { }
27 47
 
28 48
     public Message(String text) {
29 49
         this.text = text;
30
-        //this.user = user;
31 50
     }
32 51
 
33 52
     public long getId() {
@@ -46,11 +65,11 @@ public class Message extends UserDateAudit {
46 65
         this.text = text;
47 66
     }
48 67
 
49
-//    public User getUser() {
50
-//        return user;
51
-//    }
52
-//
53
-//    public void setUser(User user) {
54
-//        this.user = user;
55
-//    }
68
+    public Chat getChat() {
69
+        return chat;
70
+    }
71
+
72
+    public void setChat(Chat chat) {
73
+        this.chat = chat;
74
+    }
56 75
 }

+ 27
- 27
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Repository/ChatRepository.java Просмотреть файл

@@ -1,27 +1,27 @@
1
-//package ZipTeamOrange.repository;
2
-//
3
-//import ZipTeamOrange.model.Chat;
4
-//import org.springframework.data.domain.Page;
5
-//import org.springframework.data.domain.Pageable;
6
-//import org.springframework.data.domain.Sort;
7
-//import org.springframework.data.jpa.repository.JpaRepository;
8
-//import org.springframework.stereotype.Repository;
9
-//
10
-//import java.util.List;
11
-//import java.util.Optional;
12
-//
13
-//@Repository
14
-//public interface ChatRepository extends JpaRepository<Chat, Long> {
15
-//
16
-//    Optional<Chat> findById(Long chatId);
17
-//
18
-//    Page<Chat> findByCreatedBy(Long userId, Pageable pageable);
19
-//
20
-//    long countByCreatedBy(Long userId);
21
-//
22
-//    List<Chat> findByIdIn(List<Long> chatIds);
23
-//
24
-//    List<Chat> findByIdIn(List<Long> chatIds, Sort sort);
25
-//
26
-//}
27
-//
1
+package ZipTeamOrange.repository;
2
+
3
+import ZipTeamOrange.model.Chat;
4
+import org.springframework.data.domain.Page;
5
+import org.springframework.data.domain.Pageable;
6
+import org.springframework.data.domain.Sort;
7
+import org.springframework.data.jpa.repository.JpaRepository;
8
+import org.springframework.stereotype.Repository;
9
+
10
+import java.util.List;
11
+import java.util.Optional;
12
+
13
+@Repository
14
+public interface ChatRepository extends JpaRepository<Chat, Long> {
15
+
16
+    Optional<Chat> findById(Long chatId);
17
+
18
+    Page<Chat> findByCreatedBy(Long userId, Pageable pageable);
19
+
20
+    long countByCreatedBy(Long userId);
21
+
22
+    List<Chat> findByIdIn(List<Long> chatIds);
23
+
24
+    List<Chat> findByIdIn(List<Long> chatIds, Sort sort);
25
+
26
+}
27
+

+ 34
- 34
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Repository/MessageRepository.java Просмотреть файл

@@ -1,34 +1,34 @@
1
-//package ZipTeamOrange.repository;
2
-//
3
-//import ZipTeamOrange.model.Chat;
4
-//import ZipTeamOrange.model.Message;
5
-//import org.springframework.data.domain.Page;
6
-//import org.springframework.data.domain.Pageable;
7
-//import org.springframework.data.domain.Sort;
8
-//import org.springframework.data.jpa.repository.JpaRepository;
9
-//import org.springframework.data.jpa.repository.Query;
10
-//import org.springframework.data.repository.query.Param;
11
-//import org.springframework.data.rest.core.annotation.RepositoryRestResource;
12
-//import org.springframework.stereotype.Repository;
13
-//
14
-//import java.util.List;
15
-//import java.util.Optional;
16
-//
17
-//@Repository
18
-//@RepositoryRestResource(collectionResourceRel = "message", path = "message")
19
-//public interface MessageRepository extends JpaRepository<Message, Long> {
20
-//
21
-//    Optional<Message> findById(Long messageId);
22
-//
23
-//    Page<Message> findByCreatedBy(Long userId, Pageable pageable);
24
-//
25
-//    long countByCreatedBy(Long userId);
26
-//
27
-////    @Query("SELECT COUNT(m.id) from Message v where v.user.id = :userId")
28
-////    long countByUserId(@Param("userId") Long userId);
29
-//
30
-//    List<Message> findByIdIn(List<Long> messageIds);
31
-//
32
-//    List<Message> findByIdIn(List<Long> messageIds, Sort sort);
33
-//
34
-//}
1
+package ZipTeamOrange.repository;
2
+
3
+import ZipTeamOrange.model.Chat;
4
+import ZipTeamOrange.model.Message;
5
+import org.springframework.data.domain.Page;
6
+import org.springframework.data.domain.Pageable;
7
+import org.springframework.data.domain.Sort;
8
+import org.springframework.data.jpa.repository.JpaRepository;
9
+import org.springframework.data.jpa.repository.Query;
10
+import org.springframework.data.repository.query.Param;
11
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
12
+import org.springframework.stereotype.Repository;
13
+
14
+import java.util.List;
15
+import java.util.Optional;
16
+
17
+@Repository
18
+@RepositoryRestResource(collectionResourceRel = "message", path = "message")
19
+public interface MessageRepository extends JpaRepository<Message, Long> {
20
+
21
+    Optional<Message> findById(Long messageId);
22
+
23
+    Page<Message> findByCreatedBy(Long userId, Pageable pageable);
24
+
25
+    long countByCreatedBy(Long userId);
26
+
27
+//    @Query("SELECT COUNT(m.id) from Message v where v.user.id = :userId")
28
+//    long countByUserId(@Param("userId") Long userId);
29
+
30
+    List<Message> findByIdIn(List<Long> messageIds);
31
+
32
+    List<Message> findByIdIn(List<Long> messageIds, Sort sort);
33
+
34
+}

+ 4
- 5
ZipTeamOrange-server/src/main/java/ZipTeamOrange/controller/AuthController.java Просмотреть файл

@@ -1,13 +1,12 @@
1 1
 package ZipTeamOrange.controller;
2 2
 
3
-import ZipTeamOrange.exception.AppException;
4 3
 import ZipTeamOrange.model.Role;
5 4
 import ZipTeamOrange.model.RoleName;
6 5
 import ZipTeamOrange.model.User;
7
-import ZipTeamOrange.payload.ApiResponse;
8
-import ZipTeamOrange.payload.JwtAuthenticationResponse;
9
-import ZipTeamOrange.payload.LoginRequest;
10
-import ZipTeamOrange.payload.SignUpRequest;
6
+import ZipTeamOrange.payload.response.ApiResponse;
7
+import ZipTeamOrange.payload.response.JwtAuthenticationResponse;
8
+import ZipTeamOrange.payload.request.LoginRequest;
9
+import ZipTeamOrange.payload.request.SignUpRequest;
11 10
 import ZipTeamOrange.repository.RoleRepository;
12 11
 import ZipTeamOrange.repository.UserRepository;
13 12
 import ZipTeamOrange.security.JwtTokenProvider;

+ 0
- 46
ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/ChatRequest.java Просмотреть файл

@@ -1,46 +0,0 @@
1
-package ZipTeamOrange.payload;
2
-
3
-import javax.validation.Valid;
4
-import javax.validation.constraints.NotBlank;
5
-import javax.validation.constraints.NotNull;
6
-import javax.validation.constraints.Size;
7
-import java.util.List;
8
-
9
-public class ChatRequest {
10
-    @NotBlank
11
-    @Size(max = 140)
12
-    private String topic;
13
-
14
-    @NotNull
15
-    @Size(min = 2, max = 6)
16
-    @Valid
17
-    private List<MessageRequest> choices;
18
-
19
-//    @NotNull
20
-//    @Valid
21
-//    private PollLength pollLength;
22
-
23
-    public String getTopic() {
24
-        return topic;
25
-    }
26
-
27
-    public void setTopic(String topic) {
28
-        this.topic = topic;
29
-    }
30
-
31
-    public List<MessageRequest> getChoices() {
32
-        return choices;
33
-    }
34
-
35
-    public void setChoices(List<MessageRequest> choices) {
36
-        this.choices = choices;
37
-    }
38
-
39
-//    public PollLength getPollLength() {
40
-//        return pollLength;
41
-//    }
42
-//
43
-//    public void setPollLength(PollLength pollLength) {
44
-//        this.pollLength = pollLength;
45
-//    }
46
-}

+ 50
- 0
ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/UserProfile.java Просмотреть файл

@@ -0,0 +1,50 @@
1
+package ZipTeamOrange.payload;
2
+
3
+import java.time.Instant;
4
+
5
+public class UserProfile {
6
+
7
+    private Long id;
8
+    private String username;
9
+    private Instant joinedAt;
10
+    private long messageCount;
11
+
12
+    public UserProfile(Long id, String username, Instant joinedAt, long messageCount) {
13
+        this.id = id;
14
+        this.username = username;
15
+        this.joinedAt = joinedAt;
16
+        this.messageCount = messageCount;
17
+    }
18
+
19
+    public Long getId() {
20
+        return id;
21
+    }
22
+
23
+    public void setId(Long id) {
24
+        this.id = id;
25
+    }
26
+
27
+    public String getUsername() {
28
+        return username;
29
+    }
30
+
31
+    public void setUsername(String username) {
32
+        this.username = username;
33
+    }
34
+
35
+    public Instant getJoinedAt() {
36
+        return joinedAt;
37
+    }
38
+
39
+    public void setJoinedAt(Instant joinedAt) {
40
+        this.joinedAt = joinedAt;
41
+    }
42
+
43
+    public long getMessageCount() {
44
+        return messageCount;
45
+    }
46
+
47
+    public void setMessageCount(long messageCount) {
48
+        this.messageCount = messageCount;
49
+    }
50
+}

+ 49
- 0
ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/ChatRequest.java Просмотреть файл

@@ -0,0 +1,49 @@
1
+package ZipTeamOrange.payload.request;
2
+
3
+import ZipTeamOrange.model.User;
4
+
5
+import javax.validation.Valid;
6
+import javax.validation.constraints.NotBlank;
7
+import javax.validation.constraints.NotNull;
8
+import javax.validation.constraints.Size;
9
+import java.util.List;
10
+import java.util.Set;
11
+
12
+public class ChatRequest {
13
+    @NotBlank
14
+    @Size(max = 140)
15
+    private String topic;
16
+
17
+    @NotNull
18
+    @Valid
19
+    private List<MessageRequest> messages;
20
+
21
+    @NotNull
22
+    @Valid
23
+    private Set<User> users;
24
+
25
+    public String getTopic() {
26
+        return topic;
27
+    }
28
+
29
+    public void setTopic(String topic) {
30
+        this.topic = topic;
31
+    }
32
+
33
+    public List<MessageRequest> getMessages() {
34
+        return messages;
35
+    }
36
+
37
+    public void setMessages(List<MessageRequest> messages) {
38
+        this.messages = messages;
39
+    }
40
+
41
+    public Set<User> getUsers() {
42
+        return users;
43
+    }
44
+
45
+    public void setUsers(Set<User> users) {
46
+        this.users = users;
47
+    }
48
+
49
+}

ZipTeamOrange-server/src/main/java/ZipTeamOrange/Payload/LoginRequest.java → ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/LoginRequest.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package ZipTeamOrange.payload;
1
+package ZipTeamOrange.payload.request;
2 2
 
3 3
 import javax.validation.constraints.NotBlank;
4 4
 

ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/MessageRequest.java → ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/MessageRequest.java Просмотреть файл

@@ -1,4 +1,6 @@
1
-package ZipTeamOrange.payload;
1
+package ZipTeamOrange.payload.request;
2
+
3
+import ZipTeamOrange.model.User;
2 4
 
3 5
 import javax.validation.constraints.NotBlank;
4 6
 import javax.validation.constraints.Size;
@@ -8,6 +10,17 @@ public class MessageRequest {
8 10
     @Size(max = 40)
9 11
     private String text;
10 12
 
13
+    @NotBlank
14
+    private User user;
15
+
16
+    public User getUser() {
17
+        return user;
18
+    }
19
+
20
+    public void setUser(User user) {
21
+        this.user = user;
22
+    }
23
+
11 24
     public String getText() {
12 25
         return text;
13 26
     }

ZipTeamOrange-server/src/main/java/ZipTeamOrange/Payload/SignUpRequest.java → ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/request/SignUpRequest.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package ZipTeamOrange.payload;
1
+package ZipTeamOrange.payload.request;
2 2
 
3 3
 import javax.validation.constraints.Email;
4 4
 import javax.validation.constraints.NotBlank;

ZipTeamOrange-server/src/main/java/ZipTeamOrange/Payload/ApiResponse.java → ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/ApiResponse.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package ZipTeamOrange.payload;
1
+package ZipTeamOrange.payload.response;
2 2
 
3 3
 public class ApiResponse {
4 4
     private Boolean success;

+ 4
- 0
ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/ChatResonse.java Просмотреть файл

@@ -0,0 +1,4 @@
1
+package ZipTeamOrange.payload.response;
2
+
3
+public class ChatResonse {
4
+}

+ 6
- 0
ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/ChatResponse.java Просмотреть файл

@@ -0,0 +1,6 @@
1
+package ZipTeamOrange.payload.response;
2
+
3
+public class ChatResponse {
4
+
5
+
6
+}

ZipTeamOrange-server/src/main/java/ZipTeamOrange/Payload/JwtAuthenticationResponse.java → ZipTeamOrange-server/src/main/java/ZipTeamOrange/payload/response/JwtAuthenticationResponse.java Просмотреть файл

@@ -1,4 +1,4 @@
1
-package ZipTeamOrange.payload;
1
+package ZipTeamOrange.payload.response;
2 2
 
3 3
 public class JwtAuthenticationResponse {
4 4
     private String accessToken;