Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions App/Server/RESTAPIRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ void RESTAPIRegistry::registerRESTAPI(
Qt::DirectConnection,
Q_RETURN_ARG(QString, MethodDoc)
);
MethodDoc = MethodDoc.trimmed();
FoundDoc = true;
// break;
}
Expand Down Expand Up @@ -659,14 +660,16 @@ void RESTAPIRegistry::dumpAPIs()

TargomanDebug(5).noLabel().noquote().nospace() << endl << Targoman::API::Helpers::ClientConfigs::RESTServerAddress.value();

int index = 1;
int APIsIndex = 1;
int MethodsIndex = 1;
foreach (const QString Name, Keys) {
bool IsLastAPI = (Name == Keys.last());

TargomanDebug(5).noLabel().noquote().nospace()
<< "│";
TargomanDebug(5).noLabel().noquote().nospace()
<< (IsLastAPI ? "└" : "├") << "── "
<< (IsLastAPI ? "└" : "├") << "──"
<< "[" << QString::number(APIsIndex++) << "] "
<< Name;

QStringList Methods = APIs[Name].keys();
Expand All @@ -678,8 +681,8 @@ void RESTAPIRegistry::dumpAPIs()

TargomanDebug(5).noLabel().noquote().nospace()
<< (IsLastAPI ? " " : "│") << " "
<< (IsLastMethod ? "└" : "├") << "── "
<< QString::number(index++) << ") "
<< (IsLastMethod ? "└" : "├") << "──"
<< "(" << QString::number(MethodsIndex++) << ") "
<< Method.toUpper(); // << " " << Name;

if (API.APIObject->ParamTypesName.isEmpty() == false) {
Expand Down Expand Up @@ -716,7 +719,8 @@ void RESTAPIRegistry::dumpAPIs()
TargomanDebug(5).noLabel().noquote().nospace()
<< (IsLastAPI ? " " : "│") << " "
<< (IsLastMethod ? " " : "│") << " "
<< (IsLastParam ? "└" : "├") << "── "
<< (IsLastParam ? "└" : "├") << "──"
<< " " << QString::number(ParamsIndex + 1) << ": "
<< API.APIObject->ParamTypesName[ParamsIndex].leftJustified(maxLen)
<< " "
<< API.APIObject->ParamNames[ParamsIndex]
Expand Down
10 changes: 8 additions & 2 deletions App/Server/clsAPIObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ intfAPIArgManipulator* clsAPIObject::argSpecs(quint8 _paramIndex) const {
}

QVariant clsAPIObject::invoke(
intfAPICallBoom* _APICALLBOOM,
INTFAPICALLBOOM_IMPL *_APICALLBOOM,
bool _isUpdateMethod,
const QStringList& _args,
// /*OUT*/ QVariantMap &_responseHeaders,
Expand Down Expand Up @@ -302,7 +302,7 @@ QVariant clsAPIObject::invoke(
}

void clsAPIObject::invokeMethod(
intfAPICallBoom* _APICALLBOOM,
INTFAPICALLBOOM_IMPL *_APICALLBOOM,
const QVariantList& _arguments,
QGenericReturnArgument _returnArg
// /*OUT*/ QVariantMap &_responseHeaders
Expand All @@ -320,6 +320,12 @@ void clsAPIObject::invokeMethod(

QVector<void*> ArgStorage(_arguments.size(), {});

#ifdef QT_DEBUG
if (this->BaseMethod.name() == "apiPOSTclaimOfflinePayment") {
int ii; ii = 0;
}
#endif

auto useArgAt = [=, &_arguments, &ArgStorage](int _i) -> QGenericArgument {
Targoman::API::Common::intfAPIArgManipulator* ArgMan = (this->ParamTypesID.at(_i) < TAPI_BASE_USER_DEFINED_TYPEID
? gOrderedMetaTypeInfo.at(this->ParamTypesID.at(_i))
Expand Down
4 changes: 2 additions & 2 deletions App/Server/clsAPIObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class clsAPIObject : public intfAPIObject, public QObject
}

QVariant invoke(
intfAPICallBoom* _APICALLBOOM,
INTFAPICALLBOOM_DECL *_APICALLBOOM,
bool _isUpdateMethod,
const QStringList& _args,
// /*OUT*/ QVariantMap &_responseHeaders,
Expand All @@ -130,7 +130,7 @@ class clsAPIObject : public intfAPIObject, public QObject
) const;

void invokeMethod(
intfAPICallBoom* _APICALLBOOM,
INTFAPICALLBOOM_DECL *_APICALLBOOM,
const QVariantList& _arguments,
QGenericReturnArgument _returnArg
// /*OUT*/ QVariantMap &_responseHeaders
Expand Down
26 changes: 21 additions & 5 deletions Interfaces/AAA/Accounting_Defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,31 @@
namespace Targoman::API::AAA {

TARGOMAN_DEFINE_ENUM(enuVoucherStatus,
New = 'N',
Canceled = 'C',
Error = 'E',
Finished = 'F',
Removed = 'R',
New = 'N',
Canceled = 'C',
Error = 'E',
Finished = 'F',
// WaitForProcess = 'W',
Removed = 'R',
);

TARGOMAN_DEFINE_ENUM(enuDiscountType,
Percent = '%',
Currency = '$',
);

TARGOMAN_DEFINE_ENUM(enuVoucherItemProcessStatus,
Canceled = 'C',
Error = 'E',
Finished = 'F',
Removed = 'R',
);

} //namespace Targoman::API::AAA

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

namespace Targoman::API::AAA {

Expand Down Expand Up @@ -248,6 +259,11 @@ TAPI_DEFINE_VARIANT_ENABLED_STRUCT(stuVoucher,
SF_Enum(enuVoucherStatus, Status, enuVoucherStatus::New)
);

//TAPI_DEFINE_VARIANT_ENABLED_STRUCT(stuVoucherItemProcess,
// SF_MD5_t(UUID),
// SF_NULLABLE_Enum(enuVoucherItemProcessStatus, Status)
//);

//bool KKKKKKKKKKKKKKKKKK() {return true;}

typedef QMap<QString, qint32> ServiceUsage_t;
Expand Down
81 changes: 41 additions & 40 deletions Interfaces/AAA/Accounting_Interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ TAPI_REGISTER_METATYPE(

TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuVoucherStatus);
TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuDiscountType);
TAPI_REGISTER_TARGOMAN_ENUM(Targoman::API::AAA, enuVoucherItemProcessStatus);

namespace Targoman::API::AAA {

Expand Down Expand Up @@ -244,29 +245,29 @@ intfAccountProducts::intfAccountProducts(
}) + _exclusiveIndexes
) { ; }

QVariant intfAccountProducts::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
QVariant IMPL_ORMGET(intfAccountProducts) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_GET, this->moduleBaseName()));

constexpr quint16 CACHE_TIME = 15 * 60;
return /*Targoman::API::Query::*/this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL, {}, CACHE_TIME);
return this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM, {}, CACHE_TIME);
}

quint32 intfAccountProducts::apiCREATE(CREATE_METHOD_ARGS_IMPL_APICALL) {
quint32 IMPL_ORMCREATE(intfAccountProducts) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PUT, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountProducts::apiUPDATE(UPDATE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMUPDATE(intfAccountProducts) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PATCH, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountProducts::apiDELETE(DELETE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMDELETE(intfAccountProducts) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_DELETE, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

/******************************************************************/
Expand Down Expand Up @@ -326,7 +327,7 @@ intfAccountSaleables::intfAccountSaleables(
}) + _exclusiveIndexes
) { ; }

QVariant intfAccountSaleables::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
QVariant IMPL_ORMGET(intfAccountSaleables) {
// QString ExtraFilters;
// if (Authorization::hasPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_GET, this->moduleBaseName())) == false)
// ExtraFilters = QString ("%1<=NOW() + ( %2=NULL | %2>=DATE_ADD(NOW(),INTERVAL$SPACE$15$SPACEMIN) )")
Expand All @@ -343,25 +344,25 @@ QVariant intfAccountSaleables::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
);

constexpr quint16 CACHE_TIME = 15 * 60;
return /*Targoman::API::Query::*/this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL, ExtraFilters, CACHE_TIME);
return this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM, ExtraFilters, CACHE_TIME);
}

