增加日志
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#ifndef BANK_H
|
||||
#define BANK_H
|
||||
|
||||
#define MAX_LOGS 100 // 日志队列最大容量,防止无限增长
|
||||
#define MAX_ACCOUNTS 50 //系统规格为50个账户
|
||||
#define NAME_LEN 31 //用户名字最长30字符,因此需要多1个字符串结束符
|
||||
|
||||
@@ -51,4 +51,30 @@ void DeleteAccount(int id);
|
||||
|
||||
void InitAdminAccount();
|
||||
|
||||
// 日志条目结构
|
||||
typedef struct {
|
||||
int account_id; // 涉及的账户ID
|
||||
char type[10]; // 操作类型: "Deposit" 或 "Withdraw"
|
||||
double amount; // 交易金额
|
||||
double balance; // 交易后的余额
|
||||
char timestamp[20]; // 时间戳 (格式: YYYY-MM-DD HH:MM:SS)
|
||||
char location[50]; // 地点信息
|
||||
} LogEntry;
|
||||
|
||||
// 环形队列结构
|
||||
typedef struct {
|
||||
LogEntry logs[MAX_LOGS];
|
||||
int front; // 队头指针
|
||||
int rear; // 队尾指针
|
||||
} LogQueue;
|
||||
|
||||
// 全局日志队列变量 (在 bank.c 中定义,在其他文件中 extern 引用)
|
||||
extern LogQueue g_logQueue;
|
||||
|
||||
// 日志函数声明
|
||||
void InitLogQueue(); // 初始化队列
|
||||
int IsLogQueueFull(); // 检查队列是否满
|
||||
int IsLogQueueEmpty(); // 检查队列是否空
|
||||
int EnqueueLog(int id, const char* type, double amt, double bal); // 入队
|
||||
void ShowTransactionLogs(); // 显示所有日志
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user