Package idatt2106.group3.backend.Service
Class ChatService
- java.lang.Object
-
- idatt2106.group3.backend.Service.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 databaseboolean
deleteChat(long chatId)
Deletes Chat object from the database based on chatIdChat
getChat(long chatId)
Gets a Chat object if it exists in the databasejava.util.List<Chat>
getChats()
Gets a list of all chats stored in the databasejava.util.List<MessageDTO>
getMessages(long chatId)
Returns all messages written in the given ChatChat
updateChat(long chatId, Chat chat)
Finds a Chat object from database and changes fields that are not null in the input Chat object
-
-
-
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
-
-