89fc662181
<UserStory> 1960: Service Refactoring </UserStory> UserStory #1960 <Changes> 1. Replaced the Controller load/save workflow with initialize() and shutdown() methods. 2. Moved startup checks such as admin verification, low stock alerts, and payment reminders into Controller::initialize(). 3. Updated UserInterface to use the new Controller initialization and shutdown flow. 4. Updated DataStore::getUsers() and DataStore::getNotifications() to load data directly from shared memory. 5. Added logic to rebuild user notification mappings when user data is loaded from shared memory. 6. Implemented user and notification persistence through DataStore::saveUsers() and DataStore::saveNotifications(). 7. Updated UserManagementService to use TrackedRecord-based shared memory records. 8. Added DataStore locking and unlocking to user management operations for synchronization. 9. Updated createUser(), updateUserDetails(), removeUser(), and deleteNotification() to persist changes through shared memory. 10. Removed legacy loadUsers() and saveUsers() implementations from UserManagementService. 11. Added required header dependencies for shared memory support. </Changes> <Test> N/A </Test> <Review> Sreeja Reghukumar, please review </Review>
35 lines
1.2 KiB
C++
35 lines
1.2 KiB
C++
/*
|
|
File: UserManagementService.h
|
|
Description: Header file declaring the UserManagementService class, which manages
|
|
user creation, updates, retrieval, removal, notifications, and ensures
|
|
the existence of an admin account.
|
|
Author: Trenser
|
|
Date:19-May-2026
|
|
*/
|
|
|
|
#pragma once
|
|
#include <string>
|
|
#include "Map.h"
|
|
#include "Enums.h"
|
|
#include "DataStore.h"
|
|
|
|
class User;
|
|
class Notification;
|
|
|
|
class UserManagementService
|
|
{
|
|
private:
|
|
DataStore& m_dataStore;
|
|
public:
|
|
UserManagementService() : m_dataStore(DataStore::getInstance()) {}
|
|
void createUser(const std::string& username, const std::string& name, const std::string& password, const std::string& email, const std::string& phone, util::UserType type);
|
|
void updateUserDetails(const std::string& userID, const std::string& email, const std::string& phone);
|
|
util::Map<std::string, User*> getUsers();
|
|
util::Map<std::string, User*> getUsers(util::UserType type);
|
|
User* getUser (const std::string& userID);
|
|
void removeUser(const std::string& userID);
|
|
util::Vector<Notification*> getUserNotifications(const std::string& userID);
|
|
void deleteNotification(const std::string& notificationID, const std::string& userID);
|
|
void ensureAdminExists();
|
|
};
|