#ifndef STRUCT_DATA_H
|
#define STRUCT_DATA_H
|
|
/* 使用枚举,表示类型和功能 */
|
enum TypeInfo {
|
LOGIN_REQ, // 登录请求
|
LOGIN_RES, // 登录响应
|
|
REGISTER_REQ,//注册请求
|
REGISTER_RES,//注册响应
|
|
HEART_CHECK_REQ, // 心跳检测请求
|
HEART_CHECK_RES, // 心跳检测响应
|
|
TEST, // 柔性数组的类型
|
TEST_NEXT, // 指针不定长类型
|
};
|
|
/* 报文头 */
|
struct Head{
|
int type;//区分类型
|
int len; //表示封包长度
|
};
|
|
/* 权限 */
|
struct Permission
|
{
|
int admin; // 管理员权限
|
int history; // 历史查询
|
int log_search; // 日志查询权限
|
int map_change; // 地图修改
|
int attend_manage; // 考勤管理
|
int device_manage; // 设备管理
|
int version_manage; // 版本管理
|
int notify_manage; // 通知管理
|
int image_input; // 图像录入
|
int monitor_back; // 后台监控
|
};
|
|
/* 登录请求 */
|
struct LoginReq
|
{
|
Head head;
|
char user_name[32];
|
char password[32];
|
|
LoginReq(){
|
head.type = LOGIN_REQ;
|
head.len = sizeof(LoginReq);
|
}
|
};
|
|
/* 登录响应 */
|
struct LoginRes
|
{
|
Head head;
|
char user_name[32];
|
int emp_id;//返回工号
|
int status;
|
Permission per;//权限对象
|
|
LoginRes() {
|
head.type = LOGIN_RES;
|
head.len = sizeof(LoginRes);
|
}
|
};
|
|
/* 注册请求 */
|
struct RegisterReq
|
{
|
Head head;
|
char user_name[32];
|
char password[32];
|
char email[32];
|
char telephone[32];
|
char department[32];
|
|
RegisterReq(){
|
head.type = REGISTER_REQ;
|
head.len = sizeof(RegisterReq);
|
}
|
};
|
|
/* 注册响应 */
|
struct RegisterRes
|
{
|
Head head;
|
char user_name[32];
|
int emp_id;//返回工号
|
int status;
|
Permission per;//权限对象
|
char res_info[100];
|
|
RegisterRes() {
|
head.type = REGISTER_RES;
|
head.len = sizeof(RegisterRes);
|
}
|
};
|
|
/*
|
经过协商,客户端Qt界面·用户信息的结构体
|
|
struct User {
|
QString username; //ok
|
QString password; //ok
|
QString email; //ok
|
QString phone; //ok
|
QString department; //ok
|
QString permission; //default【注册默认只有最基本的权限】[可以提前写入]
|
QString status; //default【注册默认状态1】[可以提前写入]
|
QDate registerDate; //default【注册默认当前时间】[是不是应该在数据库写入?]
|
};
|
|
个人理解:把这个结构体封装到注册请求包中
|
*/
|
|
#endif // STRUCT_DATA_H
|