quint32 intfAccountSaleables::apiCREATE(CREATE_METHOD_ARGS_IMPL_APICALL) {
quint32 IMPL_ORMCREATE(intfAccountSaleables) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PUT, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountSaleables::apiUPDATE(UPDATE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMUPDATE(intfAccountSaleables) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PATCH, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountSaleables::apiDELETE(DELETE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMDELETE(intfAccountSaleables) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_DELETE, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

/******************************************************************/
Expand Down Expand Up @@ -415,17 +416,17 @@ intfAccountUserAssets::intfAccountUserAssets(
}) + _exclusiveIndexes
) { ; }

QVariant intfAccountUserAssets::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
QVariant IMPL_ORMGET(intfAccountUserAssets) {
if (Authorization::hasPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_GET, this->moduleBaseName())) == false)
this->setSelfFilters({{tblAccountUserAssetsBase::uas_usrID, _APICALLBOOM.getUserID() }}, _filters);

return /*Targoman::API::Query::*/this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM);
}

bool intfAccountUserAssets::apiUPDATEsetAsPrefered(
bool IMPL_REST_UPDATE(intfAccountUserAssets, setAsPrefered, (
APICALLBOOM_TYPE_JWT_IMPL &APICALLBOOM_PARAM,
TAPI::PKsByPath_t _pksByPath
) {
)) {
bool Ok;
quint64 UserPackageID = _pksByPath.toUInt(&Ok);
if (!Ok || !UserPackageID )
Expand All @@ -438,10 +439,10 @@ bool intfAccountUserAssets::apiUPDATEsetAsPrefered(
return false;
}

bool intfAccountUserAssets::apiUPDATEdisablePackage(
bool IMPL_REST_UPDATE(intfAccountUserAssets, disablePackage, (
APICALLBOOM_TYPE_JWT_IMPL &APICALLBOOM_PARAM,
TAPI::PKsByPath_t _pksByPath
) {
)) {
bool Ok;
quint64 UserPackageID = _pksByPath.toUInt(&Ok);
if (!Ok || !UserPackageID )
Expand Down Expand Up @@ -479,11 +480,11 @@ intfSQLBasedModule(
)
{ ; }

QVariant intfAccountAssetUsage::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
QVariant IMPL_ORMGET(intfAccountAssetUsage) {
if (Authorization::hasPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_GET, this->moduleBaseName())) == false)
this->setSelfFilters({{tblAccountUserAssetsBase::uas_usrID, _APICALLBOOM.getUserID()}}, _filters);

return /*Targoman::API::Query::*/this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM);
}

/******************************************************************/
Expand Down Expand Up @@ -535,32 +536,32 @@ intfAccountCoupons::intfAccountCoupons(
}
) { ; }

