From aedb3b85fed48cb2cf0abb5fafa8e7591644c9f4 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 02 十二月 2024 08:53:06 +0800
Subject: [PATCH] Merge branch 'liuyang' into clh
---
SourceCode/Bond/BondEq/DBManager/SystemLogManager.h | 76 ++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/BondEq/DBManager/SystemLogManager.h b/SourceCode/Bond/BondEq/DBManager/SystemLogManager.h
new file mode 100644
index 0000000..764450c
--- /dev/null
+++ b/SourceCode/Bond/BondEq/DBManager/SystemLogManager.h
@@ -0,0 +1,76 @@
+#ifndef SYSTEM_LOG_MANAGER_H
+#define SYSTEM_LOG_MANAGER_H
+
+#include <string>
+#include <vector>
+#include <mutex>
+#include "Database.h"
+
+// 系统日志管理类
+class SystemLogManager {
+public:
+ // 日志类型定义
+ enum class LogType {
+ Info,
+ Error,
+ Operation,
+ Unknown
+ };
+
+ // 获取单例实例
+ static SystemLogManager& getInstance();
+
+ // 设置数据库连接
+ void setDatabase(BL::Database* db);
+
+ // 初始化日志表
+ bool initializeLogTable();
+
+ // 添加日志
+ bool log(LogType logType, const std::string& event);
+ bool log(LogType logType, const std::string& event, const std::string& username);
+
+ // 获取日志内容
+ std::vector<std::vector<std::string>> getLogs(int startPosition = -1, int count = -1);
+
+ // 获取筛选后的日志数据
+ std::vector<std::vector<std::string>> getFilteredLogs(
+ const std::string& logType,
+ const std::string& username,
+ const std::string& description,
+ const std::string& startTime,
+ const std::string& endTime,
+ int pageNumber,
+ int pageSize);
+
+ // 获取符合条件的日志总数
+ int getTotalLogCount(
+ const std::string& logType,
+ const std::string& username,
+ const std::string& description,
+ const std::string& startTime,
+ const std::string& endTime);
+
+ // 清理超过指定天数的旧日志
+ void cleanOldLogs(int daysToKeep = 30);
+
+ // 转换日志类型为字符串
+ static std::string logTypeToString(LogType logType);
+
+private:
+ // 构造函数和析构函数
+ SystemLogManager();
+ ~SystemLogManager();
+
+ // 禁止拷贝和赋值
+ SystemLogManager(const SystemLogManager&) = delete;
+ SystemLogManager& operator=(const SystemLogManager&) = delete;
+
+ // 数据库连接
+ BL::Database* m_pDB = nullptr;
+
+ // 线程安全锁
+ static std::mutex m_mutex;
+};
+
+#endif // SYSTEM_LOG_MANAGER_H
\ No newline at end of file
--
Gitblit v1.9.3