Skip to content

Community Services API Documentation

Table of Contents

  1. Introduction
  2. GroupChat Service
  3. Message Service
  4. UserHasGroup Service
  5. UserResults Service

Introduction

This document provides detailed API service documentation for the community system. It describes the available service classes, their methods, and how they interact with the data repositories to manage group chats, messages, user-group associations, and user accounts.


GroupChat Service

Class: GroupChatService

Method Description
getAllGroupChatIds() Retrieves all group chat IDs.
getGroupChatById(Long) Retrieves a group chat by its ID.
createGroupChat(GroupChat) Creates and saves a new group chat.
deleteGroupChat(Long) Deletes a group chat by its ID.

Example Usage:

List<GroupChat> allGroupChats = groupChatService.getAllGroupChatIds();
GroupChat chat = groupChatService.getGroupChatById(1L).orElse(null);

Message Service

Class: MessageService

Method Description
getAllMessages() Retrieves all messages.
getMessagesByGroupId(Long, String) Retrieves messages by group ID, optionally filtered by date.
saveMessage(Message) Saves a new message to the repository.

Example Usage:

List<Message> messages = messageService.getAllMessages();
List<MessageResponse> filteredMessages = messageService.getMessagesByGroupId(1L, "2023-01-01T00:00:00");

UserHasGroup Service

Class: UserHasGroupService

Method Description
saveUserGroupMapping(String, String) Maps a user to a group by username and group name.
getGroupsForUser(String) Retrieves all groups associated with a given username.
getGroupChatsByUsername(String) Retrieves the group chats associated with a given username.

Example Usage:

UserHasGroup userGroup = userHasGroupService.saveUserGroupMapping("john_doe", "Project Group");
List<GroupChat> userGroups = userHasGroupService.getGroupsForUser("john_doe");

UserResults Service

Class: UserResultsService

Method Description
login(User) Authenticates a user and returns their ID if successful.
register(User) Registers a new user. Throws exceptions if validation fails.
getUserById(Long) Retrieves a user by their ID. Throws an exception if not found.
getUserByUsername(String) Retrieves a user by their username. Throws an exception if not found.
updateUser(User) Updates a user with the provided data.
deleteUser(User) Deletes a user by their ID.

Example Usage:

User user = userResultsService.getUserByUsername("jane_doe");
userResultsService.updateUser(user);