mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 03:27:51 +00:00
Adding devices /sub + op
This commit is contained in:
@@ -304,12 +304,16 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename db_type> void ListHandlerForOperator(const char *BlockName,db_type & DB, RESTAPIHandler & R, const Types::UUID_t & OperatorId ) {
|
||||
template <typename db_type> void ListHandlerForOperator(const char *BlockName,db_type & DB, RESTAPIHandler & R, const Types::UUID_t & OperatorId, const Types::UUID_t & subscriberId="") {
|
||||
typedef typename db_type::RecordVec RecVec;
|
||||
typedef typename db_type::RecordName RecType;
|
||||
|
||||
auto whereClause = subscriberId.empty() ?
|
||||
fmt::format(" operatorId='{}'", OperatorId) :
|
||||
fmt::format(" operatorId='{}' and subscriberId='{}' ", OperatorId, subscriberId);
|
||||
|
||||
if(R.QB_.CountOnly) {
|
||||
auto Count = DB.Count( fmt::format(" operatorId='{}'", OperatorId) );
|
||||
auto Count = DB.Count( whereClause );
|
||||
return R.ReturnCountOnly(Count);
|
||||
}
|
||||
|
||||
@@ -319,7 +323,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
RecVec Entries;
|
||||
DB.GetRecords(R.QB_.Offset,R.QB_.Limit,Entries,fmt::format(" operatorId='{}'", OperatorId));
|
||||
DB.GetRecords(R.QB_.Offset,R.QB_.Limit,Entries,whereClause);
|
||||
return MakeJSONObjectArray(BlockName, Entries, R);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,13 @@ namespace OpenWifi {
|
||||
|
||||
void RESTAPI_sub_devices_list_handler::DoGet() {
|
||||
auto operatorId=GetParameter("operatorId");
|
||||
auto subscriberId=GetParameter("subscriberId");
|
||||
|
||||
if(operatorId.empty() || !StorageService()->OperatorDB().Exists("id",operatorId)) {
|
||||
return BadRequest(RESTAPI::Errors::OperatorIdMustExist);
|
||||
}
|
||||
|
||||
return ListHandlerForOperator<SubscriberDeviceDB>("subscriberDevices", DB_, *this, operatorId);
|
||||
return ListHandlerForOperator<SubscriberDeviceDB>("subscriberDevices", DB_, *this, operatorId, subscriberId);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user