mirror of
				https://github.com/Telecominfraproject/wlan-cloud-owprov.git
				synced 2025-10-31 18:48:09 +00:00 
			
		
		
		
	Fixing list handlers
This commit is contained in:
		| @@ -211,4 +211,37 @@ namespace OpenWifi { | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     template <typename DB> void ListHandler(const char *BlockName,DB & DBInstance, RESTAPIHandler & R) { | ||||
|         auto Entity = R.GetParameter("entity", ""); | ||||
|         auto Venue = R.GetParameter("venue", ""); | ||||
|  | ||||
|         typedef typename DB::RecordVec      RecVec; | ||||
|         typedef typename DB::RecordName     RecType; | ||||
|  | ||||
|         if(!R.QB_.Select.empty()) { | ||||
|             return ReturnRecordList<decltype(DBInstance), | ||||
|                     RecType>(BlockName, DBInstance, R); | ||||
|         } if(!Entity.empty()) { | ||||
|             RecVec Entries; | ||||
|             DBInstance.GetRecords(R.QB_.Offset,R.QB_.Limit,Entries," entity=' " + Entity +"'"); | ||||
|             if(R.QB_.CountOnly) | ||||
|                 return R.ReturnCountOnly(Entries.size()); | ||||
|             return MakeJSONObjectArray(BlockName, Entries, R); | ||||
|         } if(!Venue.empty()) { | ||||
|             RecVec Entries; | ||||
|             DBInstance.GetRecords(R.QB_.Offset,R.QB_.Limit,Entries," venue=' " + Venue +"'"); | ||||
|             if(R.QB_.CountOnly) | ||||
|                 return R.ReturnCountOnly(Entries.size()); | ||||
|             return MakeJSONObjectArray(BlockName, Entries, R); | ||||
|         } else if(R.QB_.CountOnly) { | ||||
|             Poco::JSON::Object  Answer; | ||||
|             auto C = DBInstance.Count(); | ||||
|             return R.ReturnCountOnly(C); | ||||
|         } else { | ||||
|             RecVec Entries; | ||||
|             DBInstance.GetRecords(R.QB_.Offset,R.QB_.Limit,Entries); | ||||
|             return MakeJSONObjectArray(BlockName, Entries, R); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 stephb9959
					stephb9959