mirror of
				https://github.com/Telecominfraproject/wlan-cloud-owprov.git
				synced 2025-10-31 10:37:57 +00:00 
			
		
		
		
	Finishing DB refactor.
This commit is contained in:
		| @@ -6,22 +6,13 @@ | ||||
|  | ||||
| #include "RESTObjects/RESTAPI_ProvObjects.h" | ||||
| #include "StorageService.h" | ||||
| #include "framework/RESTAPI_errors.h" | ||||
| #include "RESTAPI_db_helpers.h" | ||||
|  | ||||
| namespace OpenWifi{ | ||||
|     void RESTAPI_configurations_list_handler::DoGet() { | ||||
|         if(!QB_.Select.empty()) { | ||||
|             auto DevUUIDS = Utils::Split(QB_.Select); | ||||
|             ProvObjects::DeviceConfigurationVec Configs; | ||||
|             for(const auto &i:DevUUIDS) { | ||||
|                 ProvObjects::DeviceConfiguration E; | ||||
|                 if(StorageService()->ConfigurationDB().GetRecord("id",i,E)) { | ||||
|                     Configs.push_back(E); | ||||
|                 } else { | ||||
|                     return BadRequest(RESTAPI::Errors::UnknownId + " (" + i + ")"); | ||||
|                 } | ||||
|             } | ||||
|             return ReturnObject("configurations", Configs); | ||||
|             return ReturnRecordList<decltype(StorageService()->ConfigurationDB()), | ||||
|                     ProvObjects::DeviceConfiguration>("configurations",StorageService()->ConfigurationDB(),*this ); | ||||
|         } else if(QB_.CountOnly) { | ||||
|             Poco::JSON::Object  Answer; | ||||
|             auto C = StorageService()->ConfigurationDB().Count(); | ||||
| @@ -29,31 +20,7 @@ namespace OpenWifi{ | ||||
|         } else { | ||||
|             ProvObjects::DeviceConfigurationVec Configs; | ||||
|             StorageService()->ConfigurationDB().GetRecords(QB_.Offset,QB_.Limit,Configs); | ||||
|  | ||||
|             if(QB_.AdditionalInfo) { | ||||
|                 Poco::JSON::Array   ObjArray; | ||||
|                 for(const auto &i:Configs) { | ||||
|                     Poco::JSON::Object  Obj; | ||||
|                     i.to_json(Obj); | ||||
|                     Poco::JSON::Object  EI; | ||||
|  | ||||
|                     if(!i.managementPolicy.empty()) { | ||||
|                         Poco::JSON::Object  PolObj; | ||||
|                         ProvObjects::ManagementPolicy Policy; | ||||
|                         if(StorageService()->PolicyDB().GetRecord("id",i.managementPolicy,Policy)) { | ||||
|                             PolObj.set( "name", Policy.info.name); | ||||
|                             PolObj.set( "description", Policy.info.description); | ||||
|                         } | ||||
|                         EI.set("managementPolicy",PolObj); | ||||
|                     } | ||||
|                     Obj.set("extendedInfo", EI); | ||||
|                     ObjArray.add(Obj); | ||||
|                 } | ||||
|                 Poco::JSON::Object  Answer; | ||||
|                 Answer.set("locations",ObjArray); | ||||
|                 return ReturnObject(Answer); | ||||
|             } | ||||
|             return ReturnObject("configurations", Configs); | ||||
|             return MakeJSONObjectArray("configurations", Configs, *this); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 stephb9959
					stephb9959