mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Adding contact and location for subscriberDevices.
This commit is contained in:
@@ -585,12 +585,6 @@ components:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
operatorId:
|
||||
type: string
|
||||
format: uuid
|
||||
subscriberDeviceId:
|
||||
type: string
|
||||
format: uuid
|
||||
geoCode:
|
||||
type: string
|
||||
|
||||
@@ -754,12 +748,6 @@ components:
|
||||
type: string
|
||||
accessPIN:
|
||||
type: string
|
||||
operatorId:
|
||||
type: string
|
||||
format: uuid
|
||||
subscriberDeviceId:
|
||||
type: string
|
||||
format: uuid
|
||||
|
||||
DeviceConfigurationElement:
|
||||
type: object
|
||||
|
||||
@@ -47,8 +47,6 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if( !ValidDbId(NewObject.managementPolicy, StorageService()->PolicyDB(), true , RESTAPI::Errors::UnknownManagementPolicyUUID, *this) ||
|
||||
!ValidDbId(NewObject.contact, StorageService()->OpContactDB(), true, RESTAPI::Errors::InvalidContactId, *this) ||
|
||||
!ValidDbId(NewObject.location, StorageService()->OpLocationDB(), true, RESTAPI::Errors::InvalidLocationId, *this) ||
|
||||
!ValidDbId(NewObject.operatorId, StorageService()->OperatorDB(), true, RESTAPI::Errors::InvalidOperatorId, *this) ||
|
||||
!ValidDbId(NewObject.serviceClass, StorageService()->ServiceClassDB(), true, RESTAPI::Errors::InvalidServiceClassId, *this) ||
|
||||
!ValidSubscriberId(NewObject.subscriberId, true, *this) ||
|
||||
@@ -77,8 +75,6 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if( !ValidDbId(UpdateObj.managementPolicy, StorageService()->PolicyDB(), true , RESTAPI::Errors::UnknownManagementPolicyUUID, *this) ||
|
||||
!ValidDbId(UpdateObj.contact, StorageService()->OpContactDB(), true, RESTAPI::Errors::InvalidContactId, *this) ||
|
||||
!ValidDbId(UpdateObj.location, StorageService()->OpLocationDB(), true, RESTAPI::Errors::InvalidLocationId, *this) ||
|
||||
!ValidDbId(UpdateObj.operatorId, StorageService()->OperatorDB(), true, RESTAPI::Errors::InvalidOperatorId, *this) ||
|
||||
!ValidDbId(UpdateObj.serviceClass, StorageService()->ServiceClassDB(), true, RESTAPI::Errors::InvalidServiceClassId, *this) ||
|
||||
!ValidSubscriberId(UpdateObj.subscriberId, true, *this) ||
|
||||
@@ -91,8 +87,6 @@ namespace OpenWifi {
|
||||
ProvObjects::UpdateObjectInfo(RawObject,UserInfo_.userinfo,Existing.info);
|
||||
AssignIfPresent(RawObject, "deviceType", Existing.deviceType);
|
||||
AssignIfPresent(RawObject, "subscriberId", Existing.subscriberId);
|
||||
AssignIfPresent(RawObject, "location", Existing.location);
|
||||
AssignIfPresent(RawObject, "contact", Existing.contact);
|
||||
AssignIfPresent(RawObject, "managementPolicy", Existing.managementPolicy);
|
||||
AssignIfPresent(RawObject, "serviceClass", Existing.serviceClass);
|
||||
AssignIfPresent(RawObject, "qrCode", Existing.qrCode);
|
||||
@@ -102,6 +96,8 @@ namespace OpenWifi {
|
||||
AssignIfPresent(RawObject, "locale", Existing.locale);
|
||||
AssignIfPresent(RawObject, "billingCode", Existing.billingCode);
|
||||
AssignIfPresent(RawObject, "realMacAddress", Existing.realMacAddress);
|
||||
AssignIfPresent(RawObject, "contact", UpdateObj.contact, Existing.contact);
|
||||
AssignIfPresent(RawObject, "location", UpdateObj.location, Existing.location);
|
||||
|
||||
if(RawObject->has("configuration")) {
|
||||
Existing.configuration = UpdateObj.configuration;
|
||||
|
||||
@@ -398,6 +398,38 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SubLocation::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"type",type);
|
||||
field_to_json( Obj,"buildingName",buildingName);
|
||||
field_to_json( Obj,"addressLines",addressLines);
|
||||
field_to_json( Obj,"city",city);
|
||||
field_to_json( Obj,"state",state);
|
||||
field_to_json( Obj,"postal",postal);
|
||||
field_to_json( Obj,"country",country);
|
||||
field_to_json( Obj,"phones",phones);
|
||||
field_to_json( Obj,"mobiles",mobiles);
|
||||
field_to_json( Obj,"geoCode",geoCode);
|
||||
}
|
||||
|
||||
bool SubLocation::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"type", type);
|
||||
field_from_json( Obj,"buildingName",buildingName);
|
||||
field_from_json( Obj,"addressLines",addressLines);
|
||||
field_from_json( Obj,"city",city);
|
||||
field_from_json( Obj,"state",state);
|
||||
field_from_json( Obj,"postal",postal);
|
||||
field_from_json( Obj,"country",country);
|
||||
field_from_json( Obj,"phones",phones);
|
||||
field_from_json( Obj,"mobiles",mobiles);
|
||||
field_from_json( Obj,"geoCode",geoCode);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OperatorLocationList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj, "locations", locations);
|
||||
}
|
||||
@@ -502,6 +534,42 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SubContact::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"type", type);
|
||||
field_to_json( Obj,"title",title);
|
||||
field_to_json( Obj,"salutation",salutation);
|
||||
field_to_json( Obj,"firstname",firstname);
|
||||
field_to_json( Obj,"lastname",lastname);
|
||||
field_to_json( Obj,"initials",initials);
|
||||
field_to_json( Obj,"visual",visual);
|
||||
field_to_json( Obj,"mobiles",mobiles);
|
||||
field_to_json( Obj,"phones",phones);
|
||||
field_to_json( Obj,"primaryEmail",primaryEmail);
|
||||
field_to_json( Obj,"secondaryEmail",secondaryEmail);
|
||||
field_to_json( Obj,"accessPIN",accessPIN);
|
||||
}
|
||||
|
||||
bool SubContact::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"type", type);
|
||||
field_from_json( Obj,"title",title);
|
||||
field_from_json( Obj,"salutation",salutation);
|
||||
field_from_json( Obj,"firstname",firstname);
|
||||
field_from_json( Obj,"lastname",lastname);
|
||||
field_from_json( Obj,"initials",initials);
|
||||
field_from_json( Obj,"visual",visual);
|
||||
field_from_json( Obj,"mobiles",mobiles);
|
||||
field_from_json( Obj,"phones",phones);
|
||||
field_from_json( Obj,"primaryEmail",primaryEmail);
|
||||
field_from_json( Obj,"secondaryEmail",secondaryEmail);
|
||||
field_from_json( Obj,"accessPIN",accessPIN);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OperatorContactList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj, "contacts", contacts);
|
||||
}
|
||||
|
||||
@@ -221,6 +221,22 @@ namespace OpenWifi::ProvObjects {
|
||||
};
|
||||
typedef std::vector<Location> LocationVec;
|
||||
|
||||
struct SubLocation {
|
||||
std::string type;
|
||||
std::string buildingName;
|
||||
Types::StringVec addressLines;
|
||||
std::string city;
|
||||
std::string state;
|
||||
std::string postal;
|
||||
std::string country;
|
||||
Types::StringVec phones;
|
||||
Types::StringVec mobiles;
|
||||
std::string geoCode;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct OperatorLocationList {
|
||||
std::vector<OperatorLocation> locations;
|
||||
|
||||
@@ -314,6 +330,24 @@ namespace OpenWifi::ProvObjects {
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct SubContact {
|
||||
std::string type;
|
||||
std::string title;
|
||||
std::string salutation;
|
||||
std::string firstname;
|
||||
std::string lastname;
|
||||
std::string initials;
|
||||
std::string visual;
|
||||
Types::StringVec mobiles;
|
||||
Types::StringVec phones;
|
||||
std::string primaryEmail;
|
||||
std::string secondaryEmail;
|
||||
std::string accessPIN;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct OperatorContactList {
|
||||
std::vector<OperatorContact> contacts;
|
||||
|
||||
@@ -602,8 +636,8 @@ namespace OpenWifi::ProvObjects {
|
||||
std::string deviceType;
|
||||
Types::UUID_t operatorId;
|
||||
Types::UUID_t subscriberId;
|
||||
Types::UUID_t location;
|
||||
Types::UUID_t contact;
|
||||
SubLocation location;
|
||||
SubContact contact;
|
||||
Types::UUID_t managementPolicy;
|
||||
Types::UUID_t serviceClass;
|
||||
std::string qrCode;
|
||||
|
||||
@@ -1994,6 +1994,14 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T> bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, const T &value, T & assignee) {
|
||||
if(O->has(Field)) {
|
||||
assignee = value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void AddCORS() {
|
||||
auto Origin = Request->find("Origin");
|
||||
if (Origin != Request->end()) {
|
||||
|
||||
@@ -38,16 +38,16 @@ namespace OpenWifi {
|
||||
};
|
||||
|
||||
static ORM::IndexVec SubscriberDeviceDB_Indexes{
|
||||
{ std::string("subscriber_device_name_index"),
|
||||
{ std::string("subscriber_device_name_index2"),
|
||||
ORM::IndexEntryVec{ {std::string("name"), ORM::Indextype::ASC} } },
|
||||
{ std::string("subscriber_device_serialNumber_index"),
|
||||
{ std::string("subscriber_device_serialNumber_index2"),
|
||||
ORM::IndexEntryVec{ {std::string("serialNumber"), ORM::Indextype::ASC} } } ,
|
||||
{ std::string("subscriber_device_realMacAddress_index"),
|
||||
{ std::string("subscriber_device_realMacAddress_index2"),
|
||||
ORM::IndexEntryVec{ {std::string("realMacAddress"), ORM::Indextype::ASC} } }
|
||||
};
|
||||
|
||||
SubscriberDeviceDB::SubscriberDeviceDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
||||
DB(T, "sub_devices", SubscriberDeviceDB_Fields, SubscriberDeviceDB_Indexes, P, L, "sdv") {
|
||||
DB(T, "sub_devices2", SubscriberDeviceDB_Fields, SubscriberDeviceDB_Indexes, P, L, "sdv") {
|
||||
}
|
||||
|
||||
bool SubscriberDeviceDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
|
||||
@@ -70,8 +70,8 @@ template<> void ORM::DB< OpenWifi::SubDeviceDBRecordType, OpenWifi::ProvObjec
|
||||
Out.deviceType = In.get<7>();
|
||||
Out.operatorId = In.get<8>();
|
||||
Out.subscriberId = In.get<9>();
|
||||
Out.location = In.get<10>();
|
||||
Out.contact = In.get<11>();
|
||||
Out.location = OpenWifi::RESTAPI_utils::to_object<OpenWifi::ProvObjects::SubLocation>(In.get<10>());
|
||||
Out.contact = OpenWifi::RESTAPI_utils::to_object<OpenWifi::ProvObjects::SubContact>(In.get<11>());
|
||||
Out.managementPolicy = In.get<12>();
|
||||
Out.serviceClass = In.get<13>();
|
||||
Out.qrCode = In.get<14>();
|
||||
@@ -96,8 +96,8 @@ template<> void ORM::DB< OpenWifi::SubDeviceDBRecordType, OpenWifi::ProvObjec
|
||||
Out.set<7>(In.deviceType);
|
||||
Out.set<8>(In.operatorId);
|
||||
Out.set<9>(In.subscriberId);
|
||||
Out.set<10>(In.location);
|
||||
Out.set<11>(In.contact);
|
||||
Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.location));
|
||||
Out.set<11>(OpenWifi::RESTAPI_utils::to_string(In.contact));
|
||||
Out.set<12>(In.managementPolicy);
|
||||
Out.set<13>(In.serviceClass);
|
||||
Out.set<14>(In.qrCode);
|
||||
@@ -110,12 +110,3 @@ template<> void ORM::DB< OpenWifi::SubDeviceDBRecordType, OpenWifi::ProvObjec
|
||||
Out.set<21>(In.suspended);
|
||||
Out.set<22>(In.realMacAddress);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
$ cmake3 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr -DLibCrypto_INCLUDE_DIR=/usr/include -DLibCrypto_LIBRARY=/usr/lib64/libcrypto.so ..
|
||||
|
||||
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user