2025-06-23 10:41:33 +08:00
|
|
|
#include "DelByInterface.h"
|
|
|
|
#include "M_DelByInterfaceDAO.h"
|
|
|
|
#include "DataManager.h"
|
|
|
|
#include "DataAttribute.h"
|
|
|
|
|
|
|
|
DelByInterface::DelByInterface()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DelByInterface::~DelByInterface()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-06-23 21:06:10 +08:00
|
|
|
// void static backupDAOData(DBPlatformSpace::M_DelByInterfaceDAO& src, DBPlatformSpace::M_DelByInterfaceDAO& dst)
|
|
|
|
// {
|
2025-06-23 10:41:33 +08:00
|
|
|
|
2025-06-23 21:06:10 +08:00
|
|
|
// }
|
2025-06-23 10:41:33 +08:00
|
|
|
|
2025-06-23 21:06:10 +08:00
|
|
|
// void static restoreData(DBPlatformSpace::M_DelByInterfaceDAO& src, DelByInterface& dst)
|
|
|
|
// {
|
2025-06-23 10:41:33 +08:00
|
|
|
|
2025-06-23 21:06:10 +08:00
|
|
|
// }
|
2025-06-23 10:41:33 +08:00
|
|
|
|
|
|
|
void DelByInterface::loadData(DBPlatformSpace::DAO* pDao)
|
|
|
|
{
|
|
|
|
_pDBDAO = pDao;
|
|
|
|
DBPlatformSpace::M_DelByInterfaceDAO* pDelDAO = dynamic_cast<DBPlatformSpace::M_DelByInterfaceDAO*>(_pDBDAO);
|
|
|
|
_id = pDelDAO->_ID;
|
|
|
|
_bExport = pDelDAO->_bExport;
|
|
|
|
_name = CommonHelper::stringToQstring(pDelDAO->_name);
|
|
|
|
_description = CommonHelper::stringToQstring(pDelDAO->_description);
|
|
|
|
_paraList = CommonHelper::stringToQstring(pDelDAO->_paraList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DelByInterface::deleteSelf()
|
|
|
|
{
|
|
|
|
using namespace DBPlatformSpace;
|
|
|
|
ResultMsg rm;
|
|
|
|
M_DelByInterfaceDAO* pDelDao = dynamic_cast<M_DelByInterfaceDAO*>(_pDBDAO);
|
|
|
|
rm = pDelDao->delself();
|
|
|
|
if (rm.rCode == 0)
|
|
|
|
{
|
|
|
|
LOG(INFO) << CommonHelper::utf8ToStdString("M_FindByInterfaceDAO.save success");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
LOG(INFO) << CommonHelper::utf8ToStdString("M_FindByInterfaceDAO.save failed");
|
|
|
|
LOG(INFO) << rm.rMsg;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DelByInterface::saveToDao()
|
|
|
|
{
|
|
|
|
using namespace DBPlatformSpace;
|
|
|
|
M_DelByInterfaceDAO* pDao = dynamic_cast<M_DelByInterfaceDAO*>(_pDBDAO);
|
|
|
|
|
|
|
|
if (pDao == nullptr)
|
|
|
|
{
|
|
|
|
pDao = new M_DelByInterfaceDAO();
|
|
|
|
_pDBDAO = pDao;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDao->_name = CommonHelper::qstringToStdString(getName());
|
|
|
|
pDao->_bExport = _bExport;
|
|
|
|
pDao->_description = CommonHelper::qstringToStdString(_description);
|
|
|
|
pDao->_paraList = CommonHelper::qstringToStdString(_paraList);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DelByInterface::saveSelf()
|
|
|
|
{
|
|
|
|
using namespace DBPlatformSpace;
|
|
|
|
ResultMsg rm;
|
|
|
|
M_DelByInterfaceDAO* pDao = dynamic_cast<M_DelByInterfaceDAO*>(_pDBDAO);
|
2025-06-23 18:01:09 +08:00
|
|
|
/*备份DAO数据*/
|
2025-06-23 10:41:33 +08:00
|
|
|
M_DelByInterfaceDAO oldDaoData;
|
2025-06-23 21:06:10 +08:00
|
|
|
// backupDAOData(*pDao, oldDaoData);
|
2025-06-23 10:41:33 +08:00
|
|
|
if (pDao == nullptr)
|
|
|
|
{
|
|
|
|
pDao = new M_DelByInterfaceDAO();
|
|
|
|
}
|
|
|
|
saveToDao();
|
|
|
|
rm = pDao->save();
|
|
|
|
if (rm.rCode == 0)
|
|
|
|
{
|
|
|
|
LOG(INFO) << CommonHelper::utf8ToStdString("DelByInterface.save success");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2025-06-23 21:06:10 +08:00
|
|
|
// restoreData(oldDaoData, *this);
|
2025-06-23 10:41:33 +08:00
|
|
|
LOG(INFO) << CommonHelper::utf8ToStdString("M_FindByInterfaceDAO.save failed");
|
|
|
|
LOG(INFO) << rm.rMsg;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DelByInterface::toJson(json& jsonObj, bool)
|
|
|
|
{
|
|
|
|
jsonObj["id"] = _id;
|
|
|
|
jsonObj["name"] = CommonHelper::qstringToUtf8(_name);
|
|
|
|
jsonObj["description"] = CommonHelper::qstringToUtf8(_description);
|
|
|
|
jsonObj["beExport"] = _bExport == 1 ? true : false;
|
|
|
|
jsonObj["paramList"] = CommonHelper::qstringToUtf8(_paraList);
|
|
|
|
}
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
/*获取新的属性*/
|
2025-06-23 10:41:33 +08:00
|
|
|
void DelByInterface::getNewProperty(json& parameter, QVariantMap& valueMap)
|
|
|
|
{
|
|
|
|
auto data = parameter["data"];
|
|
|
|
|
2025-06-23 18:01:09 +08:00
|
|
|
//接口名称
|
2025-06-23 10:41:33 +08:00
|
|
|
valueMap.insert("name", CommonHelper::utf8ToQString(data["name"]));
|
2025-06-23 18:01:09 +08:00
|
|
|
//描述
|
2025-06-23 10:41:33 +08:00
|
|
|
valueMap.insert("description", CommonHelper::utf8ToQString(data["description"]));
|
|
|
|
//IsExport
|
|
|
|
if (!data["beExport"].is_null())
|
|
|
|
{
|
|
|
|
valueMap.insert("IsExport", (int)(data["beExport"]));
|
|
|
|
}
|
2025-06-23 18:01:09 +08:00
|
|
|
//参数列表
|
2025-06-23 10:41:33 +08:00
|
|
|
if (!data["paramList"].is_null())
|
|
|
|
{
|
|
|
|
valueMap.insert("paralist", CommonHelper::utf8ToQString(data["paramList"]));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void DelByInterface::setNewData(json& parameter)
|
|
|
|
{
|
|
|
|
QVariantMap newValues;
|
|
|
|
getNewProperty(parameter, newValues);
|
|
|
|
setProperties(newValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DelByInterface::setFileData(FileGenerate* generator, QStringList flag)
|
|
|
|
{
|
|
|
|
DataManager& mgr = GetDataRoot();
|
|
|
|
QStringList para = _paraList.split("#");
|
|
|
|
QString paraShow;
|
|
|
|
for (int i = 0; i < para.size(); i++)
|
|
|
|
{
|
|
|
|
QString curStr = para.at(i);
|
|
|
|
int pos = curStr.indexOf(",");
|
|
|
|
QString right = curStr.right(curStr.size() - pos - 1);
|
|
|
|
int id = curStr.left(pos).toInt();
|
2025-06-23 18:01:09 +08:00
|
|
|
//查找id对应的名称
|
2025-06-23 10:41:33 +08:00
|
|
|
DataAttribute* pdata = qobject_cast<DataAttribute*>(mgr.findObjectById(DataManager::DataType::dataAttribute, id));
|
|
|
|
paraShow += (pdata->_strDisplayName + right) + " ";
|
|
|
|
}
|
|
|
|
if (flag.size() == 2)
|
|
|
|
{
|
|
|
|
generator->interfaceTableData.append(new CCS_Report::CCSModelDataSet(flag[0], flag[1], _name, paraShow, ""));
|
|
|
|
}
|
|
|
|
else if (flag.size() == 3)
|
|
|
|
{
|
|
|
|
generator->interfaceTableData111.append(new CCS_Report::CCSModelDataSet(flag[0], flag[1], flag[2], _name, paraShow, ""));
|
|
|
|
}
|
|
|
|
}
|