Class ChatService


  • @Service
    public class ChatService
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ChatService()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Chat createChat​(Chat chat)
      Stores a given Chat object in the database
      boolean deleteChat​(long chatId)
      Deletes Chat object from the database based on chatId
      Chat getChat​(long chatId)
      Gets a Chat object if it exists in the database
      java.util.List<Chat> getChats()
      Gets a list of all chats stored in the database
      java.util.List<MessageDTO> getMessages​(long chatId)
      Returns all messages written in the given Chat
      Chat updateChat​(long chatId, Chat chat)
      Finds a Chat object from database and changes fields that are not null in the input Chat object
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChatService

        public ChatService()
    • Method Detail

      • getChats

        public java.util.List<Chat> getChats()
        Gets a list of all chats stored in the database
        Returns:
        List of chats
      • getChat

        public Chat getChat​(long chatId)
        Gets a Chat object if it exists in the database
        Parameters:
        chatId -
        Returns:
        Chat
      • createChat

        public Chat createChat​(Chat chat)
        Stores a given Chat object in the database
        Parameters:
        chat -
        Returns:
        Chat
      • updateChat

        public Chat updateChat​(long chatId,
                               Chat chat)
        Finds a Chat object from database and changes fields that are not null in the input Chat object
        Parameters:
        chatId -
        chat -
        Returns:
        updated Chat object
      • getMessages

        public java.util.List<MessageDTO> getMessages​(long chatId)
        Returns all messages written in the given Chat
        Parameters:
        chatId -
        Returns:
        List of all Message objects, empty list in case chat not exists
      • deleteChat

        public boolean deleteChat​(long chatId)
        Deletes Chat object from the database based on chatId
        Parameters:
        chatId -
        Returns:
        true if was deleted, false if it still exists