205 lines
5.6 KiB
C++
205 lines
5.6 KiB
C++
|
#include "FindByInterface.h"
|
|||
|
#include "M_FindByInterfaceDAO.h"
|
|||
|
#include "DataManager.h"
|
|||
|
#include "DataAttribute.h"
|
|||
|
|
|||
|
FindByInterface::FindByInterface()
|
|||
|
{}
|
|||
|
|
|||
|
FindByInterface::~FindByInterface()
|
|||
|
{}
|
|||
|
|
|||
|
void static backupDAOData(DBPlatformSpace::M_FindByInterfaceDAO& src, DBPlatformSpace::M_FindByInterfaceDAO& dst)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void static restoreData(DBPlatformSpace::M_FindByInterfaceDAO& src, FindByInterface& dst)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void FindByInterface::saveToDao()
|
|||
|
{
|
|||
|
using namespace DBPlatformSpace;
|
|||
|
M_FindByInterfaceDAO* pDao = dynamic_cast<M_FindByInterfaceDAO*>(_pDBDAO);
|
|||
|
|
|||
|
if (pDao == nullptr)
|
|||
|
{
|
|||
|
pDao = new M_FindByInterfaceDAO();
|
|||
|
_pDBDAO = pDao;
|
|||
|
}
|
|||
|
|
|||
|
pDao->_name = CommonHelper::qstringToStdString(getName()); //<2F><><EFBFBD>Ʊ<EFBFBD>ʶ
|
|||
|
pDao->_type = _interfaceType;
|
|||
|
pDao->_sortType = _sortType;
|
|||
|
pDao->_description = CommonHelper::qstringToStdString(_description);
|
|||
|
pDao->_bExport = _bIsExport;
|
|||
|
pDao->_paraList = CommonHelper::qstringToStdString(_paraList);
|
|||
|
pDao->_sortAttributeList = CommonHelper::qstringToStdString(_sortAtrributeList);
|
|||
|
}
|
|||
|
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>*/
|
|||
|
void FindByInterface::loadData(DBPlatformSpace::DAO* pDao)
|
|||
|
{
|
|||
|
using namespace DBPlatformSpace;
|
|||
|
_pDBDAO = pDao;
|
|||
|
M_FindByInterfaceDAO* pFindDAO = dynamic_cast<M_FindByInterfaceDAO*>(pDao);
|
|||
|
_id = pFindDAO->_ID;
|
|||
|
_bIsExport = pFindDAO->_bExport;
|
|||
|
_name = CommonHelper::stringToQstring(pFindDAO->_name);
|
|||
|
_description = CommonHelper::stringToQstring(pFindDAO->_description);
|
|||
|
_sortType = pFindDAO->_sortType;
|
|||
|
_classID = pFindDAO->_t_M_EntityTableID;
|
|||
|
_paraList = CommonHelper::stringToQstring(pFindDAO->_paraList);
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
_sortAtrributeList = CommonHelper::stringToQstring(pFindDAO->_sortAttributeList);
|
|||
|
}
|
|||
|
|
|||
|
/*<2A><>ȡ<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
void FindByInterface::getNewProperty(json& parameter, QVariantMap& valueMap)
|
|||
|
{
|
|||
|
auto data = parameter["data"];
|
|||
|
|
|||
|
//<2F>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
valueMap.insert("name", CommonHelper::utf8ToQString(data["name"]));
|
|||
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
valueMap.insert("description", CommonHelper::utf8ToQString(data["description"]));
|
|||
|
//interfaceType
|
|||
|
valueMap.insert("Interfacetype", (int)(data["type"]));
|
|||
|
//sortType
|
|||
|
if (!data["sortType"].is_null())
|
|||
|
{
|
|||
|
valueMap.insert("sortType", (int)(data["sortType"]));
|
|||
|
}
|
|||
|
//IsExport
|
|||
|
if (!data["beExport"].is_null())
|
|||
|
{
|
|||
|
valueMap.insert("IsExport", (int)(data["beExport"]));
|
|||
|
}
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|||
|
if (!data["paramList"].is_null())
|
|||
|
{
|
|||
|
valueMap.insert("paralist", CommonHelper::utf8ToQString(data["paramList"]));
|
|||
|
}
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sortAttributes
|
|||
|
if (!data["sortList"].is_null())
|
|||
|
{
|
|||
|
/*vector<int>*/auto list = data["sortList"];
|
|||
|
QStringList sortAttribute;
|
|||
|
for (auto j : list)
|
|||
|
{
|
|||
|
sortAttribute.append(QString::number(j.get<int>()));
|
|||
|
}
|
|||
|
|
|||
|
QString sortList = sortAttribute.join(",");
|
|||
|
valueMap.insert("sortAttribute", sortList);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void FindByInterface::toJson(json& jsonObj, bool)
|
|||
|
{
|
|||
|
jsonObj["id"] = _id;
|
|||
|
jsonObj["name"] = CommonHelper::qstringToUtf8(_name);
|
|||
|
jsonObj["description"] = CommonHelper::qstringToUtf8(_description);
|
|||
|
jsonObj["type"] = _interfaceType;
|
|||
|
jsonObj["beExport"] = _bIsExport == 1 ? true : false;
|
|||
|
jsonObj["paramList"] = CommonHelper::qstringToUtf8(_paraList);
|
|||
|
jsonObj["sortType"] = _sortType;
|
|||
|
if (_sortAtrributeList.isEmpty())
|
|||
|
{
|
|||
|
jsonObj["sortList"] = json::array();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
QStringList sortlist = _sortAtrributeList.split(",");
|
|||
|
for (int i = 0; i < sortlist.size(); i++)
|
|||
|
{
|
|||
|
QString id = sortlist.at(i);
|
|||
|
jsonObj["sortList"].push_back(id.toInt());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// data["sortList"] = json::parse(dstData._sortAtrributeList.begin(), dstData._sortAtrributeList.end());
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void FindByInterface::setNewData(json& parameter)
|
|||
|
{
|
|||
|
QVariantMap newValues;
|
|||
|
getNewProperty(parameter, newValues);
|
|||
|
setProperties(newValues);
|
|||
|
}
|
|||
|
|
|||
|
bool FindByInterface::deleteSelf()
|
|||
|
{
|
|||
|
using namespace DBPlatformSpace;
|
|||
|
ResultMsg rm;
|
|||
|
M_FindByInterfaceDAO* pDao = dynamic_cast<M_FindByInterfaceDAO*>(_pDBDAO);
|
|||
|
rm = pDao->delself();
|
|||
|
if (rm.rCode == 0)
|
|||
|
{
|
|||
|
LOG(INFO) << CommonHelper::utf8ToStdString("M_FindByInterfaceDAO.delself success");
|
|||
|
return true;
|
|||
|
}
|
|||
|
LOG(INFO) << CommonHelper::utf8ToStdString("M_FindByInterfaceDAO.delself failed");
|
|||
|
LOG(INFO) << rm.rMsg;
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
bool FindByInterface::saveSelf()
|
|||
|
{
|
|||
|
using namespace DBPlatformSpace;
|
|||
|
ResultMsg rm;
|
|||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>*/
|
|||
|
M_FindByInterfaceDAO* pDao = dynamic_cast<M_FindByInterfaceDAO*>(_pDBDAO);
|
|||
|
/*<2A><><EFBFBD><EFBFBD>DAO<41><4F><EFBFBD><EFBFBD>*/
|
|||
|
M_FindByInterfaceDAO oldDaoData;
|
|||
|
backupDAOData(*pDao, oldDaoData);
|
|||
|
if (pDao == nullptr)
|
|||
|
{
|
|||
|
pDao = new M_FindByInterfaceDAO();
|
|||
|
}
|
|||
|
|
|||
|
saveToDao();
|
|||
|
rm = pDao->save();
|
|||
|
if (rm.rCode == 0)
|
|||
|
{
|
|||
|
LOG(INFO) << CommonHelper::utf8ToStdString("M_FindByInterfaceDAO.save success");
|
|||
|
return true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
restoreData(oldDaoData, *this);
|
|||
|
LOG(INFO) << CommonHelper::utf8ToStdString("M_FindByInterfaceDAO.save failed");
|
|||
|
LOG(INFO) << rm.rMsg;
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void FindByInterface::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();
|
|||
|
//<2F><><EFBFBD><EFBFBD>id<69><64>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
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, CommonHelper::convertInterfaceTypeToStr(_interfaceType)));
|
|||
|
}
|
|||
|
else if (flag.size() == 3)
|
|||
|
{
|
|||
|
generator->interfaceTableData111.append(new CCS_Report::CCSModelDataSet(flag[0], flag[1], flag[2], _name, paraShow, CommonHelper::convertInterfaceTypeToStr(_interfaceType)));
|
|||
|
}
|
|||
|
}
|