From 414714ae4383dfe1c537b686ff642a118d813e39 Mon Sep 17 00:00:00 2001 From: kambizzandi Date: Wed, 7 Sep 2022 17:37:28 +0430 Subject: [PATCH] ssid and address added to user --- Interfaces/AAA/AAADefs.hpp | 46 +++++++++++-------- ...62657_AAA_add_ssid_and_address_to_user.sql | 8 ++++ Modules/Account/moduleSrc/ORM/User.cpp | 8 +++- Modules/Account/moduleSrc/ORM/User.h | 4 +- 4 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 Modules/Account/migrations/db/m20220907_162657_AAA_add_ssid_and_address_to_user.sql diff --git a/Interfaces/AAA/AAADefs.hpp b/Interfaces/AAA/AAADefs.hpp index 1e3d0e86..de190860 100644 --- a/Interfaces/AAA/AAADefs.hpp +++ b/Interfaces/AAA/AAADefs.hpp @@ -95,6 +95,8 @@ namespace tblUser { TARGOMAN_CREATE_CONSTEXPR(usrPass); TARGOMAN_CREATE_CONSTEXPR(usr_rolID); TARGOMAN_CREATE_CONSTEXPR(usrSpecialPrivs); + TARGOMAN_CREATE_CONSTEXPR(usrSSID); + TARGOMAN_CREATE_CONSTEXPR(usrAddress); TARGOMAN_CREATE_CONSTEXPR(usrLanguage); TARGOMAN_CREATE_CONSTEXPR(usrEnableEmailAlerts); TARGOMAN_CREATE_CONSTEXPR(usrEnableSMSAlerts); @@ -113,29 +115,31 @@ namespace tblUser { namespace Private { const QList ORMFields = { - ///ColName Type Validation Default UpBy Sort Filter Self Virt PK + //ColName Type Validation Default UpBy Sort Filter Self Virt PK //ORM_PRIMARYKEY_64 with self:true - { Fields::usrID, S(quint64), QFV.integer().minValue(1), QAuto, UPNone, true, true, true, false, true }, - { Fields::usrEmail, S(TAPI::Email_t), QFV.emailNotFake(), QNull, UPOwner }, - { Fields::usrName, S(QString), QFV.unicodeAlNum().maxLenght(128), QNull, UPOwner }, - { Fields::usrFamily, S(QString), QFV.unicodeAlNum().maxLenght(128), QNull, UPOwner }, - { Fields::usrGender, S(TAPI::enuGender::Type), QFV, TAPI::enuGender::NotExpressed, UPOwner }, - { Fields::usrMobile, S(TAPI::Mobile_t), QFV, QNull, UPOwner }, - { Fields::usrApprovalState, S(TAPI::enuUserApproval::Type), QFV, TAPI::enuUserApproval::None }, + { Fields::usrID, S(quint64), QFV.integer().minValue(1), QAuto, UPNone, true, true, true, false, true }, + { Fields::usrEmail, S(TAPI::Email_t), QFV.emailNotFake(), QNull, UPOwner }, + { Fields::usrName, S(QString), QFV.unicodeAlNum().maxLenght(128), QNull, UPOwner }, + { Fields::usrFamily, S(QString), QFV.unicodeAlNum().maxLenght(128), QNull, UPOwner }, + { Fields::usrGender, S(TAPI::enuGender::Type), QFV, TAPI::enuGender::NotExpressed, UPOwner }, + { Fields::usrMobile, S(TAPI::Mobile_t), QFV, QNull, UPOwner }, + { Fields::usrApprovalState, S(TAPI::enuUserApproval::Type), QFV, TAPI::enuUserApproval::None }, //usrPass : not define here - { Fields::usr_rolID, S(quint32), QFV.integer().minValue(1), QRequired, UPAdmin }, - { Fields::usrSpecialPrivs, S(TAPI::PrivObject_t), QFV, QNull, UPAdmin, false, false }, - { Fields::usrLanguage, S(QString), QFV.languageCode(), "fa", UPOwner }, - { Fields::usrEnableEmailAlerts, S(bool), QFV, true, UPOwner }, - { Fields::usrEnableSMSAlerts, S(bool), QFV, true, UPOwner }, - { Fields::usrMaxSessions, S(qint32), QFV.integer().betweenValues(-1, 100), -1, UPAdmin }, - { Fields::usrActiveSessions, S(qint32), QFV.integer().betweenValues(-1, 1000), QInvalid, UPNone }, - { Fields::usrLastLogin, S(TAPI::DateTime_t), QFV, QInvalid, UPNone }, - { Fields::usrStatus, ORM_STATUS_FIELD(TAPI::enuUserStatus, TAPI::enuUserStatus::MustValidate) }, + { Fields::usr_rolID, S(quint32), QFV.integer().minValue(1), QRequired, UPAdmin }, + { Fields::usrSpecialPrivs, S(TAPI::PrivObject_t), QFV, QNull, UPAdmin, false, false }, + { Fields::usrSSID, S(QString), QFV.unicodeAlNum().maxLenght(10), QNull, UPOwner }, + { Fields::usrAddress, S(QString), QFV.unicodeAlNum().maxLenght(1024), QNull, UPOwner }, + { Fields::usrLanguage, S(QString), QFV.languageCode(), "fa", UPOwner }, + { Fields::usrEnableEmailAlerts, S(bool), QFV, true, UPOwner }, + { Fields::usrEnableSMSAlerts, S(bool), QFV, true, UPOwner }, + { Fields::usrMaxSessions, S(qint32), QFV.integer().betweenValues(-1, 100), -1, UPAdmin }, + { Fields::usrActiveSessions, S(qint32), QFV.integer().betweenValues(-1, 1000), QInvalid, UPNone }, + { Fields::usrLastLogin, S(TAPI::DateTime_t), QFV, QInvalid, UPNone }, + { Fields::usrStatus, ORM_STATUS_FIELD(TAPI::enuUserStatus, TAPI::enuUserStatus::MustValidate) }, { ORM_INVALIDATED_AT_FIELD }, - { Fields::usrCreationDateTime, ORM_CREATED_ON }, - { Fields::usrCreatedBy_usrID, ORM_CREATED_BY_NULLABLE }, - { Fields::usrUpdatedBy_usrID, ORM_UPDATED_BY }, + { Fields::usrCreationDateTime, ORM_CREATED_ON }, + { Fields::usrCreatedBy_usrID, ORM_CREATED_BY_NULLABLE }, + { Fields::usrUpdatedBy_usrID, ORM_UPDATED_BY }, }; ///Col Reference Table ForeignCol Rename LeftJoin @@ -170,6 +174,8 @@ namespace tblUser { SF_Enum (usrApprovalState, TAPI::enuUserApproval, TAPI::enuUserApproval::None), SF_quint32 (usr_rolID), SF_JSON_t (usrSpecialPrivs), + SF_QString (usrSSID), + SF_QString (usrAddress), SF_QString (usrLanguage), SF_bool (usrEnableEmailAlerts), SF_bool (usrEnableSMSAlerts), diff --git a/Modules/Account/migrations/db/m20220907_162657_AAA_add_ssid_and_address_to_user.sql b/Modules/Account/migrations/db/m20220907_162657_AAA_add_ssid_and_address_to_user.sql new file mode 100644 index 00000000..1bf207f9 --- /dev/null +++ b/Modules/Account/migrations/db/m20220907_162657_AAA_add_ssid_and_address_to_user.sql @@ -0,0 +1,8 @@ +/* Migration File: m20220907_162657_AAA_add_ssid_and_address_to_user.sql */ +/* CAUTION: don't forget to use {{dbprefix}} for schemas */ + +USE `{{dbprefix}}{{Schema}}`; + +ALTER TABLE `tblUser` + ADD COLUMN `usrSSID` VARCHAR(10) NULL DEFAULT NULL AFTER `usrSpecialPrivs`, + ADD COLUMN `usrAddress` VARCHAR(1024) NULL DEFAULT NULL AFTER `usrSSID`; diff --git a/Modules/Account/moduleSrc/ORM/User.cpp b/Modules/Account/moduleSrc/ORM/User.cpp index c82d39d7..db88d615 100644 --- a/Modules/Account/moduleSrc/ORM/User.cpp +++ b/Modules/Account/moduleSrc/ORM/User.cpp @@ -78,6 +78,8 @@ QVariant IMPL_ORMGET_USER(User) { tblUser::Fields::usrApprovalState, tblUser::Fields::usr_rolID, // tblUser::Fields::usrSpecialPrivs, + tblUser::Fields::usrSSID, + tblUser::Fields::usrAddress, tblUser::Fields::usrLanguage, tblUser::Fields::usrEnableEmailAlerts, tblUser::Fields::usrEnableSMSAlerts, @@ -299,7 +301,9 @@ bool IMPL_REST_UPDATE(User, personalInfo, ( TAPI::ISO639_2_t _language, NULLABLE_TYPE(TAPI::enuGender::Type) _gender, NULLABLE_TYPE(bool) _enableEmailAlerts, - NULLABLE_TYPE(bool) _enableSMSAlerts + NULLABLE_TYPE(bool) _enableSMSAlerts, + QString _ssid, + QString _address )) { quint64 CurrentUserID = APICALLBOOM_PARAM.getActorID(); @@ -311,6 +315,8 @@ bool IMPL_REST_UPDATE(User, personalInfo, ( if (NULLABLE_HAS_VALUE(_gender)) ToUpdate.insert(tblUser::Fields::usrGender, *_gender); if (NULLABLE_HAS_VALUE(_enableEmailAlerts)) ToUpdate.insert(tblUser::Fields::usrEnableEmailAlerts, *_enableEmailAlerts ? 1 : 0); if (NULLABLE_HAS_VALUE(_enableSMSAlerts)) ToUpdate.insert(tblUser::Fields::usrEnableSMSAlerts, *_enableSMSAlerts ? 1 : 0); + if (_ssid.isNull() == false) ToUpdate.insert(tblUser::Fields::usrSSID, _ssid); + if (_address.isNull() == false) ToUpdate.insert(tblUser::Fields::usrAddress, _address); if (ToUpdate.size()) this->Update(APICALLBOOM_PARAM, diff --git a/Modules/Account/moduleSrc/ORM/User.h b/Modules/Account/moduleSrc/ORM/User.h index 18dc6875..bd745b54 100644 --- a/Modules/Account/moduleSrc/ORM/User.h +++ b/Modules/Account/moduleSrc/ORM/User.h @@ -107,7 +107,9 @@ private slots: TAPI::ISO639_2_t _language = {}, NULLABLE_TYPE(TAPI::enuGender::Type) _gender = NULLABLE_NULL_VALUE, NULLABLE_TYPE(bool) _enableEmailAlerts = NULLABLE_NULL_VALUE, - NULLABLE_TYPE(bool) _enableSMSAlerts = NULLABLE_NULL_VALUE + NULLABLE_TYPE(bool) _enableSMSAlerts = NULLABLE_NULL_VALUE, + QString _ssid = {}, + QString _address = {} ), "Update User personal info" )