Added manager classes for song metadata
This commit is contained in:
@@ -18,6 +18,9 @@ public:
|
||||
loginController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), exe_path(p)
|
||||
{ }
|
||||
loginController(const Model::BinaryPath& bConf, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
:oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf)
|
||||
{ }
|
||||
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
@@ -27,7 +30,8 @@ public:
|
||||
OATPP_LOGI("icarus", "logging in");
|
||||
|
||||
Manager::token_manager tok;
|
||||
auto token = tok.retrieve_token(exe_path);
|
||||
//auto token = tok.retrieve_token(exe_path);
|
||||
auto token = tok.retrieve_token(bconf);
|
||||
|
||||
auto logRes = loginResultDto::createShared();
|
||||
logRes->id = 0; // TODO: change this later on to something meaningful
|
||||
@@ -43,6 +47,7 @@ public:
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::string exe_path;
|
||||
Model::BinaryPath m_bConf;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
std::cout << "starting process of retrieving songs" << std::endl;
|
||||
songRepository songRepo(m_exe_path);
|
||||
Database::songRepository songRepo(m_exe_path);
|
||||
auto songsDb = songRepo.retrieveRecords();
|
||||
auto songs = oatpp::data::mapping::type::List<songDto::ObjectWrapper>::createShared();
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
ENDPOINT("GET", "/api/v1/song/{id}", songRecord,
|
||||
PATH(Int32, id)) {
|
||||
|
||||
songRepository songRepo(m_exe_path);
|
||||
Database::songRepository songRepo(m_exe_path);
|
||||
Model::Song songDb;
|
||||
songDb.id = id;
|
||||
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
ENDPOINT("GET", "/api/v1/song/data/{id}", downloadSong,
|
||||
PATH(Int32, id)) {
|
||||
|
||||
songRepository songRepo(m_exe_path);
|
||||
Database::songRepository songRepo(m_exe_path);
|
||||
Model::Song songDb;
|
||||
songDb.id = id;
|
||||
songDb = songRepo.retrieveRecord(songDb, songFilter::id);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "database/artistRepository.h"
|
||||
|
||||
Database::artistRepository::artistRepository(const Model::BinaryPath& binConf)
|
||||
: base_repository(binConf)
|
||||
{
|
||||
}
|
||||
+9
-5
@@ -17,14 +17,15 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void run(const std::string& working_path)
|
||||
//void run(const std::string& working_path)
|
||||
void run(const Model::BinaryPath& bConf)
|
||||
{
|
||||
appComponent component;
|
||||
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router);
|
||||
|
||||
auto logController = std::make_shared<loginController>(working_path);
|
||||
auto sngController = std::make_shared<songController>(working_path);
|
||||
auto logController = std::make_shared<loginController>(bConf);
|
||||
auto sngController = std::make_shared<songController>(bConf);
|
||||
logController->addEndpointsToRouter(router);
|
||||
sngController->addEndpointsToRouter(router);
|
||||
|
||||
@@ -42,9 +43,12 @@ void run(const std::string& working_path)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
oatpp::base::Environment::init();
|
||||
const std::string working_path = argv[0];
|
||||
//const std::string working_path = argv[0];
|
||||
Model::BinaryPath bConf;
|
||||
bConf.path = argv[0]
|
||||
|
||||
run(working_path);
|
||||
//run(working_path);
|
||||
run(bConf);
|
||||
|
||||
oatpp::base::Environment::destroy();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Model::Cover Manager::coverArtManager::saveCover(const Model::Song& song, std::s
|
||||
cov = meta.update_cover_art(song, cov, stockCoverPath);
|
||||
cov.songTitle = song.title;
|
||||
|
||||
coverArtRepository covRepo(path);
|
||||
Database::coverArtRepository covRepo(path);
|
||||
std::cout << "saving record to the database" << std::endl;
|
||||
covRepo.saveRecord(cov);
|
||||
std::cout << "retrieving record from database" << std::endl;
|
||||
|
||||
@@ -49,14 +49,14 @@ void Manager::song_manager::saveSong(Model::Song& song)
|
||||
|
||||
printSong(song);
|
||||
|
||||
songRepository songRepo(exe_path);
|
||||
Database::songRepository songRepo(exe_path);
|
||||
songRepo.saveRecord(song);
|
||||
}
|
||||
|
||||
void Manager::song_manager::deleteSong(Model::Song& song)
|
||||
{
|
||||
coverArtRepository covRepo(exe_path);
|
||||
songRepository songRepo(exe_path);
|
||||
Database::coverArtRepository covRepo(exe_path);
|
||||
Database::songRepository songRepo(exe_path);
|
||||
|
||||
song = songRepo.retrieveRecord(song, songFilter::id);
|
||||
songRepo.deleteRecord(song);
|
||||
|
||||
@@ -104,6 +104,23 @@ Model::auth_credentials Manager::token_manager::parse_auth_credentials(std::stri
|
||||
|
||||
return auth;
|
||||
}
|
||||
Model::auth_credentials Manager::token_manager::parse_auth_credentials(const BinaryPath& bConf)
|
||||
{
|
||||
auto exePath = Manager::directory_manager::configPath(bConf);
|
||||
exe_path.append("/auth_credentials.json");
|
||||
|
||||
auto con = Manager::directory_manager::credentialConfigContent(exePath);
|
||||
|
||||
Model::auth_credentials auth;
|
||||
auth.uri = "https://";
|
||||
auth.uri.append(con["domain"]);
|
||||
auth.api_identifier = con["api_identifier"];
|
||||
auth.client_id = con["client_id"];
|
||||
auth.client_secret = con["client_secret"];
|
||||
auth.endpoint = "oauth/token";
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
std::vector<std::string> Manager::token_manager::extract_scopes(const jwt::decoded_jwt&& decoded)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user