mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralsec.git
synced 2025-11-02 19:57:46 +00:00
Refactoring project layout
This commit is contained in:
@@ -7,57 +7,23 @@
|
||||
//
|
||||
|
||||
#include "StorageService.h"
|
||||
#include "Daemon.h"
|
||||
#include "Poco/Util/Application.h"
|
||||
#include "framework/Utils.h"
|
||||
#include "framework/MicroService.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
class Storage *Storage::instance_ = nullptr;
|
||||
|
||||
std::string Storage::ConvertParams(const std::string & S) const {
|
||||
std::string R;
|
||||
|
||||
R.reserve(S.size()*2+1);
|
||||
|
||||
if(dbType_==pgsql) {
|
||||
auto Idx=1;
|
||||
for(auto const & i:S)
|
||||
{
|
||||
if(i=='?') {
|
||||
R += '$';
|
||||
R.append(std::to_string(Idx++));
|
||||
} else {
|
||||
R += i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
R = S;
|
||||
}
|
||||
return R;
|
||||
}
|
||||
|
||||
int Storage::Start() {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
|
||||
Logger_.setLevel(Poco::Message::PRIO_NOTICE);
|
||||
Logger_.notice("Starting.");
|
||||
std::string DBType = Daemon()->ConfigGetString("storage.type");
|
||||
if (DBType == "sqlite") {
|
||||
Setup_SQLite();
|
||||
} else if (DBType == "postgresql") {
|
||||
Setup_PostgreSQL();
|
||||
} else if (DBType == "mysql") {
|
||||
Setup_MySQL();
|
||||
}
|
||||
|
||||
StorageClass::Start();
|
||||
Create_Tables();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Storage::Stop() {
|
||||
Logger_.notice("Stopping.");
|
||||
StorageClass::Stop();
|
||||
}
|
||||
}
|
||||
// namespace
|
||||
Reference in New Issue
Block a user