QVariant intfAccountCoupons::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
QVariant IMPL_ORMGET(intfAccountCoupons) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_GET, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM);

// return query.one();

// return this->selectFromTable({}, {}, GET_METHOD_CALL_ARGS_APICALL);
}

quint32 intfAccountCoupons::apiCREATE(CREATE_METHOD_ARGS_IMPL_APICALL) {
quint32 IMPL_ORMCREATE(intfAccountCoupons) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PUT, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountCoupons::apiUPDATE(UPDATE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMUPDATE(intfAccountCoupons) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PATCH, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountCoupons::apiDELETE(DELETE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMDELETE(intfAccountCoupons) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_DELETE, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

/******************************************************************/
Expand All @@ -577,32 +578,32 @@ intfAccountPrizes::intfAccountPrizes(
_relations
) { ; }

QVariant intfAccountPrizes::apiGET(GET_METHOD_ARGS_IMPL_APICALL) {
QVariant IMPL_ORMGET(intfAccountPrizes) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_GET, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Select(*this, GET_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM);

// return query.one();

// return this->selectFromTable({}, {}, GET_METHOD_CALL_ARGS_APICALL);
}

quint32 intfAccountPrizes::apiCREATE(CREATE_METHOD_ARGS_IMPL_APICALL) {
quint32 IMPL_ORMCREATE(intfAccountPrizes) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PUT, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Create(*this, CREATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountPrizes::apiUPDATE(UPDATE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMUPDATE(intfAccountPrizes) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_PATCH, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->Update(*this, UPDATE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

bool intfAccountPrizes::apiDELETE(DELETE_METHOD_ARGS_IMPL_APICALL) {
bool IMPL_ORMDELETE(intfAccountPrizes) {
Authorization::checkPriv(_APICALLBOOM.getJWT(), this->privOn(EHTTP_DELETE, this->moduleBaseName()));

return /*Targoman::API::Query::*/this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL);
return this->DeleteByPks(*this, DELETE_METHOD_CALL_ARGS_INTERNAL_CALL_BOOM2USER);
}

//} //namespace Targoman::API::AAA {
Expand Down
4 changes: 2 additions & 2 deletions Interfaces/AAA/Authorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ void checkPriv(const TAPI::JWT_t &_jwt, const QStringList &_requiredAccess, bool
throw exAuthorization("Not enought privileges: required are <" + _requiredAccess.join("|") + ">");
}

QVariant getPrivValue(const TAPI::JWT_t &_jwt, QString _accessItem) {
QVariant getPrivValue(const TAPI::JWT_t &_jwt, QString _accessItem, const QVariant &_defIfNotFoundAndAllIsDefined) {
QJsonObject Privs = privObjectFromInfo(_jwt);

if (Privs.isEmpty())
return QVariant();

return PrivHelpers::getPrivValue(Privs, _accessItem);
return PrivHelpers::getPrivValue(Privs, _accessItem, _defIfNotFoundAndAllIsDefined);
}

QJsonObject privObjectFromInfo(const QJsonObject& _info) {
Expand Down
2 changes: 1 addition & 1 deletion Interfaces/AAA/Authorization.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Targoman::API::AAA::Authorization {
extern bool hasPriv(const TAPI::JWT_t& _jwt, const QStringList& _requiredAccess, bool _isSelf = false);
extern void checkPriv(const TAPI::JWT_t& _jwt, const QStringList& _requiredAccess, bool _isSelf = false);
extern QJsonObject privObjectFromInfo(const QJsonObject& _info);
extern QVariant getPrivValue(const TAPI::JWT_t &_jwt, QString _accessItem);
extern QVariant getPrivValue(const TAPI::JWT_t &_jwt, QString _accessItem, const QVariant &_defIfNotFoundAndAllIsDefined = {});

} // namespace Targoman::API::AAA::Authorization

Expand Down
Loading