diff --git a/Interfaces/AAA/Accounting_Defs.hpp b/Interfaces/AAA/Accounting_Defs.hpp index 783bc632..fb7e235f 100644 --- a/Interfaces/AAA/Accounting_Defs.hpp +++ b/Interfaces/AAA/Accounting_Defs.hpp @@ -74,12 +74,23 @@ TARGOMAN_DEFINE_ENUM(enuVoucherItemProcessStatus, Removed = 'R', ); +TARGOMAN_DEFINE_ENUM(enuAssetHistoryReportStepUnit, + Minute = 'I', + Hour = 'H', + Day = 'D', +// Week = 'W', +// Month = 'M', +// Year = 'Y', + ); + } //namespace Targoman::API::AAA -TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuVoucherType); // -> TAPI_REGISTER_TARGOMAN_ENUM() in Accounting_Interfaces.cpp -TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuVoucherStatus) // -> TAPI_REGISTER_TARGOMAN_ENUM() in Accounting_Interfaces.cpp -TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuDiscountType) // -> TAPI_REGISTER_TARGOMAN_ENUM() in Accounting_Interfaces.cpp -TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuVoucherItemProcessStatus) // -> TAPI_REGISTER_TARGOMAN_ENUM() in Accounting_Interfaces.cpp +//TAPI_REGISTER_TARGOMAN_ENUM() in Accounting_Interfaces.cpp: +TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuVoucherType); +TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuVoucherStatus); +TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuDiscountType); +TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuVoucherItemProcessStatus); +TAPI_DECLARE_METATYPE_ENUM(Targoman::API::AAA, enuAssetHistoryReportStepUnit); namespace Targoman::API::AAA { @@ -273,6 +284,15 @@ namespace tblAccountAssetUsageBase { } } +namespace tblAccountAssetUsageHistoryBase { + constexpr char Name[] = "tblAccountAssetUsageHistory"; + + namespace Fields { + TARGOMAN_CREATE_CONSTEXPR(ush_uasID); + TARGOMAN_CREATE_CONSTEXPR(ushLastDateTime); + } +} + ///@TODO: max usage count (user, system) ///@TODO: CodeCommentMark namespace tblAccountCouponsBase { @@ -855,6 +875,39 @@ namespace tblAccountAssetUsageBase { ); } +namespace tblAccountAssetUsageHistoryBase { + namespace Relation { +// constexpr char AAA[] = "aaa"; + } + + namespace Private { + const QList ORMFields = { + //ColName Type Validation Default UpBy Sort Filter Self Virt PK + { Fields::ush_uasID, ORM_PRIMARYKEY_64 }, + { Fields::ushLastDateTime, S(TAPI::DateTime_t), QFV, QRequired, UPAdmin }, + }; + + inline const QList Relations(Q_DECL_UNUSED const QString& _schema) { + return { + //Col Reference Table ForeignCol Rename LeftJoin + { Fields::ush_uasID, R(_schema, tblAccountUserAssetsBase::Name), tblAccountUserAssetsBase::Fields::uasID }, + }; + }; + + const QList Indexes = { + }; + + } //namespace Private + +#define SF_tblAccountAssetUsageHistoryBase_DTO \ + SF_ORM_PRIMARYKEY_64 (ush_uasID), \ + SF_DateTime_t (ushLastDateTime) + + TAPI_DEFINE_STRUCT(DTO, + SF_tblAccountAssetUsageHistoryBase_DTO + ); +} + namespace tblAccountCouponsBase { namespace Relation { // constexpr char AAA[] = "aaa"; diff --git a/Interfaces/AAA/Accounting_Interfaces.cpp b/Interfaces/AAA/Accounting_Interfaces.cpp index 41c37bbb..8143c3a5 100644 --- a/Interfaces/AAA/Accounting_Interfaces.cpp +++ b/Interfaces/AAA/Accounting_Interfaces.cpp @@ -37,6 +37,7 @@ TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuVoucherType); TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuVoucherStatus); TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuDiscountType); TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuVoucherItemProcessStatus); +TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuAssetHistoryReportStepUnit); TAPI_REGISTER_METATYPE_TYPE_STRUCT( /* namespace */ Targoman::API::AAA, @@ -994,6 +995,315 @@ intfAccountAssetUsage<_itmplIsTokenBase>::intfAccountAssetUsage( // , intfAccountORMBase<_itmplIsTokenBase>() { ; } +/******************************************************************/ +/******************************************************************/ +/******************************************************************/ +baseintfAccountAssetUsageHistory::baseintfAccountAssetUsageHistory( + const QString& _schema, + const QList& _cols, + const QList& _relations, + const QList& _indexes +) : + intfSQLBasedModule( + _schema, + tblAccountAssetUsageHistoryBase::Name, + _cols, + _relations, + _indexes + ) + // , intfAccountORMBase<_itmplIsTokenBase>() +{ ; } + +/* +SELECT + 1 + DATEDIFF(columnDate, @start_date) DIV 7 AS weekNumber + , @start_date + INTERVAL (DATEDIFF(columnDate, @start_date) DIV 7) WEEK + AS week_start_date + , MIN(columnDate) AS actual_first_date + , MAX(columnDate) AS actual_last_date + , SUM(otherColumn) + , AVG(otherColumn) + --- +FROM + tableX +WHERE + columnDate >= @start_date +GROUP BY + DATEDIFF(columnDate, @start_date) DIV 7 ; +*/ +TAPI::stuTable baseintfAccountAssetUsageHistory::report( + INTFAPICALLBOOM_IMPL &APICALLBOOM_PARAM, + quint64 _currentActorID, + quint64 _pageIndex, + quint16 _pageSize, + bool _reportCount, + quint64 _assetID, + TAPI::DateTime_t _fromDate, + TAPI::DateTime_t _toDate, + quint16 _step, + enuAssetHistoryReportStepUnit::Type _stepUnit +) { + QStringList QueryStringParts; + QueryStringParts.append("SELECT"); + + //-- + QString StrFromDate = _fromDate.isValid() + ? _fromDate.toString("yyyy-MM-dd hh:mm:ss") + : ""; + + QString StrToDate = _toDate.isValid() + ? _toDate.toString("yyyy-MM-dd hh:mm:ss") + : ""; + + QString DateDiffPart; + if (_stepUnit == enuAssetHistoryReportStepUnit::Minute) { + if (_fromDate.isValid()) + DateDiffPart = QString("1 + TIME_TO_SEC(TIMEDIFF(ushLastDateTime, '%1')) DIV %2") + .arg(StrFromDate) + .arg(_step * 60); + else + DateDiffPart = QString("1 + TIME_TO_SEC(TIMEDIFF(NOW(), ushLastDateTime)) DIV %1") + .arg(_step * 60); + } else if (_stepUnit == enuAssetHistoryReportStepUnit::Hour) { + if (_fromDate.isValid()) + DateDiffPart = QString("1 + TIME_TO_SEC(TIMEDIFF(ushLastDateTime, '%1')) DIV %2") + .arg(StrFromDate) + .arg(_step * 60 * 60); + else + DateDiffPart = QString("1 + TIME_TO_SEC(TIMEDIFF(NOW(), ushLastDateTime)) DIV %1") + .arg(_step * 60 * 60); + } else if (_stepUnit == enuAssetHistoryReportStepUnit::Day) { + if (_fromDate.isValid()) + DateDiffPart = QString("1 + DATEDIFF(ushLastDateTime, '%1') DIV %2") + .arg(StrFromDate) + .arg(_step); + else + DateDiffPart = QString("1 + DATEDIFF(NOW(), ushLastDateTime) DIV %1") + .arg(_step); + } + QueryStringParts.append(QString("%1 AS counter").arg(DateDiffPart)); + + //-- + QueryStringParts.append(", COUNT(*) AS pointsCount"); + QueryStringParts.append(", MIN(ushLastDateTime) AS minDate"); + QueryStringParts.append(", MAX(ushLastDateTime) AS maxDate"); + + //-- + foreach (auto CreditField, this->creditFieldNames()) { + QueryStringParts.append(QString(", SUM(%1) AS %1").arg(CreditField)); + } + + //-- + QueryStringParts.append("FROM tblAccountAssetUsageHistory ush"); + QueryStringParts.append("INNER JOIN tblAccountUserAssets uas"); + QueryStringParts.append("ON uas.uasID = ush.ush_uasID"); + + //-- + QStringList WhereParts; + + if (Authorization::hasPriv(APICALLBOOM_PARAM, this->privOn(EHTTP_GET, this->moduleBaseName())) == false) + WhereParts.append(QString("uas_actorID = %1").arg(_currentActorID)); + + if (_assetID > 0) + WhereParts.append(QString("ush_uasID = %1").arg(_assetID)); + + if (_fromDate.isValid()) + WhereParts.append(QString("ushLastDateTime >= '%1'").arg(StrFromDate)); + + if (_toDate.isValid()) + WhereParts.append(QString("ushLastDateTime <= '%1'").arg(StrToDate)); + + if (WhereParts.isEmpty() == false) { + QueryStringParts.append("WHERE"); + QueryStringParts.append(WhereParts.join("\n AND ")); + } + + //-- + QueryStringParts.append(QString("GROUP BY %1").arg(DateDiffPart)); + + //-- + QueryStringParts.append("ORDER BY MIN(ushLastDateTime)"); + + //-- + QString QueryString = QueryStringParts.join("\n"); + + TAPI::stuTable Result; + Result.HasCount = false; + + if (_reportCount) { + QString CountingQueryString = QString("SELECT COUNT(*) AS cnt FROM (\n%1\n) qry").arg(QueryString); + QJsonDocument ResultTotalRows = this->execQuery(APICALLBOOM_PARAM, CountingQueryString).toJson(true); + + Result.HasCount = true; + Result.TotalRows = ResultTotalRows + .toVariant() + .toMap()["cnt"] + .toULongLong(); + + } + + if ((_pageIndex > 0) || (_pageSize > 0)) { + if (_pageSize == 0) + _pageSize = 100; + + QueryString += QString("\nLIMIT %1,%2").arg(_pageIndex * _pageSize).arg(_pageSize); + } + + QJsonDocument ResultRows = this->execQuery(APICALLBOOM_PARAM, QueryString).toJson(false); + + Result.Rows = ResultRows + .toVariant() + .toList(); + + if (_pageSize > 0) + Result.PageCount = ceil((double)Result.TotalRows / _pageSize); + else + Result.PageCount = 1; + + Result.HasMore = (Result.PageCount > (_pageIndex + 1)); + + return Result; +} + +/******************************************************************/ +baseintfAccountAssetUsageHistory_USER::baseintfAccountAssetUsageHistory_USER( + const QString& _schema, + const QList& _cols, + const QList& _relations, + const QList& _indexes +) : + baseintfAccountAssetUsageHistory( + _schema, + _cols, + _relations, + _indexes + ) + // , intfAccountORMBase<_itmplIsTokenBase>() +{ ; } + +QVariant IMPL_ORMGET_USER(baseintfAccountAssetUsageHistory_USER) { + quint64 CurrentActorID = APICALLBOOM_PARAM.getActorID(); + + if (Authorization::hasPriv(APICALLBOOM_PARAM, this->privOn(EHTTP_GET, this->moduleBaseName())) == false) + this->setSelfFilters({{ tblAccountUserAssetsBase::Fields::uas_actorID, CurrentActorID }}, _filters); + + return this->Select(GET_METHOD_ARGS_CALL_VALUES); +} + +QVariant IMPL_REST_GET_OR_POST(baseintfAccountAssetUsageHistory_USER, report, ( + APICALLBOOM_TYPE_JWT_USER_IMPL &APICALLBOOM_PARAM, + quint64 _pageIndex, + quint16 _pageSize, + bool _reportCount, + quint64 _assetID, + TAPI::DateTime_t _fromDate, + TAPI::DateTime_t _toDate, + quint16 _step, + Targoman::API::AAA::enuAssetHistoryReportStepUnit::Type _stepUnit +)) { + quint64 CurrentActorID = APICALLBOOM_PARAM.getActorID(); + + bool CompactList = APICALLBOOM_PARAM.requestHeader("compact-list", false).toBool(); + + return this->report( + APICALLBOOM_PARAM, + CurrentActorID, + _pageIndex, + _pageSize, + _reportCount, + _assetID, + _fromDate, + _toDate, + _step, + _stepUnit + ).toVariant(CompactList); +} + +/******************************************************************/ +baseintfAccountAssetUsageHistory_API::baseintfAccountAssetUsageHistory_API( + const QString& _schema, + const QList& _cols, + const QList& _relations, + const QList& _indexes +) : + baseintfAccountAssetUsageHistory( + _schema, + _cols, + _relations, + _indexes + ) + // , intfAccountORMBase<_itmplIsTokenBase>() +{ ; } + +QVariant IMPL_REST_GET(baseintfAccountAssetUsageHistory_API, , ( + APICALLBOOM_TYPE_JWT_USER_IMPL &APICALLBOOM_PARAM, + QString _apiToken, + TAPI::PKsByPath_t _pksByPath, + quint64 _pageIndex, + quint16 _pageSize, + TAPI::Cols_t _cols, + TAPI::Filter_t _filters, + TAPI::OrderBy_t _orderBy, + TAPI::GroupBy_t _groupBy, + bool _reportCount +)) { + bool _translate = true; + + quint64 CurrentActorID = checkAPITokenOwner(APICALLBOOM_PARAM, _apiToken); + +// if (Authorization::hasPriv(APICALLBOOM_PARAM, this->privOn(EHTTP_GET, this->moduleBaseName())) == false) + this->setSelfFilters({{ tblAccountUserAssetsBase::Fields::uas_actorID, CurrentActorID }}, _filters); + + return this->Select(GET_METHOD_ARGS_CALL_VALUES); +} + +QVariant IMPL_REST_GET_OR_POST(baseintfAccountAssetUsageHistory_API, report, ( + APICALLBOOM_TYPE_JWT_USER_IMPL &APICALLBOOM_PARAM, + QString _apiToken, + quint64 _pageIndex, + quint16 _pageSize, + bool _reportCount, + quint64 _assetID, + TAPI::DateTime_t _fromDate, + TAPI::DateTime_t _toDate, + quint16 _step, + Targoman::API::AAA::enuAssetHistoryReportStepUnit::Type _stepUnit +)) { + quint64 CurrentActorID = checkAPITokenOwner(APICALLBOOM_PARAM, _apiToken); + + bool CompactList = APICALLBOOM_PARAM.requestHeader("compact-list", false).toBool(); + + return this->report( + APICALLBOOM_PARAM, + CurrentActorID, + _pageIndex, + _pageSize, + _reportCount, + _assetID, + _fromDate, + _toDate, + _step, + _stepUnit + ).toVariant(CompactList); +} + +/******************************************************************/ +template +intfAccountAssetUsageHistory<_itmplIsTokenBase>::intfAccountAssetUsageHistory( + const QString& _schema, + const QList& _exclusiveCols, + const QList& _exclusiveRelations, + const QList& _exclusiveIndexes +) : + std::conditional<_itmplIsTokenBase, baseintfAccountAssetUsageHistory_API, baseintfAccountAssetUsageHistory_USER>::type( + _schema, + tblAccountAssetUsageHistoryBase::Private::ORMFields + _exclusiveCols, + tblAccountAssetUsageHistoryBase::Private::Relations(_schema) + _exclusiveRelations, + tblAccountAssetUsageHistoryBase::Private::Indexes + _exclusiveIndexes + ) + // , intfAccountORMBase<_itmplIsTokenBase>() +{ ; } + /******************************************************************/ /******************************************************************/ /******************************************************************/ @@ -1209,6 +1519,7 @@ stuAssetItemReq_t& stuAssetItemReq_t::fromVariant(const QVariant& _value, const template class intfAccountUserAssets; //template class intfAccountUserAssetsFiles; template class intfAccountAssetUsage; +template class intfAccountAssetUsageHistory; //template class intfAccountCoupons; //template class intfAccountPrizes; @@ -1222,6 +1533,7 @@ template class intfAccountAssetUsage; template class intfAccountUserAssets; //template class intfAccountUserAssetsFiles; template class intfAccountAssetUsage; +template class intfAccountAssetUsageHistory; //template class intfAccountCoupons; //template class intfAccountPrizes; diff --git a/Interfaces/AAA/Accounting_Interfaces.h b/Interfaces/AAA/Accounting_Interfaces.h index 166536c7..bf8a5b57 100644 --- a/Interfaces/AAA/Accounting_Interfaces.h +++ b/Interfaces/AAA/Accounting_Interfaces.h @@ -488,6 +488,132 @@ class intfAccountAssetUsage : public std::conditional<_itmplIsTokenBase, baseint }; +/******************************************************/ +/******************************************************/ +/******************************************************/ +class baseintfAccountAssetUsageHistory : public intfSQLBasedModule +{ +// Q _OBJECT + +public: + baseintfAccountAssetUsageHistory(const QString& _schema, + const QList& _cols = {}, + const QList& _relations = {}, + const QList& _indexes = {}); + +protected: + virtual QStringList creditFieldNames() = 0; + + TAPI::stuTable report( + INTFAPICALLBOOM_DECL &APICALLBOOM_PARAM, + quint64 _currentActorID, + quint64 _pageIndex = 0, + quint16 _pageSize = 100, + bool _reportCount = true, + quint64 _assetID = 0, + TAPI::DateTime_t _fromDate = {}, + TAPI::DateTime_t _toDate = {}, + quint16 _step = 1, + Targoman::API::AAA::enuAssetHistoryReportStepUnit::Type _stepUnit = enuAssetHistoryReportStepUnit::Day + ); +}; + +/******************************************************/ +class baseintfAccountAssetUsageHistory_USER : public baseintfAccountAssetUsageHistory +{ + Q_OBJECT + ACCORM_TOKENBASE_TYPES(false) + +public: + baseintfAccountAssetUsageHistory_USER(const QString& _schema, + const QList& _cols = {}, + const QList& _relations = {}, + const QList& _indexes = {}); + +private slots: +// QVariant ORMGET_TOKENBASE("Get User Asset Usage") + QVariant ORMGET_USER("Get User Asset Usage History") + + QVariant REST_GET_OR_POST( + report, + ( + APICALLBOOM_TYPE_JWT_USER_DECL &APICALLBOOM_PARAM, + quint64 _pageIndex = 0, + quint16 _pageSize = 100, + bool _reportCount = true, + quint64 _assetID = 0, + TAPI::DateTime_t _fromDate = {}, + TAPI::DateTime_t _toDate = {}, + quint16 _step = 1, + Targoman::API::AAA::enuAssetHistoryReportStepUnit::Type _stepUnit = enuAssetHistoryReportStepUnit::Day + ), + "Get User Asset Usage History Report" + ); +}; + +/******************************************************/ +class baseintfAccountAssetUsageHistory_API : public baseintfAccountAssetUsageHistory +{ + Q_OBJECT + ACCORM_TOKENBASE_TYPES(true) + +public: + baseintfAccountAssetUsageHistory_API(const QString& _schema, + const QList& _cols = {}, + const QList& _relations = {}, + const QList& _indexes = {}); + +private slots: +// QVariant ORMGET_TOKENBASE("Get User Asset Usage") +// QVariant ORMGET_API("Get User Asset Usage") + QVariant REST_GET( + , + ( + APICALLBOOM_TYPE_JWT_USER_DECL &APICALLBOOM_PARAM, + QString _apiToken, + TAPI::PKsByPath_t _pksByPath = {}, + quint64 _pageIndex = 0, + quint16 _pageSize = 20, + TAPI::Cols_t _cols = {}, + TAPI::Filter_t _filters = {}, + TAPI::OrderBy_t _orderBy = {}, + TAPI::GroupBy_t _groupBy = {}, + bool _reportCount = true + ), + "Get User Asset Usage History" + ); + + QVariant REST_GET_OR_POST( + report, + ( + APICALLBOOM_TYPE_JWT_USER_DECL &APICALLBOOM_PARAM, + QString _apiToken, + quint64 _pageIndex = 0, + quint16 _pageSize = 100, + bool _reportCount = true, + quint64 _assetID = 0, + TAPI::DateTime_t _fromDate = {}, + TAPI::DateTime_t _toDate = {}, + quint16 _step = 1, + Targoman::API::AAA::enuAssetHistoryReportStepUnit::Type _stepUnit = enuAssetHistoryReportStepUnit::Day + ), + "Get User Asset Usage History Report" + ); +}; + +/******************************************************/ +template +class intfAccountAssetUsageHistory : public std::conditional<_itmplIsTokenBase, baseintfAccountAssetUsageHistory_API, baseintfAccountAssetUsageHistory_USER>::type //intfSQLBasedModule// , public intfAccountORMBase<_itmplIsTokenBase> +{ +public: + intfAccountAssetUsageHistory(//bool _isTokenBase, + const QString& _schema, + const QList& _exclusiveCols = {}, + const QList& _exclusiveRelations = {}, + const QList& _exclusiveIndexes = {}); + +}; + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/Interfaces/AAA/intfAccountingBasedModule.cpp b/Interfaces/AAA/intfAccountingBasedModule.cpp index e8dbaf61..5836f978 100644 --- a/Interfaces/AAA/intfAccountingBasedModule.cpp +++ b/Interfaces/AAA/intfAccountingBasedModule.cpp @@ -109,18 +109,19 @@ baseintfAccountingBasedModule* serviceAccounting(const QString& _serviceName) { |** baseintfAccountingBasedModule ******************************************************************| \***************************************************************************************************/ baseintfAccountingBasedModule::baseintfAccountingBasedModule( - const QString &_module, - const QString &_schema, - AssetUsageLimitsCols_t _AssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - baseintfAccountUserAssets *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - baseintfAccountAssetUsage *_assetUsages, - intfAccountCoupons *_discounts, - intfAccountPrizes *_prizes + const QString &_module, + const QString &_schema, + AssetUsageLimitsCols_t _AssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + baseintfAccountUserAssets *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + baseintfAccountAssetUsage *_assetUsage, + baseintfAccountAssetUsageHistory *_assetUsageHistory, + intfAccountCoupons *_discounts, + intfAccountPrizes *_prizes ) : intfSQLBasedModule(_module, _schema), ServiceName(_schema), @@ -130,7 +131,8 @@ baseintfAccountingBasedModule::baseintfAccountingBasedModule( AccountSaleablesFiles(_saleablesFiles), AccountUserAssets(_userAssets), AccountUserAssetsFiles(_userAssetsFiles), - AccountAssetUsages(_assetUsages), + AccountAssetUsage(_assetUsage), + AccountAssetUsageHistory(_assetUsageHistory), AccountCoupons(_discounts), AccountPrizes(_prizes), AssetUsageLimitsCols(_AssetUsageLimitsCols) @@ -1729,18 +1731,19 @@ bool IMPL_REST_POST(baseintfAccountingBasedModule, cancelVoucherItem, ( |** baseintfAccountingBasedModule_USER *************************************************************| \***************************************************************************************************/ baseintfAccountingBasedModule_USER::baseintfAccountingBasedModule_USER( - const QString &_module, - const QString &_schema, - AssetUsageLimitsCols_t _AssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - intfAccountUserAssets *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage *_assetUsages, - intfAccountCoupons *_discounts, - intfAccountPrizes *_prizes + const QString &_module, + const QString &_schema, + AssetUsageLimitsCols_t _AssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + intfAccountUserAssets *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + intfAccountAssetUsage *_assetUsage, + intfAccountAssetUsageHistory *_assetUsageHistory, + intfAccountCoupons *_discounts, + intfAccountPrizes *_prizes ) : baseintfAccountingBasedModule( _module, @@ -1752,7 +1755,8 @@ baseintfAccountingBasedModule_USER::baseintfAccountingBasedModule_USER( _saleablesFiles, _userAssets, _userAssetsFiles, - _assetUsages, + _assetUsage, + _assetUsageHistory, _discounts, _prizes ) { ; } @@ -1788,18 +1792,19 @@ Targoman::API::AAA::stuBasketActionResult IMPL_REST_POST(baseintfAccountingBased |** baseintfAccountingBasedModule_API **************************************************************| \***************************************************************************************************/ baseintfAccountingBasedModule_API::baseintfAccountingBasedModule_API( - const QString &_module, - const QString &_schema, - AssetUsageLimitsCols_t _AssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - intfAccountUserAssets *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage *_assetUsages, - intfAccountCoupons *_discounts, - intfAccountPrizes *_prizes + const QString &_module, + const QString &_schema, + AssetUsageLimitsCols_t _AssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + intfAccountUserAssets *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + intfAccountAssetUsage *_assetUsage, + intfAccountAssetUsageHistory *_assetUsageHistory, + intfAccountCoupons *_discounts, + intfAccountPrizes *_prizes ) : baseintfAccountingBasedModule( _module, @@ -1811,7 +1816,8 @@ baseintfAccountingBasedModule_API::baseintfAccountingBasedModule_API( _saleablesFiles, _userAssets, _userAssetsFiles, - _assetUsages, + _assetUsage, + _assetUsageHistory, _discounts, _prizes ) { ; } @@ -1874,19 +1880,19 @@ Targoman::API::AAA::stuBasketActionResult IMPL_REST_POST(baseintfAccountingBased \***************************************************************************************************/ template intfAccountingBasedModule<_itmplIsTokenBase>::intfAccountingBasedModule( - const QString &_module, - const QString &_schema, -// bool _isTokenBase, - AssetUsageLimitsCols_t _AssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsages, - intfAccountCoupons *_discounts, - intfAccountPrizes *_prizes + const QString &_module, + const QString &_schema, + AssetUsageLimitsCols_t _AssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsage, + intfAccountAssetUsageHistory<_itmplIsTokenBase> *_assetUsageHistory, + intfAccountCoupons *_discounts, + intfAccountPrizes *_prizes ) : std::conditional<_itmplIsTokenBase, baseintfAccountingBasedModule_API, baseintfAccountingBasedModule_USER>::type( _module, @@ -1898,7 +1904,8 @@ intfAccountingBasedModule<_itmplIsTokenBase>::intfAccountingBasedModule( _saleablesFiles, _userAssets, _userAssetsFiles, - _assetUsages, + _assetUsage, + _assetUsageHistory, _discounts, _prizes ) diff --git a/Interfaces/AAA/intfAccountingBasedModule.h b/Interfaces/AAA/intfAccountingBasedModule.h index ced95ff3..3922f11a 100644 --- a/Interfaces/AAA/intfAccountingBasedModule.h +++ b/Interfaces/AAA/intfAccountingBasedModule.h @@ -42,16 +42,17 @@ class baseintfAccountingBasedModule : public intfSQLBasedModule baseintfAccountingBasedModule( const QString &_module, const QString &_schema, - AssetUsageLimitsCols_t _AssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - baseintfAccountUserAssets *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - baseintfAccountAssetUsage *_assetUsages, - intfAccountCoupons *_discounts = nullptr, - intfAccountPrizes *_prizes = nullptr + AssetUsageLimitsCols_t _AssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + baseintfAccountUserAssets *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + baseintfAccountAssetUsage *_assetUsage, + baseintfAccountAssetUsageHistory *_assetUsageHistory, + intfAccountCoupons *_discounts = nullptr, + intfAccountPrizes *_prizes = nullptr ); public: @@ -283,28 +284,30 @@ protected slots: ) public: - intfAccountUnits* accountUnits() { return this->AccountUnits.data(); } - intfAccountProducts* accountProducts() { return this->AccountProducts.data(); } - intfAccountSaleables* accountSaleables() { return this->AccountSaleables.data(); } - intfAccountSaleablesFiles* accountSaleablesFiles() { return this->AccountSaleablesFiles.data(); } - baseintfAccountUserAssets* accountUserAssets() { return this->AccountUserAssets.data(); } - intfAccountUserAssetsFiles* accountUserAssetsFiles() { return this->AccountUserAssetsFiles.data(); } - baseintfAccountAssetUsage* accountAssetUsages() { return this->AccountAssetUsages.data(); } - intfAccountCoupons* accountCoupons() { return this->AccountCoupons.data(); } - intfAccountPrizes* accountPrizes() { return this->AccountPrizes.data(); } + intfAccountUnits* accountUnits() { return this->AccountUnits.data(); } + intfAccountProducts* accountProducts() { return this->AccountProducts.data(); } + intfAccountSaleables* accountSaleables() { return this->AccountSaleables.data(); } + intfAccountSaleablesFiles* accountSaleablesFiles() { return this->AccountSaleablesFiles.data(); } + baseintfAccountUserAssets* accountUserAssets() { return this->AccountUserAssets.data(); } + intfAccountUserAssetsFiles* accountUserAssetsFiles() { return this->AccountUserAssetsFiles.data(); } + baseintfAccountAssetUsage* accountAssetUsage() { return this->AccountAssetUsage.data(); } + baseintfAccountAssetUsageHistory* accountAssetUsageHistory() { return this->AccountAssetUsageHistory.data(); } + intfAccountCoupons* accountCoupons() { return this->AccountCoupons.data(); } + intfAccountPrizes* accountPrizes() { return this->AccountPrizes.data(); } protected: QString ServiceName; - QScopedPointer AccountUnits; - QScopedPointer AccountProducts; - QScopedPointer AccountSaleables; - QScopedPointer AccountSaleablesFiles; - QScopedPointer AccountUserAssets; - QScopedPointer AccountUserAssetsFiles; - QScopedPointer AccountAssetUsages; - QScopedPointer AccountCoupons; - QScopedPointer AccountPrizes; + QScopedPointer AccountUnits; + QScopedPointer AccountProducts; + QScopedPointer AccountSaleables; + QScopedPointer AccountSaleablesFiles; + QScopedPointer AccountUserAssets; + QScopedPointer AccountUserAssetsFiles; + QScopedPointer AccountAssetUsage; + QScopedPointer AccountAssetUsageHistory; + QScopedPointer AccountCoupons; + QScopedPointer AccountPrizes; AssetUsageLimitsCols_t AssetUsageLimitsCols; // QStringList AssetUsageLimitsColsName; @@ -326,7 +329,8 @@ class baseintfAccountingBasedModule_USER : public baseintfAccountingBasedModule intfAccountSaleablesFiles *_saleablesFiles, intfAccountUserAssets *_userAssets, intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage *_assetUsages, + intfAccountAssetUsage *_assetUsage, + intfAccountAssetUsageHistory *_assetUsageHistory, intfAccountCoupons *_discounts = nullptr, intfAccountPrizes *_prizes = nullptr ); @@ -369,7 +373,8 @@ class baseintfAccountingBasedModule_API : public baseintfAccountingBasedModule intfAccountSaleablesFiles *_saleablesFiles, intfAccountUserAssets *_userAssets, intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage *_assetUsages, + intfAccountAssetUsage *_assetUsage, + intfAccountAssetUsageHistory *_assetUsageHistory, intfAccountCoupons *_discounts = nullptr, intfAccountPrizes *_prizes = nullptr ); @@ -403,18 +408,19 @@ class intfAccountingBasedModule : public std::conditional<_itmplIsTokenBase, bas { protected: intfAccountingBasedModule( - const QString &_module, - const QString &_schema, - AssetUsageLimitsCols_t _AssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsages, - intfAccountCoupons *_discounts = nullptr, - intfAccountPrizes *_prizes = nullptr + const QString &_module, + const QString &_schema, + AssetUsageLimitsCols_t _AssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsage, + intfAccountAssetUsageHistory<_itmplIsTokenBase> *_assetUsageHistory, + intfAccountCoupons *_discounts = nullptr, + intfAccountPrizes *_prizes = nullptr ); }; diff --git a/Interfaces/DBM/QueryBuilders.cpp b/Interfaces/DBM/QueryBuilders.cpp index 9c1b6861..565fed17 100644 --- a/Interfaces/DBM/QueryBuilders.cpp +++ b/Interfaces/DBM/QueryBuilders.cpp @@ -3101,7 +3101,11 @@ TAPI::stuTable ORMSelectQuery::allWithCount(QVariantMap _args) { //, quint16 _ma .toVariant() .toList(); - Result.PageCount = ceil((double)Result.TotalRows / this->Data->PageSize); + if (this->Data->PageSize > 0) + Result.PageCount = ceil((double)Result.TotalRows / this->Data->PageSize); + else + Result.PageCount = 1; + Result.HasMore = (Result.PageCount > (this->Data->PageIndex + 1)); return Result; diff --git a/Interfaces/ORM/intfAlerts.cpp b/Interfaces/ORM/intfAlerts.cpp index 09695f6f..09e733b4 100644 --- a/Interfaces/ORM/intfAlerts.cpp +++ b/Interfaces/ORM/intfAlerts.cpp @@ -30,10 +30,13 @@ TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::ORM, enuAlertStatus); namespace Targoman::API::ORM { -intfAlerts::intfAlerts() : - clsTable( - "Common", - "Alert", +intfAlerts::intfAlerts( + const QString& _module, + const QString& _schema +) : + intfSQLBasedModule( + _module, + _schema, tblAlerts::Private::ORMFields, tblAlerts::Private::Relations, tblAlerts::Private::Indexes diff --git a/Interfaces/ORM/intfAlerts.h b/Interfaces/ORM/intfAlerts.h index fae02098..4d497323 100644 --- a/Interfaces/ORM/intfAlerts.h +++ b/Interfaces/ORM/intfAlerts.h @@ -24,8 +24,9 @@ #ifndef TARGOMAN_API_ALERTS_H #define TARGOMAN_API_ALERTS_H -#include "Interfaces/DBM/clsTable.h" #include "Interfaces/AAA/AAADefs.hpp" +#include "Interfaces/API/intfSQLBasedModule.h" +//#include "Interfaces/DBM/clsTable.h" using namespace Targoman::API::DBM; @@ -122,10 +123,13 @@ namespace tblAlerts { } #pragma GCC diagnostic pop -class intfAlerts : public clsTable +class intfAlerts : public intfSQLBasedModule { public: - intfAlerts(); + intfAlerts( + const QString& _module, + const QString& _schema + ); // instanceGetter(intfAlerts) public: diff --git a/Interfaces/migrations/accounting/db/m20221029_182940_Interfaces_Accounting_create_assetusagehistory_table.sql b/Interfaces/migrations/accounting/db/m20221029_182940_Interfaces_Accounting_create_assetusagehistory_table.sql new file mode 100644 index 00000000..ec3773ad --- /dev/null +++ b/Interfaces/migrations/accounting/db/m20221029_182940_Interfaces_Accounting_create_assetusagehistory_table.sql @@ -0,0 +1,20 @@ +/* Migration File: m20221029_182940_Interfaces_Accounting_create_assetusagehistory_table.sql */ +/* CAUTION: don't forget to use {{dbprefix}} for schemas */ + +USE `{{dbprefix}}{{Schema}}`; + +CREATE TABLE `tblAccountAssetUsageHistory` ( + `ush_uasID` BIGINT(20) UNSIGNED NOT NULL, + `ushLastDateTime` DATETIME NOT NULL, + `ushUniqueMD5` CHAR(32) AS (md5(concat_ws('X',`ush_uasID`,date_format(`ushLastDateTime`,'%Y-%m-%d %H:%i:00')))) virtual, + UNIQUE INDEX `ushUniqueMD5` (`ushUniqueMD5`) USING BTREE, + INDEX `ush_uasID` (`ush_uasID`) USING BTREE, + CONSTRAINT `FK_tblAccountAssetUsageHistory_tblAccountUserAssets` FOREIGN KEY (`ush_uasID`) REFERENCES `tblAccountUserAssets` (`uasID`) ON UPDATE NO ACTION ON DELETE NO ACTION +) +COLLATE='utf8mb4_general_ci' +ENGINE=InnoDB +; + +ALTER TABLE `tblAccountAssetUsageHistory` + ADD INDEX `ushLastDateTime` (`ushLastDateTime`); + diff --git a/ModuleHelpers/MT/Interfaces/intfMTAccounting.cpp b/ModuleHelpers/MT/Interfaces/intfMTAccounting.cpp index 861afff1..872a605c 100644 --- a/ModuleHelpers/MT/Interfaces/intfMTAccounting.cpp +++ b/ModuleHelpers/MT/Interfaces/intfMTAccounting.cpp @@ -221,6 +221,47 @@ intfAccountAssetUsageMT<_itmplIsTokenBase>::intfAccountAssetUsageMT( baseintfAccountAssetUsageMT() { ; } +/******************************************************************/ +/******************************************************************/ +/******************************************************************/ +baseintfAccountAssetUsageHistoryMT::baseintfAccountAssetUsageHistoryMT( +// const QString& _schema, +// const QList& _exclusiveCols, +// const QList& _exclusiveRelations, +// const QList& _exclusiveIndexes +//) : +// baseintfAccountAssetUsageHistory( +// _schema, +// _exclusiveCols, +// _exclusiveRelations, +// _exclusiveIndexes + ) +{ ; } + +/******************************************************************/ +template +intfAccountAssetUsageHistoryMT<_itmplIsTokenBase>::intfAccountAssetUsageHistoryMT( + const QString& _schema, + const QList& _exclusiveCols, + const QList& _exclusiveRelations, + const QList& _exclusiveIndexes +) : + intfAccountAssetUsageHistory<_itmplIsTokenBase>( + _schema, + tblAccountAssetUsageHistoryMTBase::Private::ExtraORMFields + _exclusiveCols, + tblAccountAssetUsageHistoryMTBase::Private::ExtraRelations(_schema) + _exclusiveRelations, + tblAccountAssetUsageHistoryMTBase::Private::ExtraIndexes + _exclusiveIndexes + ), + baseintfAccountAssetUsageHistoryMT() +{ ; } + +template +QStringList intfAccountAssetUsageHistoryMT<_itmplIsTokenBase>::creditFieldNames() { + return { + tblAccountAssetUsageHistoryMTBase::ExtraFields::ushSumUsedTotalWords, + }; +} + /******************************************************************/ /******************************************************************/ /******************************************************************/ @@ -268,6 +309,7 @@ intfAccountCouponsMT::intfAccountCouponsMT( template class intfAccountUserAssetsMT; //template class intfAccountUserAssetsFilesMT; template class intfAccountAssetUsageMT; +template class intfAccountAssetUsageHistoryMT; //template class intfAccountCouponsMT; //template class intfAccountPrizesMT; @@ -281,6 +323,7 @@ template class intfAccountAssetUsageMT; template class intfAccountUserAssetsMT; //template class intfAccountUserAssetsFilesMT; template class intfAccountAssetUsageMT; +template class intfAccountAssetUsageHistoryMT; //template class intfAccountCouponsMT; //template class intfAccountPrizesMT; diff --git a/ModuleHelpers/MT/Interfaces/intfMTAccounting.h b/ModuleHelpers/MT/Interfaces/intfMTAccounting.h index 31370cfc..bbb0ce58 100644 --- a/ModuleHelpers/MT/Interfaces/intfMTAccounting.h +++ b/ModuleHelpers/MT/Interfaces/intfMTAccounting.h @@ -367,6 +367,42 @@ namespace tblAccountAssetUsageMTBase { ); } +namespace tblAccountAssetUsageHistoryMTBase { + + namespace ExtraFields { + TARGOMAN_CREATE_CONSTEXPR(ushSumUsedTotalWords); + } + + namespace ExtraRelation { + // constexpr char AAA[] = "aaa"; + } + + namespace Private { + const QList ExtraORMFields = { + //ColName Type Validation Default UpBy Sort Filter Self Virt PK + { ExtraFields::ushSumUsedTotalWords, S(quint32), QFV.integer().minValue(0), QRequired, UPAdmin } + }; + + inline const QList ExtraRelations(Q_DECL_UNUSED const QString& _schema) { + ///Col Reference Table ForeignCol Rename LeftJoin + return { }; + }; + + const QList ExtraIndexes = { + }; + + } //namespace Private + +#define SF_tblAccountAssetUsageHistoryMTBase_DTO \ + SF_tblAccountAssetUsageHistoryBase_DTO + + TAPI_DEFINE_STRUCT(DTO, + SF_tblAccountAssetUsageHistoryMTBase_DTO, + + SF_quint32 (ushSumUsedTotalWords) + ); +} + namespace tblAccountCouponsMTBase { namespace ExtraFields { @@ -565,6 +601,36 @@ class intfAccountAssetUsageMT : public intfAccountAssetUsage<_itmplIsTokenBase>, const QList& _exclusiveIndexes = {}); }; +/******************************************************/ +/******************************************************/ +/******************************************************/ +class baseintfAccountAssetUsageHistoryMT //: private QObject +{ +// Q _OBJECT + +public: + baseintfAccountAssetUsageHistoryMT(); + +//protected slots: +//APICALLBOOM_TYPE_JWT_TOKENBASE_DECL +//APICALLBOOM_TYPE_JWT_TOKENBASE_IMPL +}; + +template +class intfAccountAssetUsageHistoryMT : public intfAccountAssetUsageHistory<_itmplIsTokenBase>, public baseintfAccountAssetUsageHistoryMT +{ +// Q _OBJECT + +public: + intfAccountAssetUsageHistoryMT(const QString& _schema, + const QList& _exclusiveCols = {}, + const QList& _exclusiveRelations = {}, + const QList& _exclusiveIndexes = {}); + +protected: + virtual QStringList creditFieldNames(); +}; + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/ModuleHelpers/MT/Interfaces/intfMTModule.cpp b/ModuleHelpers/MT/Interfaces/intfMTModule.cpp index 015d93f2..ba4da579 100644 --- a/ModuleHelpers/MT/Interfaces/intfMTModule.cpp +++ b/ModuleHelpers/MT/Interfaces/intfMTModule.cpp @@ -34,26 +34,27 @@ using namespace DBManager; template intfMTModule<_itmplIsTokenBase>::intfMTModule( - const QString &_module, - const QString &_schema, + const QString &_module, + const QString &_schema, //Account -- - AssetUsageLimitsCols_t _exclusiveAssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsages, - intfAccountCoupons *_discounts, - intfAccountPrizes *_prizes, + AssetUsageLimitsCols_t _exclusiveAssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsage, + intfAccountAssetUsageHistory<_itmplIsTokenBase> *_assetUsageHistory, + intfAccountCoupons *_discounts, + intfAccountPrizes *_prizes, //MT -- - intfMTCorrectionRules_Type *_correctionRules, - intfMTDigestedTranslationLogs_Type *_digestedTranslationLogs, - intfMTMultiDic_Type *_multiDic, - intfMTTokenStats_Type *_tokenStats, - intfMTTranslatedPhrases_Type *_translatedPhrases, - intfMTTranslationLogs_Type *_translationLogs + intfMTCorrectionRules_Type *_correctionRules, + intfMTDigestedTranslationLogs_Type *_digestedTranslationLogs, + intfMTMultiDic_Type *_multiDic, + intfMTTokenStats_Type *_tokenStats, + intfMTTranslatedPhrases_Type *_translatedPhrases, + intfMTTranslationLogs_Type *_translationLogs ) : intfAccountingBasedModule<_itmplIsTokenBase>( _module, @@ -76,7 +77,8 @@ intfMTModule<_itmplIsTokenBase>::intfMTModule( _saleablesFiles, _userAssets, _userAssetsFiles, - _assetUsages, + _assetUsage, + _assetUsageHistory, _discounts, _prizes ), @@ -88,6 +90,35 @@ intfMTModule<_itmplIsTokenBase>::intfMTModule( MTTranslationLogs(_translationLogs) { ; } +// basket +/*********************************************************************/ +template +QVariantMap intfMTModule<_itmplIsTokenBase>::getCustomUserAssetFieldsForQuery( + INTFAPICALLBOOM_IMPL &APICALLBOOM_PARAM, + INOUT stuBasketItem &_basketItem, + Q_DECL_UNUSED const stuVoucherItem *_oldVoucherItem /*= nullptr*/ +) { + QVariantMap Result; + + tblAccountProductsMTBase::DTO AccountProductsMTBaseDTO; + AccountProductsMTBaseDTO.fromJson(_basketItem._lastFromJsonSource); + + tblAccountSaleablesMTBase::DTO AccountSaleablesMTBaseDTO; + AccountSaleablesMTBaseDTO.fromJson(_basketItem._lastFromJsonSource); + + if (NULLABLE_HAS_VALUE(AccountSaleablesMTBaseDTO.slbCreditTotalWords)) + Result.insert(tblAccountUserAssetsMTBase::ExtraFields::uasCreditTotalWords, + NULLABLE_VALUE(AccountSaleablesMTBaseDTO.slbCreditTotalWords) + ); + else if (NULLABLE_HAS_VALUE(AccountProductsMTBaseDTO.prdCreditTotalWords)) + Result.insert(tblAccountUserAssetsMTBase::ExtraFields::uasCreditTotalWords, + NULLABLE_VALUE(AccountProductsMTBaseDTO.prdCreditTotalWords) + ); + //else leave uasCreditTotalWords as null + + return Result; +} + // accounting /*********************************************************************/ template @@ -321,15 +352,24 @@ bool intfMTModule<_itmplIsTokenBase>::isUnlimited( const UsageLimits_t &_limits ) const { + for (auto it = _limits.constBegin(); + it != _limits.constEnd(); + it++ + ) { + if (NULLABLE_HAS_VALUE(it->PerDay)) + return false; + if (NULLABLE_HAS_VALUE(it->PerWeek)) + return false; + if (NULLABLE_HAS_VALUE(it->PerMonth)) + return false; + if (NULLABLE_HAS_VALUE(it->Total)) + return false; + } - - - - - + return true; } template @@ -338,14 +378,24 @@ bool intfMTModule<_itmplIsTokenBase>::isEmpty( const UsageLimits_t &_limits ) const { + for (auto it = _limits.constBegin(); + it != _limits.constEnd(); + it++ + ) { + if (NULLABLE_HAS_VALUE(it->PerDay) && NULLABLE_VALUE(it->PerDay) > 0) + return false; + if (NULLABLE_HAS_VALUE(it->PerWeek) && NULLABLE_VALUE(it->PerWeek) > 0) + return false; + if (NULLABLE_HAS_VALUE(it->PerMonth) && NULLABLE_VALUE(it->PerMonth) > 0) + return false; + if (NULLABLE_HAS_VALUE(it->Total) && NULLABLE_VALUE(it->Total) > 0) + return false; + } - - - - + return true; } template @@ -369,7 +419,34 @@ void intfMTModule<_itmplIsTokenBase>::saveAccountUsage( // QString CreditKey = CreditValues.firstKey(); qint64 UsedWordCount = CreditValues.first().toLongLong(); + // usage history + //--------------------------------------------- QString QueryString = QString(R"( + INSERT INTO %1 + SET %2 = ? + , %3 = NOW() + , %4 = ? + ON DUPLICATE KEY + UPDATE %3 = NOW() + , %4 = %4 + ? +)") + .arg(tblAccountAssetUsageHistoryBase::Name) + .arg(tblAccountAssetUsageHistoryBase::Fields::ush_uasID) + .arg(tblAccountAssetUsageHistoryBase::Fields::ushLastDateTime) + .arg(tblAccountAssetUsageHistoryMTBase::ExtraFields::ushSumUsedTotalWords) + ; + + clsDACResult Result1 = this->accountAssetUsageHistory()->execQuery(APICALLBOOM_PARAM, + QueryString, + { + _activeCredit.Credit.UserAsset.uasID, + UsedWordCount, + UsedWordCount, + }); + + // usage + //--------------------------------------------- + QueryString = QString(R"( INSERT INTO %1 SET %2 = ? , %3 = ? @@ -381,7 +458,7 @@ void intfMTModule<_itmplIsTokenBase>::saveAccountUsage( .arg(tblAccountAssetUsageMTBase::ExtraFields::usgUsedTotalWords) ; - clsDACResult Result = this->accountAssetUsages()->execQuery(APICALLBOOM_PARAM, + clsDACResult Result2 = this->accountAssetUsage()->execQuery(APICALLBOOM_PARAM, QueryString, { _activeCredit.Credit.UserAsset.uasID, @@ -391,39 +468,9 @@ void intfMTModule<_itmplIsTokenBase>::saveAccountUsage( } } -// basket -/*********************************************************************/ -template -QVariantMap intfMTModule<_itmplIsTokenBase>::getCustomUserAssetFieldsForQuery( - INTFAPICALLBOOM_IMPL &APICALLBOOM_PARAM, - INOUT stuBasketItem &_basketItem, - Q_DECL_UNUSED const stuVoucherItem *_oldVoucherItem /*= nullptr*/ -) { - QVariantMap Result; - - tblAccountProductsMTBase::DTO AccountProductsMTBaseDTO; - AccountProductsMTBaseDTO.fromJson(_basketItem._lastFromJsonSource); - - tblAccountSaleablesMTBase::DTO AccountSaleablesMTBaseDTO; - AccountSaleablesMTBaseDTO.fromJson(_basketItem._lastFromJsonSource); - - if (NULLABLE_HAS_VALUE(AccountSaleablesMTBaseDTO.slbCreditTotalWords)) - Result.insert(tblAccountUserAssetsMTBase::ExtraFields::uasCreditTotalWords, - NULLABLE_VALUE(AccountSaleablesMTBaseDTO.slbCreditTotalWords) - ); - else if (NULLABLE_HAS_VALUE(AccountProductsMTBaseDTO.prdCreditTotalWords)) - Result.insert(tblAccountUserAssetsMTBase::ExtraFields::uasCreditTotalWords, - NULLABLE_VALUE(AccountProductsMTBaseDTO.prdCreditTotalWords) - ); - //else leave uasCreditTotalWords as null - - return Result; -} - // expose /*********************************************************************/ template class intfMTModule; template class intfMTModule; } //namespace Targoman::API::ModuleHelpers::MT::Interfaces - diff --git a/ModuleHelpers/MT/Interfaces/intfMTModule.h b/ModuleHelpers/MT/Interfaces/intfMTModule.h index 7bddafb7..9e46aad5 100644 --- a/ModuleHelpers/MT/Interfaces/intfMTModule.h +++ b/ModuleHelpers/MT/Interfaces/intfMTModule.h @@ -54,26 +54,27 @@ typedef intfMTTranslationLogs<_itmplIsTokenBase ? TAPI::enuTokenActorType::API : public: intfMTModule( - const QString &_module, - const QString &_schema, + const QString &_module, + const QString &_schema, //Account -- - AssetUsageLimitsCols_t _exclusiveAssetUsageLimitsCols, - intfAccountUnits *_units, - intfAccountProducts *_products, - intfAccountSaleables *_saleables, - intfAccountSaleablesFiles *_saleablesFiles, - intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, - intfAccountUserAssetsFiles *_userAssetsFiles, - intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsages, - intfAccountCoupons *_discounts, - intfAccountPrizes *_prizes, + AssetUsageLimitsCols_t _exclusiveAssetUsageLimitsCols, + intfAccountUnits *_units, + intfAccountProducts *_products, + intfAccountSaleables *_saleables, + intfAccountSaleablesFiles *_saleablesFiles, + intfAccountUserAssets<_itmplIsTokenBase> *_userAssets, + intfAccountUserAssetsFiles *_userAssetsFiles, + intfAccountAssetUsage<_itmplIsTokenBase> *_assetUsage, + intfAccountAssetUsageHistory<_itmplIsTokenBase> *_assetUsageHistory, + intfAccountCoupons *_discounts, + intfAccountPrizes *_prizes, //MT -- - intfMTCorrectionRules_Type *_correctionRules, - intfMTDigestedTranslationLogs_Type *_digestedTranslationLogs, - intfMTMultiDic_Type *_multiDic, - intfMTTokenStats_Type *_tokenStats, - intfMTTranslatedPhrases_Type *_translatedPhrases, - intfMTTranslationLogs_Type *_translationLogs + intfMTCorrectionRules_Type *_correctionRules, + intfMTDigestedTranslationLogs_Type *_digestedTranslationLogs, + intfMTMultiDic_Type *_multiDic, + intfMTTokenStats_Type *_tokenStats, + intfMTTranslatedPhrases_Type *_translatedPhrases, + intfMTTranslationLogs_Type *_translationLogs ); protected: diff --git a/ModuleHelpers/MT/MTHelper.cpp b/ModuleHelpers/MT/MTHelper.cpp index 3dac7917..5185d36b 100644 --- a/ModuleHelpers/MT/MTHelper.cpp +++ b/ModuleHelpers/MT/MTHelper.cpp @@ -177,15 +177,15 @@ QVariantMap MTHelper::doTranslation( INTFAPICALLBOOM_IMPL &APICALLBOOM_PARAM, intfMTModule<_itmplTokenActorType == TAPI::enuTokenActorType::API> *_mtModule, QString _text, - const TranslationDir_t& _dir, - const QString& _engine, + const TranslationDir_t &_dir, + const QString &_engine, bool _useSpecialClass, bool _detailed, bool _detokenize, bool _dic, bool _dicFull, - int& _preprocessTime, - int& _translationTime + int &_preprocessTime, + int &_translationTime ) { APICALLBOOM_PARAM.createScopeTiming("translate"); @@ -305,6 +305,20 @@ QVariantMap MTHelper::doTranslation( << "ActiveCredit:" << QJsonDocument(ActiveCredit.toJson()).toJson(); } +#ifdef QT_DEBUG + if (_engine == "TEST_AAA") { + _mtModule->saveAccountUsage( + APICALLBOOM_PARAM, + ActiveCredit, + RequestedUsage, + MTAction::TRANSLATE + ); + + QVariantMap TranslationResult; + return TranslationResult; + } +#endif + //----------------------------------------- auto FnFindClassAndEngine = [this]( QString _text, diff --git a/ModuleHelpers/MT/MTHelper.h b/ModuleHelpers/MT/MTHelper.h index addb6db1..ad91b760 100644 --- a/ModuleHelpers/MT/MTHelper.h +++ b/ModuleHelpers/MT/MTHelper.h @@ -164,15 +164,15 @@ class MTHelper : public intfModuleHelper INTFAPICALLBOOM_DECL &APICALLBOOM_PARAM, intfMTModule<_itmplTokenActorType == TAPI::enuTokenActorType::API> *_mtModule, QString _text, - const TranslationDir_t& _dir, - const QString& _engine, + const TranslationDir_t &_dir, + const QString &_engine, bool _useSpecialClass, bool _detailed, bool _detokenize, bool _dic, // = false, bool _dicFull, // = false - int& _preprocessTime, - int& _translationTime + int &_preprocessTime, + int &_translationTime ); protected: diff --git a/ModuleHelpers/MT/migrations/applytomodules/db/m20221029_185258_Helpers_MT_create_assetusagehistory_table.sql b/ModuleHelpers/MT/migrations/applytomodules/db/m20221029_185258_Helpers_MT_create_assetusagehistory_table.sql new file mode 100644 index 00000000..62c4a444 --- /dev/null +++ b/ModuleHelpers/MT/migrations/applytomodules/db/m20221029_185258_Helpers_MT_create_assetusagehistory_table.sql @@ -0,0 +1,7 @@ +/* Migration File: m20221029_185258_Helpers_MT_create_assetusagehistory_table.sql */ +/* CAUTION: don't forget to use {{dbprefix}} for schemas */ + +USE `{{dbprefix}}{{Schema}}`; + +ALTER TABLE `tblAccountAssetUsageHistory` + ADD COLUMN `ushSumUsedTotalWords` INT UNSIGNED NOT NULL AFTER `ushUniqueMD5`; diff --git a/Modules/Account/functionalTest/testAccount.hpp b/Modules/Account/functionalTest/testAccount.hpp index 59da7d57..87e9ebd3 100644 --- a/Modules/Account/functionalTest/testAccount.hpp +++ b/Modules/Account/functionalTest/testAccount.hpp @@ -84,6 +84,7 @@ DELETE FROM dev_AAA.tblRoles WHERE LOWER(rolName) LIKE '%test%'; DELETE FROM dev_Common.tblAlerts; DELETE FROM dev_Common.tblDBG; TRUNCATE dev_Advert.tblActionLogs; +DELETE FROM dev_Advert.tblAccountAssetUsageHistory; DELETE FROM dev_Advert.tblAccountAssetUsage; DELETE FROM dev_Advert.tblAccountUserAssets_files; DELETE FROM dev_Advert.tblAccountUserAssets; diff --git a/Modules/Advert/moduleSrc/Advert.cpp b/Modules/Advert/moduleSrc/Advert.cpp index 69f548fe..330fe466 100644 --- a/Modules/Advert/moduleSrc/Advert.cpp +++ b/Modules/Advert/moduleSrc/Advert.cpp @@ -98,6 +98,7 @@ Advert::Advert() : &AccountUserAssets::instance(), &AccountUserAssetsFiles::instance(), &AccountAssetUsage::instance(), + &AccountAssetUsageHistory::instance(), &AccountCoupons::instance() ) { TARGOMAN_API_MODULE_IMPLEMENT_CTOR_MIGRATIONS(Advert, AdvertSchema) @@ -111,7 +112,8 @@ Advert::Advert() : this->addSubModule(AccountSaleablesFiles.data()); this->addSubModule(AccountUserAssets.data()); this->addSubModule(AccountUserAssetsFiles.data()); - this->addSubModule(AccountAssetUsages.data()); + this->addSubModule(AccountAssetUsage.data()); + this->addSubModule(AccountAssetUsageHistory.data()); this->addSubModule(AccountCoupons.data()); //this->addSubModule(AccountPrizes); // There is no prize in advertisement module diff --git a/Modules/Advert/moduleSrc/ORM/Accounting.cpp b/Modules/Advert/moduleSrc/ORM/Accounting.cpp index fcc7b8c1..80550d6b 100644 --- a/Modules/Advert/moduleSrc/ORM/Accounting.cpp +++ b/Modules/Advert/moduleSrc/ORM/Accounting.cpp @@ -156,6 +156,30 @@ AccountAssetUsage::AccountAssetUsage() : tblAccountAssetUsage::Private::ExtraIndexes ) { ; } +/******************************************************/ +/******************************************************/ +/******************************************************/ +TARGOMAN_API_SUBMODULE_IMPLEMENT(Advert, AccountAssetUsageHistory) + +AccountAssetUsageHistory::AccountAssetUsageHistory() : + intfAccountAssetUsageHistory( + AdvertSchema, + tblAccountAssetUsageHistory::Private::ExtraORMFields, + tblAccountAssetUsageHistory::Private::ExtraRelations, + tblAccountAssetUsageHistory::Private::ExtraIndexes +) { ; } + +QStringList AccountAssetUsageHistory::creditFieldNames() { + return { + tblAccountAssetUsageHistory::ExtraFields::ushSumDays, + tblAccountAssetUsageHistory::ExtraFields::ushSumDayShow, + tblAccountAssetUsageHistory::ExtraFields::ushSumTotalShow, + tblAccountAssetUsageHistory::ExtraFields::ushSumDayClicks, + tblAccountAssetUsageHistory::ExtraFields::ushSumMonthClicks, + tblAccountAssetUsageHistory::ExtraFields::ushSumTotalClicks, + }; +} + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/Modules/Advert/moduleSrc/ORM/Accounting.h b/Modules/Advert/moduleSrc/ORM/Accounting.h index b0845cec..20993975 100644 --- a/Modules/Advert/moduleSrc/ORM/Accounting.h +++ b/Modules/Advert/moduleSrc/ORM/Accounting.h @@ -400,6 +400,52 @@ namespace tblAccountAssetUsage { ); } +namespace tblAccountAssetUsageHistory { + + namespace ExtraFields { + TARGOMAN_CREATE_CONSTEXPR(ushSumDays); + TARGOMAN_CREATE_CONSTEXPR(ushSumDayShow); + TARGOMAN_CREATE_CONSTEXPR(ushSumTotalShow); + TARGOMAN_CREATE_CONSTEXPR(ushSumDayClicks); + TARGOMAN_CREATE_CONSTEXPR(ushSumMonthClicks); + TARGOMAN_CREATE_CONSTEXPR(ushSumTotalClicks); + } + + namespace ExtraRelation { + // constexpr char AAA[] = "aaa"; + } + + namespace Private { + const QList ExtraORMFields = { + //ColName Type Validation Default UpBy Sort Filter Self Virt PK + { ExtraFields::ushSumDays, S(qint16), QFV.integer().minValue(-1), 0, UPAdmin, false, false }, + { ExtraFields::ushSumDayShow, S(quint32), QFV.integer().minValue(0), 0, UPAdmin, false, false }, + { ExtraFields::ushSumTotalShow, S(quint64), QFV.integer().minValue(0), 0, UPAdmin, false, false }, + { ExtraFields::ushSumDayClicks, S(quint32), QFV.integer().minValue(0), 0, UPAdmin, false, false }, + { ExtraFields::ushSumMonthClicks, S(quint32), QFV.integer().minValue(0), 0, UPAdmin, false, false }, + { ExtraFields::ushSumTotalClicks, S(quint64), QFV.integer().minValue(0), 0, UPAdmin, false, false } + }; + + const QList ExtraRelations = { + }; + + const QList ExtraIndexes = { + }; + + } //namespace Private + + TAPI_DEFINE_STRUCT(DTO, + SF_tblAccountAssetUsageHistoryBase_DTO, + + SF_qint16 (ushSumDays), + SF_quint32 (ushSumDayShow), + SF_quint64 (ushSumTotalShow), + SF_quint32 (ushSumDayClicks), + SF_quint32 (ushSumMonthClicks), + SF_quint64 (ushSumTotalClicks) + ); +} + namespace tblAccountCoupons { namespace ExtraFields { @@ -530,6 +576,18 @@ class AccountAssetUsage : public intfAccountAssetUsage public: }; +/******************************************************/ +/******************************************************/ +/******************************************************/ +class AccountAssetUsageHistory : public intfAccountAssetUsageHistory +{ +// Q _OBJECT + TARGOMAN_API_SUBMODULE_DEFINE(Advert, AccountAssetUsageHistory) + +protected: + virtual QStringList creditFieldNames(); +}; + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/Modules/Common/moduleSrc/ORM/Alerts.cpp b/Modules/Common/moduleSrc/ORM/Alerts.cpp index b0e86b19..3f69f490 100644 --- a/Modules/Common/moduleSrc/ORM/Alerts.cpp +++ b/Modules/Common/moduleSrc/ORM/Alerts.cpp @@ -35,18 +35,17 @@ namespace Targoman::API::CommonModule::ORM { TARGOMAN_API_SUBMODULE_IMPLEMENT(Common, Alerts) Alerts::Alerts() : - intfPureModule( - "Common" -// CommonSchema, -// "" - ), - intfAlerts() { ; } + intfAlerts( + CommonDomain, + CommonSchema + ) +{ ; } QVariant IMPL_ORMGET_USER(Alerts) { - Authorization::checkPriv(APICALLBOOM_PARAM, this->privOn(EHTTP_GET, this->moduleBaseName())); + if (Authorization::hasPriv(APICALLBOOM_PARAM, this->privOn(EHTTP_GET, this->moduleBaseName())) == false) + this->setSelfFilters({{ tblAlerts::Fields::alr_usrID, APICALLBOOM_PARAM.getActorID() }}, _filters); -// return this->Select(GET_METHOD_ARGS_CALL_VALUES); - return QVariant(); + return this->Select(GET_METHOD_ARGS_CALL_VALUES); } } //namespace Targoman::API::CommonModule::ORM diff --git a/Modules/Common/moduleSrc/ORM/Alerts.h b/Modules/Common/moduleSrc/ORM/Alerts.h index 7612d1e6..aeccc381 100644 --- a/Modules/Common/moduleSrc/ORM/Alerts.h +++ b/Modules/Common/moduleSrc/ORM/Alerts.h @@ -26,7 +26,7 @@ //#include "Interfaces/AAA/AAA.hpp" #include "Interfaces/ORM/intfAlerts.h" -#include "Interfaces/API/intfPureModule.h" +//#include "Interfaces/API/intfSQLBasedModule.h" using namespace Targoman::API::ORM; @@ -36,7 +36,7 @@ namespace Targoman::API::CommonModule { namespace ORM { -class Alerts : public intfPureModule, public intfAlerts +class Alerts : public intfAlerts { Q_OBJECT TARGOMAN_API_SUBMODULE_DEFINE(Common, Alerts) diff --git a/Modules/MT/functionalTest/testMT.hpp b/Modules/MT/functionalTest/testMT.hpp index 158c72a7..462c3157 100644 --- a/Modules/MT/functionalTest/testMT.hpp +++ b/Modules/MT/functionalTest/testMT.hpp @@ -553,6 +553,7 @@ private slots: {}, { { "text", "This is a sample text for testing." }, + { "engine", "TEST_AAA" }, { "dir", "en2fa" }, }); @@ -572,6 +573,7 @@ private slots: {}, { { "text", "این یک متن نمونه برای آزمایش است." }, + { "engine", "TEST_AAA" }, { "dir", "fa2en" }, }); @@ -591,6 +593,7 @@ private slots: {}, { { "text", "این یک متن نمونه برای آزمایش است." }, + { "engine", "TEST_AAA" }, { "dir", "fa2ar" }, }); @@ -601,6 +604,29 @@ private slots: } } + void assetUsageHistory_1() { + QT_TRY { + QVariant Result = callUserAPI( + RESTClientHelper::POST, + "MT/AccountAssetUsageHistory/report", + {}, + { + { "apiToken", this->TokenJWT }, +// { "assetID", }, + { "step", 15 }, + { "stepUnit", "Minute" }, + } + ); + + QJsonDocument Doc = QJsonDocument::fromVariant(QVariantMap({{ "result", Result }})); + qDebug().noquote() << endl + << " Result:" << Doc.toJson(); + + } QT_CATCH (const std::exception &exp) { + QTest::qFail(exp.what(), __FILE__, __LINE__); + } + } + }; #endif // TEST_MT_HPP diff --git a/Modules/MT/moduleSrc/MT.cpp b/Modules/MT/moduleSrc/MT.cpp index ad1e692c..c41aad4e 100644 --- a/Modules/MT/moduleSrc/MT.cpp +++ b/Modules/MT/moduleSrc/MT.cpp @@ -68,6 +68,7 @@ MT::MT() : &AccountUserAssets::instance(), &AccountUserAssetsFiles::instance(), &AccountAssetUsage::instance(), + &AccountAssetUsageHistory::instance(), &AccountCoupons::instance(), nullptr, //--------------------- @@ -89,7 +90,8 @@ MT::MT() : this->addSubModule(AccountSaleablesFiles.data()); this->addSubModule(AccountUserAssets.data()); this->addSubModule(AccountUserAssetsFiles.data()); - this->addSubModule(AccountAssetUsages.data()); + this->addSubModule(AccountAssetUsage.data()); + this->addSubModule(AccountAssetUsageHistory.data()); this->addSubModule(AccountCoupons.data()); //this->addSubModule(AccountPrizes); // There is no prize in MT module diff --git a/Modules/MT/moduleSrc/ORM/Accounting.cpp b/Modules/MT/moduleSrc/ORM/Accounting.cpp index 6de95bdf..5a1650af 100644 --- a/Modules/MT/moduleSrc/ORM/Accounting.cpp +++ b/Modules/MT/moduleSrc/ORM/Accounting.cpp @@ -154,6 +154,19 @@ AccountAssetUsage::AccountAssetUsage() : tblAccountAssetUsage::Private::ExtraIndexes ) { ; } +/******************************************************/ +/******************************************************/ +/******************************************************/ +TARGOMAN_API_SUBMODULE_IMPLEMENT(MT, AccountAssetUsageHistory) + +AccountAssetUsageHistory::AccountAssetUsageHistory() : + intfAccountAssetUsageHistoryMT( + MTSchema, + tblAccountAssetUsageHistory::Private::ExtraORMFields, + tblAccountAssetUsageHistory::Private::ExtraRelations, + tblAccountAssetUsageHistory::Private::ExtraIndexes +) { ; } + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/Modules/MT/moduleSrc/ORM/Accounting.h b/Modules/MT/moduleSrc/ORM/Accounting.h index a6e8b68d..3786b7b8 100644 --- a/Modules/MT/moduleSrc/ORM/Accounting.h +++ b/Modules/MT/moduleSrc/ORM/Accounting.h @@ -317,6 +317,33 @@ namespace tblAccountAssetUsage { ); } +namespace tblAccountAssetUsageHistory { + + namespace ExtraFields { + } + + namespace ExtraRelation { + // constexpr char AAA[] = "aaa"; + } + + namespace Private { + const QList ExtraORMFields = { + //ColName Type Validation Default UpBy Sort Filter Self Virt PK + }; + + const QList ExtraRelations = { + }; + + const QList ExtraIndexes = { + }; + + } //namespace Private + + TAPI_DEFINE_STRUCT(DTO, + SF_tblAccountAssetUsageHistoryMTBase_DTO + ); +} + namespace tblAccountCoupons { namespace ExtraFields { @@ -447,6 +474,17 @@ class AccountAssetUsage : public intfAccountAssetUsageMT public: }; +/******************************************************/ +/******************************************************/ +/******************************************************/ +class AccountAssetUsageHistory : public intfAccountAssetUsageHistoryMT +{ +// Q _OBJECT + TARGOMAN_API_SUBMODULE_DEFINE(MT, AccountAssetUsageHistory) + +public: +}; + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/Modules/TargomanMT/moduleSrc/ORM/Accounting.cpp b/Modules/TargomanMT/moduleSrc/ORM/Accounting.cpp index af2d8c14..572471ba 100644 --- a/Modules/TargomanMT/moduleSrc/ORM/Accounting.cpp +++ b/Modules/TargomanMT/moduleSrc/ORM/Accounting.cpp @@ -164,6 +164,20 @@ AccountAssetUsage::AccountAssetUsage() : tblAccountAssetUsage::Private::ExtraIndexes ) { ; } +/******************************************************/ +/******************************************************/ +/******************************************************/ +TARGOMAN_API_SUBMODULE_IMPLEMENT(TargomanMT, AccountAssetUsageHistory) + +AccountAssetUsageHistory::AccountAssetUsageHistory() : + intfAccountAssetUsageHistoryMT( +// false, + TargomanMTSchema, + tblAccountAssetUsageHistory::Private::ExtraORMFields, + tblAccountAssetUsageHistory::Private::ExtraRelations, + tblAccountAssetUsageHistory::Private::ExtraIndexes +) { ; } + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/Modules/TargomanMT/moduleSrc/ORM/Accounting.h b/Modules/TargomanMT/moduleSrc/ORM/Accounting.h index 9e2d3aa1..f85211fc 100644 --- a/Modules/TargomanMT/moduleSrc/ORM/Accounting.h +++ b/Modules/TargomanMT/moduleSrc/ORM/Accounting.h @@ -317,6 +317,33 @@ namespace tblAccountAssetUsage { ); } +namespace tblAccountAssetUsageHistory { + + namespace ExtraFields { + } + + namespace ExtraRelation { + // constexpr char AAA[] = "aaa"; + } + + namespace Private { + const QList ExtraORMFields = { + //ColName Type Validation Default UpBy Sort Filter Self Virt PK + }; + + const QList ExtraRelations = { + }; + + const QList ExtraIndexes = { + }; + + } //namespace Private + + TAPI_DEFINE_STRUCT(DTO, + SF_tblAccountAssetUsageHistoryBase_DTO + ); +} + namespace tblAccountCoupons { namespace ExtraFields { @@ -447,6 +474,17 @@ class AccountAssetUsage : public intfAccountAssetUsageMT public: }; +/******************************************************/ +/******************************************************/ +/******************************************************/ +class AccountAssetUsageHistory : public intfAccountAssetUsageHistoryMT +{ +// Q _OBJECT + TARGOMAN_API_SUBMODULE_DEFINE(TargomanMT, AccountAssetUsageHistory) + +public: +}; + /******************************************************/ /******************************************************/ /******************************************************/ diff --git a/Modules/TargomanMT/moduleSrc/TargomanMT.cpp b/Modules/TargomanMT/moduleSrc/TargomanMT.cpp index e29fe4c1..2ac4e68f 100644 --- a/Modules/TargomanMT/moduleSrc/TargomanMT.cpp +++ b/Modules/TargomanMT/moduleSrc/TargomanMT.cpp @@ -68,6 +68,7 @@ TargomanMT::TargomanMT() : &AccountUserAssets::instance(), &AccountUserAssetsFiles::instance(), &AccountAssetUsage::instance(), + &AccountAssetUsageHistory::instance(), &AccountCoupons::instance(), nullptr, //--------------------- @@ -96,7 +97,8 @@ TargomanMT::TargomanMT() : this->addSubModule(AccountSaleablesFiles.data()); this->addSubModule(AccountUserAssets.data()); this->addSubModule(AccountUserAssetsFiles.data()); - this->addSubModule(AccountAssetUsages.data()); + this->addSubModule(AccountAssetUsage.data()); + this->addSubModule(AccountAssetUsageHistory.data()); this->addSubModule(AccountCoupons.data()); //this->addSubModule(AccountPrizes); // There is no prize in Targoman module }