From 69e50118c485954ef71cab56dc2cab0b0f06114e Mon Sep 17 00:00:00 2001
From: jiangkegeng <jiangkegeng>
Date: 星期四, 31 十月 2024 15:27:23 +0800
Subject: [PATCH] Merge branch 'master' of ssh://115.28.86.8:29418/~admin/昆仑_1025
---
Client/李宵增/document/历史查询分析模块需求分析.docx | 0
Server/王琨元/code/MysqlConn.h | 63 ++++++
Client/王鑫鑫/log/昆仑_1031项目日报.doc | 0
Server/王琨元/code/ConnectionPool.h | 54 +++++
Server/王琨元/document/~$库模块需求分析.docx | 0
Client/申烜/document/注册登录数据库表.docx | 0
Server/马渝杭/code/common.h | 164 ++++++++++++++++
Client/宋昊昳/log/日志_宋昊昳_1031.doc | 0
Server/王琨元/code/ConnectionPool.cpp | 131 +++++++++++++
Server/王琨元/log/日志模板_王琨元_1030.doc | 0
/dev/null | 0
Server/王琨元/code/MysqlConn.cpp | 174 +++++++++++++++++
Server/马渝杭/log/日志_马渝杭_20241030.doc | 0
Client/宋昊昳/document/系统设置需求分析.docx | 0
Server/李转转/log/log_1031.doc | 0
Server/王琨元/document/建表.docx | 0
Client/李宵增/log/历史查询_李宵增_1030.doc | 0
17 files changed, 586 insertions(+), 0 deletions(-)
diff --git "a/Client/\345\256\213\346\230\212\346\230\263/document/\347\263\273\347\273\237\350\256\276\347\275\256\351\234\200\346\261\202\345\210\206\346\236\220.docx" "b/Client/\345\256\213\346\230\212\346\230\263/document/\347\263\273\347\273\237\350\256\276\347\275\256\351\234\200\346\261\202\345\210\206\346\236\220.docx"
index 7ff6bde..58cade1 100644
--- "a/Client/\345\256\213\346\230\212\346\230\263/document/\347\263\273\347\273\237\350\256\276\347\275\256\351\234\200\346\261\202\345\210\206\346\236\220.docx"
+++ "b/Client/\345\256\213\346\230\212\346\230\263/document/\347\263\273\347\273\237\350\256\276\347\275\256\351\234\200\346\261\202\345\210\206\346\236\220.docx"
Binary files differ
diff --git "a/Client/\345\256\213\346\230\212\346\230\263/log/\346\227\245\345\277\227_\345\256\213\346\230\212\346\230\263_1031.doc" "b/Client/\345\256\213\346\230\212\346\230\263/log/\346\227\245\345\277\227_\345\256\213\346\230\212\346\230\263_1031.doc"
new file mode 100644
index 0000000..a58b65e
--- /dev/null
+++ "b/Client/\345\256\213\346\230\212\346\230\263/log/\346\227\245\345\277\227_\345\256\213\346\230\212\346\230\263_1031.doc"
Binary files differ
diff --git "a/Client/\346\235\216\345\256\265\345\242\236/document/\345\216\206\345\217\262\346\237\245\350\257\242\345\210\206\346\236\220\346\250\241\345\235\227\351\234\200\346\261\202\345\210\206\346\236\220.docx" "b/Client/\346\235\216\345\256\265\345\242\236/document/\345\216\206\345\217\262\346\237\245\350\257\242\345\210\206\346\236\220\346\250\241\345\235\227\351\234\200\346\261\202\345\210\206\346\236\220.docx"
index a778b7f..6b3025b 100644
--- "a/Client/\346\235\216\345\256\265\345\242\236/document/\345\216\206\345\217\262\346\237\245\350\257\242\345\210\206\346\236\220\346\250\241\345\235\227\351\234\200\346\261\202\345\210\206\346\236\220.docx"
+++ "b/Client/\346\235\216\345\256\265\345\242\236/document/\345\216\206\345\217\262\346\237\245\350\257\242\345\210\206\346\236\220\346\250\241\345\235\227\351\234\200\346\261\202\345\210\206\346\236\220.docx"
Binary files differ
diff --git "a/Client/\346\235\216\345\256\265\345\242\236/log/\345\216\206\345\217\262\346\237\245\350\257\242_\346\235\216\345\256\265\345\242\236_1030.doc" "b/Client/\346\235\216\345\256\265\345\242\236/log/\345\216\206\345\217\262\346\237\245\350\257\242_\346\235\216\345\256\265\345\242\236_1030.doc"
index 8f20d6e..8158c3a 100644
--- "a/Client/\346\235\216\345\256\265\345\242\236/log/\345\216\206\345\217\262\346\237\245\350\257\242_\346\235\216\345\256\265\345\242\236_1030.doc"
+++ "b/Client/\346\235\216\345\256\265\345\242\236/log/\345\216\206\345\217\262\346\237\245\350\257\242_\346\235\216\345\256\265\345\242\236_1030.doc"
Binary files differ
diff --git "a/Client/\347\216\213\351\221\253\351\221\253/log/\346\230\206\344\273\221_1031\351\241\271\347\233\256\346\227\245\346\212\245.doc" "b/Client/\347\216\213\351\221\253\351\221\253/log/\346\230\206\344\273\221_1031\351\241\271\347\233\256\346\227\245\346\212\245.doc"
new file mode 100644
index 0000000..a07a550
--- /dev/null
+++ "b/Client/\347\216\213\351\221\253\351\221\253/log/\346\230\206\344\273\221_1031\351\241\271\347\233\256\346\227\245\346\212\245.doc"
Binary files differ
diff --git "a/Client/\347\224\263\347\203\234/document/\346\263\250\345\206\214\347\231\273\345\275\225\346\225\260\346\215\256\345\272\223\350\241\250.docx" "b/Client/\347\224\263\347\203\234/document/\346\263\250\345\206\214\347\231\273\345\275\225\346\225\260\346\215\256\345\272\223\350\241\250.docx"
new file mode 100644
index 0000000..a37ff65
--- /dev/null
+++ "b/Client/\347\224\263\347\203\234/document/\346\263\250\345\206\214\347\231\273\345\275\225\346\225\260\346\215\256\345\272\223\350\241\250.docx"
Binary files differ
diff --git "a/Client/\347\224\263\347\203\234/document/\346\263\250\345\206\214\347\231\273\345\275\225\351\234\200\346\261\202\345\210\206\346\236\220.docx" "b/Client/\347\224\263\347\203\234/document/\346\263\250\345\206\214\347\231\273\345\275\225\351\234\200\346\261\202\345\210\206\346\236\220.docx"
deleted file mode 100644
index 366835e..0000000
--- "a/Client/\347\224\263\347\203\234/document/\346\263\250\345\206\214\347\231\273\345\275\225\351\234\200\346\261\202\345\210\206\346\236\220.docx"
+++ /dev/null
Binary files differ
diff --git "a/Server/\346\235\216\350\275\254\350\275\254/log/log_1031.doc" "b/Server/\346\235\216\350\275\254\350\275\254/log/log_1031.doc"
new file mode 100644
index 0000000..08ede4d
--- /dev/null
+++ "b/Server/\346\235\216\350\275\254\350\275\254/log/log_1031.doc"
Binary files differ
diff --git "a/Server/\347\216\213\347\220\250\345\205\203/code/ConnectionPool.cpp" "b/Server/\347\216\213\347\220\250\345\205\203/code/ConnectionPool.cpp"
new file mode 100644
index 0000000..367a7f1
--- /dev/null
+++ "b/Server/\347\216\213\347\220\250\345\205\203/code/ConnectionPool.cpp"
@@ -0,0 +1,131 @@
+#include "ConnectionPool.h"
+ConnectionPool::ConnectionPool()
+{
+ if (!parseXmlFile())
+ return;
+ for (m_num = 0; m_num < m_minSize;) {
+ bool flag = addConnection();
+ if (!flag) {
+ return;
+ }
+ }
+ // 如果子线程的任务函数是类的非静态函数,我们需要指定任务函数的地址和任务函数的所有者
+ thread producer(&ConnectionPool::productConnection, this); // 创建连接
+ thread recycler(&ConnectionPool::recycleConnection, this); // 检测并销毁连接
+ // 线程分离,防止阻塞主线程
+ producer.detach();
+ recycler.detach();
+}
+ConnectionPool::~ConnectionPool()
+{
+ while (!m_connections.empty()) {
+ MysqlConn* conn = m_connections.front();
+ m_connections.pop();
+ delete conn;
+ }
+}
+bool ConnectionPool::parseXmlFile()
+{
+ TiXmlDocument xml("mysql.xml");
+ // 加载文件
+ bool res = xml.LoadFile();
+ if (!res) {
+ return false; // 提示
+ }
+ // 根
+ TiXmlElement* rootElement = xml.RootElement();
+ TiXmlElement* childElement = rootElement->FirstChildElement("mysql");
+ // 读取信息
+ m_ip = childElement->FirstChildElement("ip")->GetText();
+ m_port = static_cast<unsigned short>(stoi(string(childElement->FirstChildElement("port")->GetText())));
+ m_user = childElement->FirstChildElement("username")->GetText();
+ m_passwd = childElement->FirstChildElement("password")->GetText();
+ m_dbName = childElement->FirstChildElement("dbName")->GetText();
+ m_minSize = static_cast<int>(stoi(string(childElement->FirstChildElement("minSize")->GetText())));
+ m_maxSize = static_cast<int>(stoi(string(childElement->FirstChildElement("maxSize")->GetText())));
+ m_maxIdleTime = static_cast<int>(stoi(string(childElement->FirstChildElement("maxIdleTime")->GetText())));
+ m_timeout = static_cast<int>(stoi(string(childElement->FirstChildElement("timeout")->GetText())));
+ return true;
+}
+bool ConnectionPool::addConnection()
+{
+ MysqlConn* conn = new MysqlConn;
+ bool res = conn->connect(m_user, m_passwd, m_dbName, m_ip, m_port);
+ if (res) {
+ // 刷新空闲时间
+ conn->refreashAliveTime();
+ m_connections.push(conn);
+ ++m_num;
+ return true;
+ }
+ else {
+ delete conn;
+ return false; // 提示
+ }
+}
+void ConnectionPool::productConnection()
+{
+ while (true) {
+ unique_lock<mutex> lc(m_mutex);
+ m_cond.wait(lc, [this]() {return m_connections.empty(); });
+ if (m_num < m_maxSize) {
+ bool flag = addConnection();
+ if (!flag) {
+ return;
+ }
+ }
+ // 唤醒
+ m_cond1.notify_all();
+ }
+}
+void ConnectionPool::recycleConnection()
+{
+ while (true) {
+ // 休眠一段时间 0.5s
+ this_thread::sleep_for(milliseconds(500));
+ lock_guard<mutex> lc(m_mutex);
+ while (!m_connections.empty() && m_num > m_minSize) {
+ MysqlConn* conn = m_connections.front();
+ if (conn->getAliveTime() >= m_maxIdleTime) {
+ m_connections.pop();
+ delete conn;
+ --m_num;
+ }
+ else {
+ break;
+ }
+ }
+ }
+}
+ConnectionPool* ConnectionPool::getConnectPool()
+{
+ // 不使用互斥锁的线程安全的懒汉模式
+ static ConnectionPool pool; // 只在第一次调用函数时初始化
+ return &pool;
+}
+shared_ptr<MysqlConn> ConnectionPool::getConnection()
+{
+ unique_lock<mutex> lc(m_mutex);
+ while (m_connections.empty()) {
+ if (cv_status::timeout == m_cond1.wait_for(lc, chrono::milliseconds(m_timeout))) {
+ if (m_connections.empty()) {
+ // cout << "out of time" << endl;
+ return nullptr; // 结束 // 提示
+ // continue; // 利用while配合continue 继续阻塞
+ }
+ }
+ }
+ // 要指定删除器destructor,来保证连接的归还
+ shared_ptr<MysqlConn> conn(m_connections.front(), [this](MysqlConn* conn) {
+ // 加锁保证队列线程安全
+ // m_mutex.lock(); // 1
+ unique_lock<mutex> lc(m_mutex); // 2
+ // lock_guard<mutex> lc(m_mutex); // 3
+ conn->refreashAliveTime();
+ m_connections.push(conn);
+ // m_mutex.unlock(); // 1
+ });
+ m_connections.pop();
+ m_cond.notify_all();
+ return conn;
+}
diff --git "a/Server/\347\216\213\347\220\250\345\205\203/code/ConnectionPool.h" "b/Server/\347\216\213\347\220\250\345\205\203/code/ConnectionPool.h"
new file mode 100644
index 0000000..3ad1ee0
--- /dev/null
+++ "b/Server/\347\216\213\347\220\250\345\205\203/code/ConnectionPool.h"
@@ -0,0 +1,54 @@
+#pragma once
+#include "MysqlConn.h"
+#include "./tinyxml/tinyxml.h"
+#include <queue>
+#include <mutex>
+#include <thread>
+#include <atomic>
+#include <condition_variable>
+
+
+#pragma comment(lib, "./tinyxml/x64/Debug/tinyxml.lib")
+
+// 应用-单例模式:懒汉模式[需要考虑多线程安全问题]
+class ConnectionPool
+{
+private:
+ ConnectionPool();
+ // 移动拷贝最终还是有且仅有一个对象,所以依旧是属于单例模式。
+ // delete 阻止拷贝构造和拷贝赋值的类对象生成
+ ConnectionPool(ConnectionPool&) = delete;
+ ConnectionPool& operator=(ConnectionPool&) = delete;
+ ~ConnectionPool();
+ // 解析xml配置文件 读取数据库及连接池的相关信息
+ bool parseXmlFile();
+ // 添加连接
+ bool addConnection();
+ // 线程函数
+ void productConnection();
+ void recycleConnection();
+
+ // 存放数据库连接池建立的连接
+ queue<MysqlConn*> m_connections;
+ // 一些基本信息
+ string m_ip; // IP
+ unsigned short m_port; // 端口
+ string m_user; // 用户名
+ string m_passwd; // 密码
+ string m_dbName; // 数据库名称
+ int m_minSize; // 初始连接量(最小连接量)
+ int m_maxSize; // 最大连接量
+ int m_timeout; // 超时时长
+ int m_maxIdleTime; // 最大空闲时长
+ // 线程安全相关
+ mutex m_mutex;
+ condition_variable m_cond; // 仅用一个条件变量来唤醒线程,但并不影响线程运行
+ condition_variable m_cond1;
+ // 连接数量
+ atomic_int m_num; // 连接的总数量
+public:
+ // 获取单例对象的接口
+ static ConnectionPool* getConnectPool();
+ // 用户获取连接的接口, 如果获取失败,会返回nullptr
+ shared_ptr<MysqlConn> getConnection();
+};
diff --git "a/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.cpp" "b/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.cpp"
new file mode 100644
index 0000000..57ba1c6
--- /dev/null
+++ "b/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.cpp"
@@ -0,0 +1,174 @@
+#include "MysqlConn.h"
+
+MysqlConn::MysqlConn()//初始化数据库
+{
+ m_result = nullptr;
+ m_mysqlRow = nullptr;
+ // 传入nullptr空指针时,会自动分配一个MYSQL对象
+ m_conn = mysql_init(nullptr);
+}
+MysqlConn::~MysqlConn()//释放数据库连接
+{
+ freeRes(); // 释放结果集
+ if (m_conn != nullptr) {
+ mysql_close(m_conn);
+ m_conn = nullptr;
+ }
+}
+void MysqlConn::freeRes()//结果集释放
+{
+ if (m_result) {
+ mysql_free_result(m_result);
+ m_result = nullptr;
+ }
+}
+bool MysqlConn::connect(const string user, const string passwd, \
+ const string dbName, string ip, \
+ const unsigned short port)//连接数据库
+{
+ MYSQL* res = mysql_real_connect(m_conn, ip.c_str(), user.c_str(), \
+ passwd.c_str(), dbName.c_str(), port, nullptr, 0);
+ // 修改编码
+ mysql_set_character_set(m_conn, "gb2312");
+ return res != nullptr;
+}
+bool MysqlConn::update(const string sql) const
+{
+ // 执行成功返回0;
+ int res = mysql_real_query(m_conn, sql.c_str(), static_cast<unsigned int>(sql.size()));
+ if (res != 0) {
+ return false; // 提示
+ }
+ return true;
+}
+bool MysqlConn::query(const string sql)
+{
+ freeRes();
+ int res = mysql_real_query(m_conn, sql.c_str(), static_cast<unsigned int>(sql.size()));
+ if (res != 0) {
+ return false; // 提示
+ }
+ m_result = mysql_store_result(m_conn);
+ return true;
+}
+bool MysqlConn::getRes()
+{
+ if (m_result != nullptr) {
+ // char** 获取单行记录
+ m_mysqlRow = mysql_fetch_row(m_result);
+ if (m_mysqlRow != nullptr) {
+ return true;
+ }
+ freeRes();
+ }
+ return false;
+}
+string MysqlConn::getValue(const int fieldIndex) const
+{
+ int fieldCount = mysql_num_fields(m_result);
+ if (fieldIndex >= fieldCount || fieldIndex < 0) {
+ return string(); // 提示
+ }
+ char* value = m_mysqlRow[fieldIndex];
+ // 得到一个保存各字段值长度的数组
+ unsigned long* len = mysql_fetch_lengths(m_result);
+ unsigned long length = len[fieldIndex];
+ // 防止结果中存在\0导致数据丢失
+ return string(value, length);
+}
+bool MysqlConn::selectDB(const string dbName) const
+{
+ int res = mysql_select_db(m_conn, dbName.c_str());
+ if (res != 0) {
+ return false; // 提示
+ }
+ return true;
+}
+void MysqlConn::backupCurrentDB(const string path)
+{
+ string sql = "show tables";
+ int r = mysql_real_query(m_conn, sql.c_str(), static_cast<unsigned long>(sql.size()));
+ if (r != 0) {
+ return; // 提示
+ }
+ MYSQL_RES* tableRes = mysql_store_result(m_conn);
+ for (int i = 0; i < mysql_num_rows(tableRes); ++i) {
+ MYSQL_ROW tableName = mysql_fetch_row(tableRes);
+ backupCurrentTable(path, tableName[0]);
+ }
+}
+void MysqlConn::backupCurrentTable(const string path, const string tableName)
+{
+ string file = path + tableName + ".sql";
+ ofstream ofs(file);
+ if (!ofs.is_open()) {
+ return; // 提示
+ }
+ // 表结构写入
+ string showCreate = "show create table " + tableName + ";";
+ bool res = query(showCreate);
+ if (!res) {
+ return; // 提示
+ }
+ if (getRes()) {
+ string writeSQL = getValue(1) + ";\n";
+ ofs.write(writeSQL.c_str(), writeSQL.size());
+ // cout << writeSQL << endl;
+ }
+ // 表数据写入
+ string sql = "select * from " + tableName + ";";
+ res = query(sql);
+ if (!res) {
+ return; // 提示
+ }
+ while (getRes()) {
+ string writeSQL = "insert into `" + tableName + "` values(";
+ for (int i = 0; !getValue(i).empty(); ++i) {
+ if (i != 0) {
+ writeSQL += ",";
+ }
+ MYSQL_FIELD* valueType = mysql_fetch_field_direct(m_result, i);
+ if (valueType->type == MYSQL_TYPE_DECIMAL
+ || valueType->type == MYSQL_TYPE_TINY
+ || valueType->type == MYSQL_TYPE_SHORT
+ || valueType->type == MYSQL_TYPE_LONG
+ || valueType->type == MYSQL_TYPE_FLOAT
+ || valueType->type == MYSQL_TYPE_DOUBLE
+ || valueType->type == MYSQL_TYPE_TIMESTAMP
+ || valueType->type == MYSQL_TYPE_LONGLONG
+ || valueType->type == MYSQL_TYPE_INT24) {
+ writeSQL += getValue(i);
+ }
+ else {
+ writeSQL += "'" + getValue(i) + "'";
+ }
+ }
+ writeSQL += ");\n";
+ ofs.write(writeSQL.c_str(), writeSQL.size());
+ }
+ ofs.close();
+}
+bool MysqlConn::transaction() const
+{
+ // 将事务提交设置为手动提交
+ return mysql_autocommit(m_conn, false);
+}
+bool MysqlConn::commit() const
+{
+ return mysql_commit(m_conn);
+}
+bool MysqlConn::rollback() const
+{
+ return mysql_rollback(m_conn);
+}
+void MysqlConn::refreashAliveTime()
+{
+ m_alivetime = steady_clock::now();
+}
+ll MysqlConn::getAliveTime()
+{
+ // 毫秒 <<= 纳秒:精度降低
+ milliseconds res = duration_cast<milliseconds>(steady_clock::now() - m_alivetime);
+ return res.count();
+}
+
diff --git "a/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.h" "b/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.h"
new file mode 100644
index 0000000..0dbbea9
--- /dev/null
+++ "b/Server/\347\216\213\347\220\250\345\205\203/code/MysqlConn.h"
@@ -0,0 +1,63 @@
+#pragma once
+#include<iostream>
+#include <memory>
+#include <string>
+#include <mysql.h>
+#include <chrono> // 时钟
+#include <fstream>
+
+#pragma comment(lib, "./lib/libmysql.lib") // 加载数据库库文件
+using namespace std;
+using namespace chrono;
+typedef long long ll;
+
+class MysqlConn
+{
+private:
+ // 绝对时钟
+ steady_clock::time_point m_alivetime;
+ // 连接
+ MYSQL* m_conn;
+ // 查询的结果集
+ MYSQL_RES* m_result;
+ // 单记录结果集
+ MYSQL_ROW m_mysqlRow;
+
+ // 结果集释放
+ void freeRes();
+ // 导出某一张表中的数据
+ void backupCurrentTable(const string path, const string tableName);
+public:
+ // 初始化数据库
+ MysqlConn();
+ // 数据库连接释放
+ ~MysqlConn();
+ // 连接数据库, 需提供用户 密码 数据库名称 ip 端口
+ bool connect(const string user, const string passwd, \
+ const string dbName, string ip, \
+ const unsigned short port = 3306U);
+ // 更新数据库:增删改操作
+ bool update(const string sql) const;
+ // 查询数据库
+ bool query(const string sql);
+ // 遍历查询结果集
+ bool getRes();
+ // 获取结果集中的字段值
+ string getValue(const int fieldIndex) const;
+ // 切换数据库
+ bool selectDB(const string dbName) const;
+ // 建库
+ //bool createDB(const string dbName) const;
+ // 备份某个库
+ void backupCurrentDB(const string path);
+ // 事务操作
+ bool transaction() const;
+ // 提交事务
+ bool commit() const;
+ // 事务回滚
+ bool rollback() const;
+ // 刷新起始的空闲时间点
+ void refreashAliveTime();
+ // 计算存活总时长
+ ll getAliveTime();
+};
diff --git "a/Server/\347\216\213\347\220\250\345\205\203/document/~$\345\272\223\346\250\241\345\235\227\351\234\200\346\261\202\345\210\206\346\236\220.docx" "b/Server/\347\216\213\347\220\250\345\205\203/document/~$\345\272\223\346\250\241\345\235\227\351\234\200\346\261\202\345\210\206\346\236\220.docx"
new file mode 100644
index 0000000..8b245e2
--- /dev/null
+++ "b/Server/\347\216\213\347\220\250\345\205\203/document/~$\345\272\223\346\250\241\345\235\227\351\234\200\346\261\202\345\210\206\346\236\220.docx"
Binary files differ
diff --git "a/Server/\347\216\213\347\220\250\345\205\203/document/\345\273\272\350\241\250.docx" "b/Server/\347\216\213\347\220\250\345\205\203/document/\345\273\272\350\241\250.docx"
index b777db4..ed3cc7a 100644
--- "a/Server/\347\216\213\347\220\250\345\205\203/document/\345\273\272\350\241\250.docx"
+++ "b/Server/\347\216\213\347\220\250\345\205\203/document/\345\273\272\350\241\250.docx"
Binary files differ
diff --git "a/Server/\347\216\213\347\220\250\345\205\203/log/\346\227\245\345\277\227\346\250\241\346\235\277_\347\216\213\347\220\250\345\205\203_1030.doc" "b/Server/\347\216\213\347\220\250\345\205\203/log/\346\227\245\345\277\227\346\250\241\346\235\277_\347\216\213\347\220\250\345\205\203_1030.doc"
new file mode 100644
index 0000000..b74ed06
--- /dev/null
+++ "b/Server/\347\216\213\347\220\250\345\205\203/log/\346\227\245\345\277\227\346\250\241\346\235\277_\347\216\213\347\220\250\345\205\203_1030.doc"
Binary files differ
diff --git "a/Server/\351\251\254\346\270\235\346\235\255/code/common.h" "b/Server/\351\251\254\346\270\235\346\235\255/code/common.h"
new file mode 100644
index 0000000..b6c770d
--- /dev/null
+++ "b/Server/\351\251\254\346\270\235\346\235\255/code/common.h"
@@ -0,0 +1,164 @@
+#ifndef COMMON_H
+#define COMMON_H
+#include <string.h>
+//绉佹湁鍗忚灏佽
+
+//璇锋眰鍝嶅簲缁撴瀯浣撴湁鏁版嵁澶�+鏁版嵁浣�
+
+//浣跨敤鏋氫妇鏉ョ粺涓�鍚勭鍔熻兘绫诲瀷銆�
+
+enum TypeInfo{
+ LOGIN_REQ, //鐧诲綍璇锋眰
+ LOGIN_RES,
+ VERSIONUPDATA_REQ, // 鐗堟湰鏇存柊璇锋眰
+ VERSIONUPDATA_RES,
+ VERSIONNUM_REQ, //鐗堟湰鍙疯姹�
+ VERSIONNUM_RES,
+ UPLOAD_FILE_REQ,
+ UPLOAD_FILE_RES,
+ VERSIONINFOENTRY_REQ, //鐗堟湰淇℃伅鏉$洰
+ VERSIONINFOENTRY_RES
+};
+
+struct Head
+{
+ int type; // 鍔熻兘绫诲瀷锛岃В鍐虫瘡涓寘鐨勫叿浣撲綔鐢紝鍖哄垎涓氬姟
+ int len; //灏佸寘闀垮害
+
+};
+// 鐧诲綍涓氬姟
+// 鐧诲綍璇锋眰
+struct LoginReq
+{
+ Head head;
+
+ char user_name[32];
+ char password[32];
+ LoginReq(){
+ head.type=LOGIN_REQ;
+ head.len=sizeof(LoginReq);
+ }
+};
+//鐧诲綍鏉冮檺缁撴瀯浣�
+struct PermissionInfo
+{
+ int admin; //绠$悊鍛�
+ int history; //鍘嗗彶鏌ョ湅
+ int version_manager;//鐗堟湰绠$悊
+ int log_search; //鏃ュ織鏌ョ湅
+ int flaw_mark ; //缂洪櫡鏍囪
+
+};
+
+//鐧诲綍鍝嶅簲
+struct LoginRes
+{
+ Head head;
+ char user_name[32];
+ int state; // 鐧诲綍鐘舵��
+ PermissionInfo per;
+ LoginRes(){
+ head.type=LOGIN_RES;
+ head.len=sizeof(LoginRes);
+ }
+};
+struct VersionUpdataReq //鐗堟湰鏇存柊璇锋眰鐨勭粨鏋勪綋
+{
+ Head head;
+ VersionUpdataReq(){
+ head.type=VERSIONUPDATA_REQ;
+ head.len=sizeof(VersionUpdataReq);
+ }
+};
+struct VersionUpdataRes //鐗堟湰鏇存柊鍝嶅簲鐨勭粨鏋勪綋
+{
+ Head head;
+ char version_id[64]; // 鐗堟湰鍙�
+ char update_date[32]; //鏇存柊鏃堕棿
+ char file_path[128]; //鏈嶅姟绔彁渚涙渶鏂扮増鏈殑鏈湴璺緞
+ VersionUpdataRes(){
+ head.type=VERSIONUPDATA_REQ;
+ head.len=sizeof(VersionUpdataReq);
+ }
+};
+struct VersionNumReq //鐗堟湰鍙疯姹�
+{
+ Head head;
+ VersionNumReq(){
+ head.type=VERSIONNUM_REQ;
+ head.len=sizeof(VersionNumReq);
+ }
+};
+struct VersionNumRes
+{
+ Head head;
+ char version_id[64];
+ VersionNumRes(){
+ head.type=VERSIONNUM_RES;
+ head.len=sizeof(VersionNumRes);
+ }
+};
+//鏂囦欢浼犺緭鍔熻兘
+struct FileInfo
+{
+ char file_name[256];
+ long long file_size;
+ char s_filepath[32];
+ char content[0]; //鏌旀�ф暟缁勭粨鏋勪綋
+};
+struct UploadFileReq
+{
+ Head head;
+ FileInfo fileInfo;
+ UploadFileReq(){
+ head.type=UPLOAD_FILE_REQ;
+ head.len=sizeof(UploadFileReq);
+ }
+};
+struct UploadFileRes
+{
+ Head head;
+ int status;
+ long long file_size; //鎬诲ぇ灏�
+ long long file_cuesize; //鏂囦欢宸蹭紶澶у皬
+ UploadFileRes(){
+ head.type=UPLOAD_FILE_RES;
+ head.len=sizeof(UploadFileRes);
+ }
+};
+//鐗堟湰淇℃伅褰曞叆---鐗堟湰淇℃伅鏉$洰
+struct VersionInfoEntryReq
+{
+ Head head;
+ char version_id[64];
+ char version_id_old[64];
+ char s_filepath[32]; //鏈嶅姟鍣ㄦ斁鏈�鏂扮増鏈殑璺緞
+ char version_description[256]; //鏇存柊鎻忚堪
+ char version_creattime[32]; //鏇存柊鏃堕棿
+ char filename[16][128]; //鏀寔澶氭枃浠朵笂浼�
+ long long filesize[16]; //鏂囦欢缁勭殑澶у皬
+ char c_filepath[16][128]; //瀹㈡埛绔殑瀹夎璺緞
+ int filenum; //涓�娆$増鏈洿鏂版墍闇�鏂囦欢涓暟
+
+ VersionInfoEntryReq(){
+ head.type=VERSIONINFOENTRY_REQ;
+ head.len=sizeof(VersionInfoEntryReq);
+ }
+};
+//鍝嶅簲
+struct VersionInfoEntryRes {
+ Head head;
+ char version_id_old[64]; // 鐗堟湰鍙�
+ VersionInfoEntryRes()
+ {
+ head.type = VERSIONINFOENTRY_RES;
+ head.len = sizeof(VersionInfoEntryRes);
+ }
+};
+
+
+
+
+
+
+#endif // COMMON_H
diff --git "a/Server/\351\251\254\346\270\235\346\235\255/log/\346\227\245\345\277\227_\351\251\254\346\270\235\346\235\255_20241030.doc" "b/Server/\351\251\254\346\270\235\346\235\255/log/\346\227\245\345\277\227_\351\251\254\346\270\235\346\235\255_20241030.doc"
new file mode 100644
index 0000000..3171038
--- /dev/null
+++ "b/Server/\351\251\254\346\270\235\346\235\255/log/\346\227\245\345\277\227_\351\251\254\346\270\235\346\235\255_20241030.doc"
Binary files differ
--
Gitblit v1.8.0