mirror of
				https://github.com/Telecominfraproject/wlan-cloud-owprov.git
				synced 2025-11-03 20:17:54 +00:00 
			
		
		
		
	Refactor Project Layout.
This commit is contained in:
		
							
								
								
									
										54
									
								
								src/RESTAPI/RESTAPI_location_list_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/RESTAPI/RESTAPI_location_list_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
//
 | 
			
		||||
// Created by stephane bourque on 2021-08-23.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "RESTAPI_location_list_handler.h"
 | 
			
		||||
#include "framework/Utils.h"
 | 
			
		||||
#include "RESTAPI_ProvObjects.h"
 | 
			
		||||
#include "StorageService.h"
 | 
			
		||||
#include "framework/RESTAPI_errors.h"
 | 
			
		||||
#include "RESTAPI/RESTAPI_db_helpers.h"
 | 
			
		||||
 | 
			
		||||
namespace OpenWifi{
 | 
			
		||||
 | 
			
		||||
    void RESTAPI_location_list_handler::DoGet() {
 | 
			
		||||
        if(!QB_.Select.empty()) {
 | 
			
		||||
            auto DevUUIDS = Utils::Split(QB_.Select);
 | 
			
		||||
            Poco::JSON::Array   ObjArr;
 | 
			
		||||
            for(const auto &i:DevUUIDS) {
 | 
			
		||||
                ProvObjects::Location E;
 | 
			
		||||
                if(Storage()->LocationDB().GetRecord("id",i,E)) {
 | 
			
		||||
                    Poco::JSON::Object  Obj;
 | 
			
		||||
                    E.to_json(Obj);
 | 
			
		||||
                    if(QB_.AdditionalInfo)
 | 
			
		||||
                        AddLocationExtendedInfo(E, Obj);
 | 
			
		||||
                    ObjArr.add(Obj);
 | 
			
		||||
                } else {
 | 
			
		||||
                    return BadRequest(RESTAPI::Errors::UnknownId + " ("+i+")");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            Poco::JSON::Object  Answer;
 | 
			
		||||
            Answer.set("locations", ObjArr);
 | 
			
		||||
            return ReturnObject(Answer);
 | 
			
		||||
        } else if(QB_.CountOnly) {
 | 
			
		||||
            Poco::JSON::Object  Answer;
 | 
			
		||||
            auto C = Storage()->LocationDB().Count();
 | 
			
		||||
            return ReturnCountOnly(C);
 | 
			
		||||
        } else {
 | 
			
		||||
            ProvObjects::LocationVec Locations;
 | 
			
		||||
            Storage()->LocationDB().GetRecords(QB_.Offset,QB_.Limit,Locations);
 | 
			
		||||
 | 
			
		||||
            Poco::JSON::Array   ObjArray;
 | 
			
		||||
            for(const auto &i:Locations) {
 | 
			
		||||
                Poco::JSON::Object  Obj;
 | 
			
		||||
                i.to_json(Obj);
 | 
			
		||||
                if(QB_.AdditionalInfo)
 | 
			
		||||
                    AddLocationExtendedInfo(i, Obj);
 | 
			
		||||
                ObjArray.add(Obj);
 | 
			
		||||
            }
 | 
			
		||||
            Poco::JSON::Object  Answer;
 | 
			
		||||
            Answer.set("locations",ObjArray);
 | 
			
		||||
            return ReturnObject(Answer);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user