| | |
| | | } |
| | | }; |
| | | |
| | | //日志查询 |
| | | |
| | | struct LogQueryRequest { |
| | | Head header; // 数据头 |
| | | std::string* keywords; // 存储多个关键字的柔性数组 |
| | | size_t keywordCount; // 关键字数量 |
| | | std::string startDate; // 开始日期 (格式: YYYY-MM-DD) |
| | | std::string endDate; // 结束日期 (格式: YYYY-MM-DD) |
| | | int pageNumber; // 当前页码 |
| | | int pageSize; // 每页条目数 |
| | | enum Typeinfo{ |
| | | LOGSEARCH_REQ,//日志查询请求 |
| | | LOGSEARCH_RES,//日志查询响应 |
| | | |
| | | // 构造函数 |
| | | LogQueryRequest(int type, int len, std::string* keywords, size_t keywordCount, const std::string& startDate, const std::string& endDate, int pageNumber, int pageSize) |
| | | : header{type, len}, keywords(keywords), keywordCount(keywordCount), startDate(startDate), endDate(endDate), pageNumber(pageNumber), pageSize(pageSize) {} |
| | | }; |
| | | |
| | | // 析构函数 |
| | | ~LogQueryRequest() { |
| | | delete[] keywords; // 释放动态分配的内存 |
| | | struct Head |
| | | { |
| | | int type; // 功能类型 |
| | | int len; //封包长度 |
| | | |
| | | }; |
| | | // 日志查询请求结构体 |
| | | struct LogQueryReq { |
| | | Head heade; // 数据头 |
| | | char keyWords[0]; // 存储多个关键字的柔性数组 |
| | | // 无参构造函数 |
| | | LogQueryReq() { |
| | | head.type = LOGSEARCH_REQ; |
| | | head.len = sizeof(LogQueryReq); |
| | | } |
| | | }; |
| | | |
| | | //日志查询响应 |
| | | // 定义日志条目结构体 |
| | | struct LogEntry { |
| | | int id; // 日志条目 ID |
| | | string entryTime; // 下井时间 |
| | | string name; // 姓名 |
| | | string exitTime; // 升井时间 |
| | | string department; // 部门 |
| | | string position; // 岗位 |
| | | //string workingTime; // 工作时间 数据库自动生成 |
| | | |
| | | // 构造函数 |
| | | LogEntry(int id, const string& entryTime, const string& name, |
| | | const string& exitTime, const string& department, |
| | | const string& position) |
| | | : id(id), entryTime(entryTime), name(name), |
| | | exitTime(exitTime), department(department), position(position) {} |
| | | }; |
| | | |
| | | // 定义日志查询响应结构体 |
| | | struct LogQueryResponse { |
| | | // 日志查询响应结构体 |
| | | struct LogQueryRes { |
| | | Head heade; |
| | | int status; // 响应状态 (如 0 表示成功,非 0 表示失败) |
| | | string errorMessage; // 错误信息(如果有) |
| | | vector<LogEntry> logEntries; // 日志条目 |
| | | |
| | | // 构造函数 |
| | | LogQueryResponse(int status, const string& errorMessage, const vector<LogEntry>& logEntries) |
| | | : status(status), errorMessage(errorMessage), logEntries(logEntries) {} |
| | | char errorMessage[256]; // 错误信息(如果有) |
| | | |
| | | // 无参构造函数 |
| | | LogQueryRes() { |
| | | head.type = LOGSEARCH_RES; |
| | | head.len = sizeof(LogQueryRes); |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | #endif // COMMON_H |
| | | #endif // COMMON_H |
| | | |