2025-03-14 16:06:20 +08:00
|
|
|
|
#ifndef GLOBAL_H
|
|
|
|
|
|
#define GLOBAL_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
#include <QSqlError>
|
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
|
|
|
|
enum DialogState
|
|
|
|
|
|
{
|
|
|
|
|
|
DS_New,
|
|
|
|
|
|
DS_Edit
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct DatabaseConfig
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strID; //存储在配置文件时用作唯一标识
|
|
|
|
|
|
QString strConnectionName;
|
|
|
|
|
|
QString strDBType; //"QPSQL","QMYSQL"...
|
|
|
|
|
|
QString strHost;
|
|
|
|
|
|
int nPort;
|
|
|
|
|
|
QString strDBName;
|
|
|
|
|
|
QString strUserName;
|
|
|
|
|
|
QString strPassword;
|
|
|
|
|
|
bool bSavePS;
|
|
|
|
|
|
QString strComment;
|
|
|
|
|
|
|
|
|
|
|
|
DatabaseConfig()
|
|
|
|
|
|
{
|
2025-05-26 16:50:46 +08:00
|
|
|
|
strID = "";
|
2025-03-14 16:06:20 +08:00
|
|
|
|
strConnectionName = "";
|
|
|
|
|
|
strDBType = "QPSQL";
|
|
|
|
|
|
strHost = "";
|
|
|
|
|
|
nPort = 5432;
|
|
|
|
|
|
strDBName = "postgres";
|
|
|
|
|
|
strUserName = "";
|
|
|
|
|
|
strPassword = "";
|
|
|
|
|
|
bSavePS = true;
|
|
|
|
|
|
strComment = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct AttributeGroup
|
|
|
|
|
|
{
|
|
|
|
|
|
int id;
|
|
|
|
|
|
QString name; //中文展示名称
|
|
|
|
|
|
QString type; //英文标识名称
|
|
|
|
|
|
QString remark;
|
|
|
|
|
|
bool isPublic;
|
2025-04-25 11:49:03 +08:00
|
|
|
|
int version; //用来及记录pucblic类型属性组数据同步的标记
|
2025-03-14 16:06:20 +08:00
|
|
|
|
|
2025-04-02 15:57:00 +08:00
|
|
|
|
AttributeGroup()
|
|
|
|
|
|
{
|
|
|
|
|
|
id = -1;
|
|
|
|
|
|
name = "";
|
|
|
|
|
|
type = "";
|
|
|
|
|
|
remark = "";
|
|
|
|
|
|
isPublic = false;
|
2025-04-25 11:49:03 +08:00
|
|
|
|
version = 0;
|
2025-04-02 15:57:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-14 16:06:20 +08:00
|
|
|
|
//利用移动语义优化的构造函数(不定义也可以,QString实际上实现了隐式共享)
|
2025-04-25 11:49:03 +08:00
|
|
|
|
AttributeGroup(int id, QString name, QString type, QString remark, bool isPublic, int version = 0)
|
2025-03-14 16:06:20 +08:00
|
|
|
|
: id(id),
|
|
|
|
|
|
name(std::move(name)),
|
|
|
|
|
|
type(std::move(type)),
|
|
|
|
|
|
remark(std::move(remark)),
|
2025-04-25 11:49:03 +08:00
|
|
|
|
isPublic(isPublic),
|
|
|
|
|
|
version(version){}
|
2025-03-14 16:06:20 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Model
|
|
|
|
|
|
{
|
|
|
|
|
|
int id;
|
|
|
|
|
|
QString name; //中文展示名称
|
|
|
|
|
|
QString type; //英文标识名称
|
|
|
|
|
|
QString remark;
|
2025-05-30 18:51:23 +08:00
|
|
|
|
QByteArray icon;
|
|
|
|
|
|
int grahicElement;
|
2025-03-14 16:06:20 +08:00
|
|
|
|
QVector<int> groups;
|
|
|
|
|
|
|
2025-05-30 18:51:23 +08:00
|
|
|
|
Model(int id, QString name, QString type, QString remark, QByteArray icon, int grahicElement, QVector<int> groups)
|
2025-03-14 16:06:20 +08:00
|
|
|
|
: id(id),
|
|
|
|
|
|
name(std::move(name)),
|
|
|
|
|
|
type(std::move(type)),
|
|
|
|
|
|
remark(std::move(remark)),
|
2025-05-30 18:51:23 +08:00
|
|
|
|
icon(std::move(icon)),
|
|
|
|
|
|
grahicElement(std::move(grahicElement)),
|
2025-03-14 16:06:20 +08:00
|
|
|
|
groups(std::move(groups)){}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-03-31 16:01:49 +08:00
|
|
|
|
struct Attribute
|
|
|
|
|
|
{
|
2025-04-01 16:45:30 +08:00
|
|
|
|
int id;
|
2025-03-31 16:01:49 +08:00
|
|
|
|
QString name; //中文展示名称(filed:attribute_name)
|
|
|
|
|
|
QString type; //英文表示名称(filed:attribute),不可重名
|
|
|
|
|
|
int dataTypeID;
|
2025-04-01 16:45:30 +08:00
|
|
|
|
int dataLength; //filed:length_precision
|
2025-03-31 16:01:49 +08:00
|
|
|
|
QString defaultValue;
|
2025-04-27 16:24:13 +08:00
|
|
|
|
int isVisible;
|
2025-03-31 16:01:49 +08:00
|
|
|
|
|
2025-04-01 16:45:30 +08:00
|
|
|
|
Attribute()
|
|
|
|
|
|
{
|
|
|
|
|
|
id = -1;
|
|
|
|
|
|
name = "";
|
|
|
|
|
|
type = "";
|
|
|
|
|
|
dataTypeID = -1;
|
|
|
|
|
|
dataLength = -1;
|
|
|
|
|
|
defaultValue = "";
|
2025-04-27 16:24:13 +08:00
|
|
|
|
isVisible = 1;
|
2025-04-01 16:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-04-27 16:24:13 +08:00
|
|
|
|
Attribute(int id, QString name, QString type, int dataTypeID, int dataLength, QString defaultVaule, int isVisible = 1)
|
2025-03-31 16:01:49 +08:00
|
|
|
|
:id(id),
|
|
|
|
|
|
name(std::move(name)),
|
|
|
|
|
|
type(std::move(type)),
|
|
|
|
|
|
dataTypeID(dataTypeID),
|
|
|
|
|
|
dataLength(dataLength),
|
2025-04-27 16:24:13 +08:00
|
|
|
|
defaultValue(std::move(defaultVaule)),
|
|
|
|
|
|
isVisible(isVisible){}
|
2025-03-31 16:01:49 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-03-24 18:13:06 +08:00
|
|
|
|
struct ModelAttributeGroup
|
|
|
|
|
|
{
|
|
|
|
|
|
int modelID;
|
|
|
|
|
|
int groupID;
|
|
|
|
|
|
QString strModelName;
|
|
|
|
|
|
QString strGroupName;
|
|
|
|
|
|
|
|
|
|
|
|
ModelAttributeGroup(int modelID, int groupID, QString strModelName, QString strGroupName)
|
|
|
|
|
|
: modelID(modelID),
|
|
|
|
|
|
groupID(groupID),
|
|
|
|
|
|
strModelName(std::move(strModelName)),
|
|
|
|
|
|
strGroupName(std::move(strGroupName)){}
|
|
|
|
|
|
};
|
2025-03-14 16:06:20 +08:00
|
|
|
|
|
2025-03-25 17:58:48 +08:00
|
|
|
|
struct PaginationInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
int totalEntries; //数据条目总数量
|
|
|
|
|
|
int entriesPerPage; //每页条目数量
|
|
|
|
|
|
int totalPages; //总页数
|
|
|
|
|
|
int currentPage; //当前页数
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-05-30 18:51:23 +08:00
|
|
|
|
struct Component
|
|
|
|
|
|
{
|
|
|
|
|
|
int id;
|
|
|
|
|
|
QString type;
|
|
|
|
|
|
QString name;
|
|
|
|
|
|
|
|
|
|
|
|
Component(int id, QString type, QString name)
|
|
|
|
|
|
: id(id),
|
|
|
|
|
|
type(std::move(type)),
|
|
|
|
|
|
name(std::move(name)){}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-03-14 16:06:20 +08:00
|
|
|
|
class DatabaseException : public std::runtime_error
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
explicit DatabaseException(const QSqlError& error)
|
|
|
|
|
|
: std::runtime_error(error.text().toStdString()), m_error(error) {}
|
|
|
|
|
|
|
|
|
|
|
|
QSqlError error() const { return m_error; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
QSqlError m_error;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|