/* * @Author: Student author@example.com * @Date: 2025-01-01 14:58:43 * @LastEditors: Student author@example.com * @LastEditTime: 2025-01-03 19:09:48 * @FilePath: \LibraryManageSystem\include\LibrarySystem.h * @Description: Coding with UTF-8 * * Copyright (c) 2025 by Student, All Rights Reserved. */ #ifndef LIBRARY_SYSTEM_H #define LIBRARY_SYSTEM_H #include "Book.h" #include "Member.h" #include #include "Constants.h" #include class LibrarySystem { public: BookManager bookManager; // 图书管理器 MemberManager memberManager; // 会员管理器 Member *currentUser; // 当前登录用户 void showAdminMenu(); // 显示管理员菜单 void showUserMenu(); // 显示用户菜单 static std::string getCategoryString(BookCategory category) // 获取图书类别字符串 { switch (category) { case BookCategory::LITERATURE: return "文学"; case BookCategory::SCIENCE: return "科学"; case BookCategory::TECHNOLOGY: return "技术"; case BookCategory::HISTORY: return "历史"; case BookCategory::PHILOSOPHY: return "哲学"; case BookCategory::ART: return "艺术"; case BookCategory::ECONOMICS: return "经济"; default: return "其他"; } } LibrarySystem() : bookManager(BOOKS_FILE), memberManager(MEMBERS_FILE), currentUser(nullptr) { std::cout << "LibrarySystem constructor called" << std::endl; std::cout.flush(); } ~LibrarySystem(); // 析构函数 // 系统登录登出 bool login(const std::string &id, const std::string &password); // 用户登录 void logout(); // 用户登出 // 管理员功能 bool addBook(const std::string &id, const std::string &title, const std::string &author, const std::string &library, int stock); // 添加新图书 bool removeBook(const std::string &bookId); // 删除图书 bool updateBookInfo(const std::string &bookId, const std::string &title, const std::string &author, const std::string &library); // 更新图书信息 bool removeMember(const std::string &memberId); // 删除会员 bool banUser(const std::string &userId); // 封禁用户 void checkOverdueBooks(); // 检查超期图书 bool updateUserInfo(const std::string &userId, const std::string &newName, const std::string &newPhone, const std::string &newPassword); // 更新用户信息 // 用户功能 bool borrowBook(const std::string &bookId); // 借阅图书 bool returnBook(const std::string &bookId); // 归还图书 void viewBorrowedBooks(); // 查看已借图书 void searchBooks(const std::string &keyword); // 搜索图书 // 通用功能 void displayAllBooks() const; // 显示所有图书 void displayBookDetails(const std::string &bookId) const; // 显示图书详情 bool isAdmin() const; // 判断是否为管理员 void recommendBooks() const; // 推荐图书 void rateBook(const std::string &bookId, int rating); // 图书评分 // 排行榜相关方法 LinkList getTopRatedBooks(int limit = 10) const; // 获取评分最高的图书 LinkList getMostBorrowedBooks(int limit = 10) const; // 获取借阅次数最多的图书 Book *findBook(const std::string &bookId) const { return bookManager.findBook(bookId); } // 查找图书 bool addMember(Member *member) { return memberManager.addMember(member); } // 添加新会员 }; #endif // LIBRARY_SYSTEM_H