Code cleanup
This commit is contained in:
@@ -7,20 +7,19 @@
|
||||
#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp"
|
||||
|
||||
namespace callback {
|
||||
class StreamCallback : public oatpp::data::stream::ReadCallback
|
||||
{
|
||||
public:
|
||||
StreamCallback();
|
||||
StreamCallback(const std::string&);
|
||||
class StreamCallback : public oatpp::data::stream::ReadCallback {
|
||||
public:
|
||||
StreamCallback();
|
||||
StreamCallback(const std::string&);
|
||||
|
||||
oatpp::data::v_io_size read(void*, oatpp::data::v_io_size);
|
||||
private:
|
||||
std::string m_songPath;
|
||||
oatpp::data::v_io_size read(void*, oatpp::data::v_io_size);
|
||||
private:
|
||||
std::string m_songPath;
|
||||
|
||||
long m_bytesRead;
|
||||
long m_counter;
|
||||
long m_fileSize;
|
||||
};
|
||||
long m_bytesRead;
|
||||
long m_counter;
|
||||
long m_fileSize;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,29 +9,32 @@
|
||||
#include "oatpp/web/server/HttpConnectionHandler.hpp"
|
||||
|
||||
namespace component {
|
||||
class AppComponent {
|
||||
public:
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>,
|
||||
serverConnectionProvider)([&] {
|
||||
return oatpp::network::server::SimpleTCPConnectionProvider::
|
||||
createShared(appPort());
|
||||
}());
|
||||
|
||||
class AppComponent
|
||||
{
|
||||
public:
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] {
|
||||
return oatpp::network::server::SimpleTCPConnectionProvider::createShared(5002);
|
||||
}());
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, httpRouter)([] {
|
||||
return oatpp::web::server::HttpRouter::createShared();
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, httpRouter)([] {
|
||||
return oatpp::web::server::HttpRouter::createShared();
|
||||
}());
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::server::ConnectionHandler>,
|
||||
serverConnectionHandler)([] {
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router);
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::server::ConnectionHandler>, serverConnectionHandler)([] {
|
||||
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, router);
|
||||
return oatpp::web::server::HttpConnectionHandler::createShared(router);
|
||||
}());
|
||||
|
||||
return oatpp::web::server::HttpConnectionHandler::createShared(router);
|
||||
}());
|
||||
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>, apiObjectMapper)([] {
|
||||
return oatpp::parser::json::mapping::ObjectMapper::createShared();
|
||||
}());
|
||||
private:
|
||||
};
|
||||
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::data::mapping::ObjectMapper>,
|
||||
apiObjectMapper)([] {
|
||||
return oatpp::parser::json::mapping::ObjectMapper::createShared();
|
||||
}());
|
||||
private:
|
||||
constexpr int appPort() noexcept { return 5002; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,69 +29,66 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace controller {
|
||||
class AlbumController : public oatpp::web::server::api::ApiController
|
||||
{
|
||||
public:
|
||||
AlbumController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_exe_path(p)
|
||||
{ }
|
||||
class AlbumController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
AlbumController(const model::BinaryPath& bConf,
|
||||
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
|
||||
AlbumController(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)
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
// endpoint for retrieving all album records in json format
|
||||
ENDPOINT("GET", "/api/v1/album", albumRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveAlbum), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving all album records in json format
|
||||
ENDPOINT("GET", "/api/v1/album", albumRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveAlbum), Status::CODE_403, "Not allowed");
|
||||
std::cout << "starting process of retrieving album\n";
|
||||
database::AlbumRepository albRepo(m_bConf);
|
||||
auto albsDb = albRepo.retrieveRecords();
|
||||
auto albums = oatpp::data::mapping::type::
|
||||
List<dto::AlbumDto::ObjectWrapper>::createShared();
|
||||
|
||||
std::cout << "starting process of retrieving album" << std::endl;
|
||||
database::AlbumRepository albRepo(m_bConf);
|
||||
auto albsDb = albRepo.retrieveRecords();
|
||||
auto albums = oatpp::data::mapping::type::List<dto::AlbumDto::ObjectWrapper>::createShared();
|
||||
for (auto& albDb : albsDb) {
|
||||
auto alb = dto::conversion::DtoConversions::toAlbumDto(albDb);
|
||||
|
||||
for (auto& albDb : albsDb) {
|
||||
auto alb = dto::conversion::DtoConversions::toAlbumDto(albDb);
|
||||
albums->pushBack(alb);
|
||||
}
|
||||
|
||||
albums->pushBack(alb);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, albums);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, albums);
|
||||
}
|
||||
// endpoint for retrieving single album record by the album id in json format
|
||||
ENDPOINT("GET", "/api/v1/album/{id}", albumRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveAlbum), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving single album record by the album id in json format
|
||||
ENDPOINT("GET", "/api/v1/album/{id}", albumRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveAlbum), Status::CODE_403, "Not allowed");
|
||||
database::AlbumRepository albRepo(m_bConf);
|
||||
model::Album albDb(id);
|
||||
|
||||
database::AlbumRepository albRepo(m_bConf);
|
||||
model::Album albDb(id);
|
||||
OATPP_ASSERT_HTTP(albRepo.doesAlbumExists(albDb,
|
||||
type::AlbumFilter::id) , Status::CODE_403, "album does not exist");
|
||||
|
||||
OATPP_ASSERT_HTTP(albRepo.doesAlbumExists(albDb, type::AlbumFilter::id) , Status::CODE_403, "album does not exist");
|
||||
std::cout << "album exists\n";
|
||||
albDb = albRepo.retrieveRecord(albDb, type::AlbumFilter::id);
|
||||
|
||||
std::cout << "album exists" << std::endl;
|
||||
albDb = albRepo.retrieveRecord(albDb, type::AlbumFilter::id);
|
||||
auto album = dto::conversion::DtoConversions::toAlbumDto(albDb);
|
||||
|
||||
auto album = dto::conversion::DtoConversions::toAlbumDto(albDb);
|
||||
return createDtoResponse(Status::CODE_200, album);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, album);
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::string m_exe_path;
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,73 +28,70 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace controller {
|
||||
class ArtistController : public oatpp::web::server::api::ApiController
|
||||
{
|
||||
public:
|
||||
ArtistController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_exe_path(p)
|
||||
{ }
|
||||
class ArtistController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
ArtistController(const model::BinaryPath& bConf,
|
||||
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
|
||||
ArtistController(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)
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
// endpoint for retrieving all artist records in json format
|
||||
ENDPOINT("GET", "/api/v1/artist", artistRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveArtist), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving all artist records in json format
|
||||
ENDPOINT("GET", "/api/v1/artist", artistRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveArtist), Status::CODE_403, "Not allowed");
|
||||
std::cout << "starting process of retrieving artist\n";
|
||||
database::ArtistRepository artRepo(m_bConf);
|
||||
auto artsDb = artRepo.retrieveRecords();
|
||||
auto artists = oatpp::data::mapping::type::
|
||||
List<dto::ArtistDto::ObjectWrapper>::createShared();
|
||||
|
||||
std::cout << "starting process of retrieving artist" << std::endl;
|
||||
database::ArtistRepository artRepo(m_bConf);
|
||||
auto artsDb = artRepo.retrieveRecords();
|
||||
auto artists = oatpp::data::mapping::type::List<dto::ArtistDto::ObjectWrapper>::createShared();
|
||||
for (auto& artDb : artsDb) {
|
||||
auto art = dto::ArtistDto::createShared();
|
||||
art->id = artDb.id;
|
||||
art->artist = artDb.artist.c_str();
|
||||
|
||||
for (auto& artDb : artsDb) {
|
||||
auto art = dto::ArtistDto::createShared();
|
||||
art->id = artDb.id;
|
||||
art->artist = artDb.artist.c_str();
|
||||
artists->pushBack(art);
|
||||
}
|
||||
|
||||
artists->pushBack(art);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, artists);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, artists);
|
||||
}
|
||||
// endpoint for retrieving single artist record by the artist id in json format
|
||||
ENDPOINT("GET", "/api/v1/artist/{id}", artistRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveArtist), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving single artist record by the artist id in json format
|
||||
ENDPOINT("GET", "/api/v1/artist/{id}", artistRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveArtist), Status::CODE_403, "Not allowed");
|
||||
database::ArtistRepository artRepo(m_bConf);
|
||||
model::Artist artDb(id);
|
||||
|
||||
database::ArtistRepository artRepo(m_bConf);
|
||||
model::Artist artDb(id);
|
||||
OATPP_ASSERT_HTTP(artRepo.doesArtistExist(artDb,
|
||||
type::ArtistFilter::id) , Status::CODE_403, "artist does not exist");
|
||||
|
||||
OATPP_ASSERT_HTTP(artRepo.doesArtistExist(artDb, type::ArtistFilter::id) , Status::CODE_403, "artist does not exist");
|
||||
std::cout << "artist exist\n";
|
||||
artDb = artRepo.retrieveRecord(artDb, type::ArtistFilter::id);
|
||||
|
||||
std::cout << "artist exist" << std::endl;
|
||||
artDb = artRepo.retrieveRecord(artDb, type::ArtistFilter::id);
|
||||
auto artist = dto::ArtistDto::createShared();
|
||||
artist->id = artDb.id;
|
||||
artist->artist = artDb.artist.c_str();
|
||||
|
||||
auto artist = dto::ArtistDto::createShared();
|
||||
artist->id = artDb.id;
|
||||
artist->artist = artDb.artist.c_str();
|
||||
return createDtoResponse(Status::CODE_200, artist);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, artist);
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::string m_exe_path;
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,95 +27,93 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace controller {
|
||||
class CoverArtController : public oatpp::web::server::api::ApiController
|
||||
{
|
||||
public:
|
||||
CoverArtController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_exe_path(p)
|
||||
{ }
|
||||
class CoverArtController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
CoverArtController(const model::BinaryPath& bConf,
|
||||
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
|
||||
CoverArtController(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)
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
// endpoint for retrieving all cover art records in json format
|
||||
ENDPOINT("GET", "/api/v1/coverart", coverArtRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::downloadCoverArt), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving all cover art records in json format
|
||||
ENDPOINT("GET", "/api/v1/coverart", coverArtRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::downloadCoverArt), Status::CODE_403, "Not allowed");
|
||||
std::cout << "starting process of retrieving cover art\n";
|
||||
database::CoverArtRepository covRepo(m_bConf);
|
||||
auto covsDb = covRepo.retrieveRecords();
|
||||
auto coverArts = oatpp::data::mapping::type::
|
||||
List<dto::CoverArtDto::ObjectWrapper>::createShared();
|
||||
|
||||
std::cout << "starting process of retrieving cover art" << std::endl;
|
||||
database::CoverArtRepository covRepo(m_bConf);
|
||||
auto covsDb = covRepo.retrieveRecords();
|
||||
auto coverArts = oatpp::data::mapping::type::List<dto::CoverArtDto::ObjectWrapper>::createShared();
|
||||
for (auto& covDb : covsDb) {
|
||||
auto cov = dto::CoverArtDto::createShared();
|
||||
cov->id = covDb.id;
|
||||
cov->songTitle = covDb.songTitle.c_str();
|
||||
|
||||
for (auto& covDb : covsDb) {
|
||||
auto cov = dto::CoverArtDto::createShared();
|
||||
cov->id = covDb.id;
|
||||
cov->songTitle = covDb.songTitle.c_str();
|
||||
coverArts->pushBack(cov);
|
||||
}
|
||||
|
||||
coverArts->pushBack(cov);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, coverArts);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, coverArts);
|
||||
}
|
||||
// endpoint for retrieving single cover art record by the cover art id in json format
|
||||
ENDPOINT("GET", "/api/v1/coverart/{id}", coverArtRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::downloadCoverArt), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving single cover art record by the cover art id in json format
|
||||
ENDPOINT("GET", "/api/v1/coverart/{id}", coverArtRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::downloadCoverArt), Status::CODE_403, "Not allowed");
|
||||
database::CoverArtRepository covRepo(m_bConf);
|
||||
model::Cover covDb;
|
||||
covDb.id = id;
|
||||
|
||||
database::CoverArtRepository covRepo(m_bConf);
|
||||
model::Cover covDb;
|
||||
covDb.id = id;
|
||||
OATPP_ASSERT_HTTP(covRepo.doesCoverArtExist(covDb,
|
||||
type::CoverFilter::id) , Status::CODE_403, "song does not exist");
|
||||
|
||||
OATPP_ASSERT_HTTP(covRepo.doesCoverArtExist(covDb, type::CoverFilter::id) , Status::CODE_403, "song does not exist");
|
||||
std::cout << "cover art exists\n";
|
||||
covDb = covRepo.retrieveRecord(covDb, type::CoverFilter::id);
|
||||
|
||||
std::cout << "cover art exists" << std::endl;
|
||||
covDb = covRepo.retrieveRecord(covDb, type::CoverFilter::id);
|
||||
auto coverArt = dto::CoverArtDto::createShared();
|
||||
coverArt->id = covDb.id;
|
||||
coverArt->songTitle = covDb.songTitle.c_str();
|
||||
|
||||
auto coverArt = dto::CoverArtDto::createShared();
|
||||
coverArt->id = covDb.id;
|
||||
coverArt->songTitle = covDb.songTitle.c_str();
|
||||
return createDtoResponse(Status::CODE_200, coverArt);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, coverArt);
|
||||
}
|
||||
ENDPOINT("GET", "/api/v1/coverart/download/{id}", downloadCoverArt,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::downloadCoverArt), Status::CODE_403, "Not allowed");
|
||||
|
||||
ENDPOINT("GET", "/api/v1/coverart/download/{id}", downloadCoverArt,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::downloadCoverArt), Status::CODE_403, "Not allowed");
|
||||
database::CoverArtRepository covRepo(m_bConf);
|
||||
model::Cover covDb;
|
||||
covDb.id = id;
|
||||
covDb = covRepo.retrieveRecord(covDb, type::CoverFilter::id);
|
||||
|
||||
database::CoverArtRepository covRepo(m_bConf);
|
||||
model::Cover covDb;
|
||||
covDb.id = id;
|
||||
covDb = covRepo.retrieveRecord(covDb, type::CoverFilter::id);
|
||||
auto rawCover = oatpp::base::StrBuffer::loadFromFile(covDb.imagePath.c_str());
|
||||
auto response = createResponse(Status::CODE_200, rawCover);
|
||||
|
||||
response->putHeader(Header::CONTENT_TYPE, "image/*");
|
||||
|
||||
auto rawCover = oatpp::base::StrBuffer::loadFromFile(covDb.imagePath.c_str());
|
||||
auto response = createResponse(Status::CODE_200, rawCover);
|
||||
|
||||
response->putHeader(Header::CONTENT_TYPE, "image/*");
|
||||
return response;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::string m_exe_path;
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,73 +28,70 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace controller {
|
||||
class GenreController : public oatpp::web::server::api::ApiController
|
||||
{
|
||||
public:
|
||||
GenreController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_exe_path(p)
|
||||
{ }
|
||||
class GenreController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
GenreController(const model::BinaryPath& bConf,
|
||||
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
|
||||
GenreController(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)
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
// endpoint for retrieving all genre records in json format
|
||||
ENDPOINT("GET", "/api/v1/genre", genreRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveGenre), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving all genre records in json format
|
||||
ENDPOINT("GET", "/api/v1/genre", genreRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveGenre), Status::CODE_403, "Not allowed");
|
||||
std::cout << "starting process of retrieving genre\n";
|
||||
database::GenreRepository gnrRepo(m_bConf);
|
||||
auto gnrsDb = gnrRepo.retrieveRecords();
|
||||
auto genres = oatpp::data::mapping::type::
|
||||
List<dto::GenreDto::ObjectWrapper>::createShared();
|
||||
|
||||
std::cout << "starting process of retrieving genre" << std::endl;
|
||||
database::GenreRepository gnrRepo(m_bConf);
|
||||
auto gnrsDb = gnrRepo.retrieveRecords();
|
||||
auto genres = oatpp::data::mapping::type::List<dto::GenreDto::ObjectWrapper>::createShared();
|
||||
for (auto& gnrDb : gnrsDb) {
|
||||
auto gnr = dto::GenreDto::createShared();
|
||||
gnr->id = gnrDb.id;
|
||||
gnr->category = gnrDb.category.c_str();
|
||||
|
||||
for (auto& gnrDb : gnrsDb) {
|
||||
auto gnr = dto::GenreDto::createShared();
|
||||
gnr->id = gnrDb.id;
|
||||
gnr->category = gnrDb.category.c_str();
|
||||
genres->pushBack(gnr);
|
||||
}
|
||||
|
||||
genres->pushBack(gnr);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, genres);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, genres);
|
||||
}
|
||||
// endpoint for retrieving single genre record by the genre id in json format
|
||||
ENDPOINT("GET", "/api/v1/genre/{id}", genreRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveGenre), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving single genre record by the genre id in json format
|
||||
ENDPOINT("GET", "/api/v1/genre/{id}", genreRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveGenre), Status::CODE_403, "Not allowed");
|
||||
database::GenreRepository gnrRepo(m_bConf);
|
||||
model::Genre gnrDb(id);
|
||||
|
||||
database::GenreRepository gnrRepo(m_bConf);
|
||||
model::Genre gnrDb(id);
|
||||
OATPP_ASSERT_HTTP(gnrRepo.doesGenreExist(gnrDb,
|
||||
type::GenreFilter::id) , Status::CODE_403, "genre does not exist");
|
||||
|
||||
OATPP_ASSERT_HTTP(gnrRepo.doesGenreExist(gnrDb, type::GenreFilter::id) , Status::CODE_403, "genre does not exist");
|
||||
std::cout << "genre exist\n";
|
||||
gnrDb = gnrRepo.retrieveRecord(gnrDb, type::GenreFilter::id);
|
||||
|
||||
std::cout << "genre exist" << std::endl;
|
||||
gnrDb = gnrRepo.retrieveRecord(gnrDb, type::GenreFilter::id);
|
||||
auto genre = dto::GenreDto::createShared();
|
||||
genre->id = gnrDb.id;
|
||||
genre->category= gnrDb.category.c_str();
|
||||
|
||||
auto genre = dto::GenreDto::createShared();
|
||||
genre->id = gnrDb.id;
|
||||
genre->category= gnrDb.category.c_str();
|
||||
return createDtoResponse(Status::CODE_200, genre);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, genre);
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::string m_exe_path;
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -16,46 +16,42 @@
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace controller {
|
||||
class LoginController : public oatpp::web::server::api::ApiController {
|
||||
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)
|
||||
{ }
|
||||
class LoginController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
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)
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
|
||||
ENDPOINT("POST", "/api/v1/login", data, BODY_DTO(dto::UserDto::ObjectWrapper, usr)) {
|
||||
OATPP_LOGI("icarus", "logging in");
|
||||
ENDPOINT("POST", "/api/v1/login", data, BODY_DTO(dto::UserDto::ObjectWrapper, usr)) {
|
||||
OATPP_LOGI("icarus", "logging in");
|
||||
|
||||
manager::UserManager usrMgr(m_bConf);
|
||||
auto user = dto::conversion::DtoConversions::toUser(usr);
|
||||
manager::UserManager usrMgr(m_bConf);
|
||||
auto user = dto::conversion::DtoConversions::toUser(usr);
|
||||
|
||||
if (!usrMgr.doesUserExist(user) || !usrMgr.validatePassword(user)) {
|
||||
auto logRes = dto::LoginResultDto::createShared();
|
||||
logRes->message = "invalid credentials";
|
||||
std::cout << "user does not exist" << std::endl;
|
||||
return createDtoResponse(Status::CODE_401, logRes);
|
||||
}
|
||||
if (!usrMgr.doesUserExist(user) || !usrMgr.validatePassword(user)) {
|
||||
auto logRes = dto::LoginResultDto::createShared();
|
||||
logRes->message = "invalid credentials";
|
||||
std::cout << "user does not exist\n";
|
||||
return createDtoResponse(Status::CODE_401, logRes);
|
||||
}
|
||||
|
||||
std::cout << "user exists" << std::endl;
|
||||
std::cout << "user exists\n";
|
||||
|
||||
manager::TokenManager tok;
|
||||
auto token = tok.retrieveToken(m_bConf);
|
||||
manager::TokenManager tok;
|
||||
auto token = tok.retrieveToken(m_bConf);
|
||||
|
||||
auto logRes = dto::conversion::DtoConversions::toLoginResultDto(user, token);
|
||||
logRes->message = "Successful";
|
||||
auto logRes = dto::conversion::DtoConversions::toLoginResultDto(user, token);
|
||||
logRes->message = "Successful";
|
||||
|
||||
return createDtoResponse(Status::CODE_200, logRes);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, logRes);
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::string exe_path;
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace controller {
|
||||
class RegisterController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
RegisterController(const model::BinaryPath& bConf,
|
||||
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper)) :
|
||||
oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper)) :
|
||||
oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace controller {
|
||||
BODY_DTO(dto::UserDto::ObjectWrapper, usr)) {
|
||||
manager::UserManager usrMgr(m_bConf);
|
||||
auto user = dto::conversion::DtoConversions::toUser(usr);
|
||||
if (usrMgr.doesUserExist(user)) {
|
||||
return createResponse(Status::CODE_401, "user already exists");
|
||||
}
|
||||
|
||||
auto res = usrMgr.registerUser(user);
|
||||
auto registerResult = dto::conversion::DtoConversions::toRegisterResultDto(res);
|
||||
|
||||
@@ -32,219 +32,219 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace controller {
|
||||
class SongController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
SongController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_exe_path(p)
|
||||
{ }
|
||||
class SongController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
SongController(const model::BinaryPath& bConf, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
|
||||
SongController(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)
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
// endpoint for uploading a song
|
||||
ENDPOINT("POST", "/api/v1/song/data", songUpload,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::upload), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for uploading a song
|
||||
ENDPOINT("POST", "/api/v1/song/data", songUpload,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::upload), Status::CODE_403, "Not allowed");
|
||||
auto mp =
|
||||
std::make_shared<oatpp::web::mime::multipart::Multipart>
|
||||
(request->getHeaders());
|
||||
|
||||
auto mp = std::make_shared<oatpp::web::mime::multipart::Multipart>(request->getHeaders());
|
||||
oatpp::web::mime::multipart::Reader mp_reader(mp.get());
|
||||
|
||||
oatpp::web::mime::multipart::Reader mp_reader(mp.get());
|
||||
mp_reader.setPartReader("file",
|
||||
oatpp::web::mime::multipart::createInMemoryPartReader(m_dataSize));
|
||||
|
||||
mp_reader.setPartReader("file", oatpp::web::mime::multipart::createInMemoryPartReader(m_dataSize));
|
||||
request->transferBody(&mp_reader);
|
||||
|
||||
request->transferBody(&mp_reader);
|
||||
auto file = mp->getNamedPart("file");
|
||||
|
||||
auto file = mp->getNamedPart("file");
|
||||
OATPP_ASSERT_HTTP(file, Status::CODE_400, "file is null");
|
||||
|
||||
OATPP_ASSERT_HTTP(file, Status::CODE_400, "file is null");
|
||||
auto buff = std::unique_ptr<char>(new char[file->getKnownSize()]);
|
||||
auto buffSize = file->getInputStream()->read(buff.get(), file->getKnownSize());
|
||||
|
||||
auto buff = std::unique_ptr<char>(new char[file->getKnownSize()]);
|
||||
auto buffSize = file->getInputStream()->read(buff.get(), file->getKnownSize());
|
||||
std::vector<unsigned char> data(buff.get(), buff.get() + buffSize);
|
||||
|
||||
std::vector<unsigned char> data(buff.get(), buff.get() + buffSize);
|
||||
model::Song sng;
|
||||
sng.data = std::move(data);
|
||||
|
||||
manager::SongManager songMgr(m_bConf);
|
||||
const auto result = songMgr.saveSong(sng);
|
||||
if (!result.first) {
|
||||
switch (result.second) {
|
||||
case type::SongUpload::AlreadyExist:
|
||||
return createResponse(Status::CODE_400, "Song already exists");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
model::Song sng;
|
||||
sng.data = std::move(data);
|
||||
|
||||
manager::SongManager songMgr(m_bConf);
|
||||
const auto result = songMgr.saveSong(sng);
|
||||
if (!result.first) {
|
||||
switch (result.second) {
|
||||
case type::SongUpload::AlreadyExist:
|
||||
return createResponse(Status::CODE_400, "Song already exists");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto songDto = dto::conversion::DtoConversions::toSongDto(sng);
|
||||
|
||||
auto songDto = dto::conversion::DtoConversions::toSongDto(sng);
|
||||
return createDtoResponse(Status::CODE_200, songDto);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, songDto);
|
||||
}
|
||||
// endpoint for retrieving all song records in json format
|
||||
ENDPOINT("GET", "/api/v1/song", songRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveSong), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving all song records in json format
|
||||
ENDPOINT("GET", "/api/v1/song", songRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveSong), Status::CODE_403, "Not allowed");
|
||||
std::cout << "starting process of retrieving songs\n";
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
auto songsDb = songRepo.retrieveRecords();
|
||||
auto songs = oatpp::data::mapping::type::List<dto::SongDto::ObjectWrapper>::createShared();
|
||||
|
||||
std::cout << "starting process of retrieving songs" << std::endl;
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
auto songsDb = songRepo.retrieveRecords();
|
||||
auto songs = oatpp::data::mapping::type::List<dto::SongDto::ObjectWrapper>::createShared();
|
||||
std::cout << "creating object to send\n";
|
||||
for (auto& songDb : songsDb) {
|
||||
auto song = dto::conversion::DtoConversions::toSongDto(songDb);
|
||||
|
||||
std::cout << "creating object to send" << std::endl;
|
||||
for (auto& songDb : songsDb) {
|
||||
auto song = dto::conversion::DtoConversions::toSongDto(songDb);
|
||||
songs->pushBack(song);
|
||||
}
|
||||
|
||||
songs->pushBack(song);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, songs);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, songs);
|
||||
}
|
||||
|
||||
// endpoint for retrieving song record by the song id in json format
|
||||
ENDPOINT("GET", "/api/v1/song/{id}", songRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveSong), Status::CODE_403, "Not allowed");
|
||||
ENDPOINT("GET", "/api/v1/song/{id}", songRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveSong), Status::CODE_403, "Not allowed");
|
||||
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
model::Song songDb(id);
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
model::Song songDb(id);
|
||||
|
||||
if (!songRepo.doesSongExist(songDb, type::SongFilter::id)) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
if (!songRepo.doesSongExist(songDb, type::SongFilter::id)) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
|
||||
std::cout << "song exists" << std::endl;
|
||||
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
|
||||
std::cout << "song exists\n";
|
||||
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
|
||||
|
||||
auto song = dto::conversion::DtoConversions::toSongDto(songDb);
|
||||
auto song = dto::conversion::DtoConversions::toSongDto(songDb);
|
||||
|
||||
return createDtoResponse(Status::CODE_200, song);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, song);
|
||||
}
|
||||
|
||||
ENDPOINT("GET", "/api/v1/song/data/{id}", downloadSong,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::download), Status::CODE_403, "Not allowed");
|
||||
ENDPOINT("GET", "/api/v1/song/data/{id}", downloadSong,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::download), Status::CODE_403, "Not allowed");
|
||||
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
model::Song songDb(id);
|
||||
if (!songRepo.doesSongExist(songDb, type::SongFilter::id)) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
model::Song songDb(id);
|
||||
if (!songRepo.doesSongExist(songDb, type::SongFilter::id)) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
|
||||
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
|
||||
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
|
||||
|
||||
auto rawSong = oatpp::base::StrBuffer::loadFromFile(songDb.songPath.c_str());
|
||||
|
||||
auto response = createResponse(Status::CODE_200, rawSong);
|
||||
response->putHeader(Header::CONTENT_TYPE, "audio/mpeg");
|
||||
auto rawSong = oatpp::base::StrBuffer::loadFromFile(songDb.songPath.c_str());
|
||||
|
||||
auto response = createResponse(Status::CODE_200, rawSong);
|
||||
response->putHeader(Header::CONTENT_TYPE, "audio/mpeg");
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
ENDPOINT("UPDATE", "/api/v1/song/{id}", songUpdate,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request),
|
||||
BODY_DTO(dto::SongDto::ObjectWrapper, songDto), PATH(Int32, id)) {
|
||||
songDto->id = id;
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::updateSong), Status::CODE_403, "Not allowed");
|
||||
ENDPOINT("UPDATE", "/api/v1/song/{id}", songUpdate,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request),
|
||||
BODY_DTO(dto::SongDto::ObjectWrapper, songDto), PATH(Int32, id)) {
|
||||
songDto->id = id;
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::updateSong), Status::CODE_403, "Not allowed");
|
||||
|
||||
auto updatedSong = dto::conversion::DtoConversions::toSong(songDto);
|
||||
manager::SongManager songMgr(m_bConf);
|
||||
auto result = songMgr.updateSong(updatedSong);
|
||||
if (!result) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
auto updatedSong = dto::conversion::DtoConversions::toSong(songDto);
|
||||
manager::SongManager songMgr(m_bConf);
|
||||
auto result = songMgr.updateSong(updatedSong);
|
||||
if (!result) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
|
||||
return createResponse(Status::CODE_200, "OK");
|
||||
}
|
||||
return createResponse(Status::CODE_200, "OK");
|
||||
}
|
||||
|
||||
// endpoint to delete a song
|
||||
ENDPOINT("DELETE", "api/v1/song/data/{id}", songDelete,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::deleteSong), Status::CODE_403, "Not allowed");
|
||||
// endpoint to delete a song
|
||||
ENDPOINT("DELETE", "api/v1/song/data/{id}", songDelete,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::deleteSong), Status::CODE_403, "Not allowed");
|
||||
|
||||
model::Song song(id);
|
||||
model::Song song(id);
|
||||
|
||||
manager::SongManager sngMgr(m_bConf);
|
||||
auto result = sngMgr.deleteSong(song);
|
||||
if (!result) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
manager::SongManager sngMgr(m_bConf);
|
||||
auto result = sngMgr.deleteSong(song);
|
||||
if (!result) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
|
||||
return createResponse(Status::CODE_200, "OK");
|
||||
}
|
||||
return createResponse(Status::CODE_200, "OK");
|
||||
}
|
||||
|
||||
// endpoint for streaming a song
|
||||
ENDPOINT("GET", "/api/v1/song/stream/{id}", streamSong,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::stream), Status::CODE_403, "Not allowed");
|
||||
// endpoint for streaming a song
|
||||
ENDPOINT("GET", "/api/v1/song/stream/{id}", streamSong,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::stream), Status::CODE_403, "Not allowed");
|
||||
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
model::Song songDb(id);
|
||||
if (!songRepo.doesSongExist(songDb, type::SongFilter::id)) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
database::SongRepository songRepo(m_bConf);
|
||||
model::Song songDb(id);
|
||||
if (!songRepo.doesSongExist(songDb, type::SongFilter::id)) {
|
||||
return songDoesNotExist();
|
||||
}
|
||||
|
||||
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
|
||||
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
|
||||
|
||||
oatpp::data::v_io_size dSize = 1024;
|
||||
oatpp::data::v_io_size dSize = 1024;
|
||||
|
||||
auto db = std::make_shared<oatpp::web::protocol::http::outgoing::ChunkedBody>(
|
||||
std::make_shared<callback::StreamCallback>(songDb.songPath), nullptr, dSize);
|
||||
auto db = std::make_shared<oatpp::web::protocol::http::outgoing::ChunkedBody>(
|
||||
std::make_shared<callback::StreamCallback>(songDb.songPath),
|
||||
nullptr, dSize);
|
||||
|
||||
auto response = OutgoingResponse::createShared(Status::CODE_200, db);
|
||||
response->putHeader(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE);
|
||||
response->putHeader(Header::CONTENT_TYPE, "audio/mpeg");
|
||||
auto response = OutgoingResponse::createShared(Status::CODE_200, db);
|
||||
response->putHeader(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE);
|
||||
response->putHeader(Header::CONTENT_TYPE, "audio/mpeg");
|
||||
|
||||
return response;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::shared_ptr<oatpp::web::protocol::http::outgoing::Response>
|
||||
songDoesNotExist() {
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::shared_ptr<oatpp::web::protocol::http::outgoing::Response>
|
||||
songDoesNotExist() {
|
||||
|
||||
return createResponse(Status::CODE_404, "Song not found");
|
||||
}
|
||||
return createResponse(Status::CODE_404, "Song not found");
|
||||
}
|
||||
|
||||
std::string m_exe_path;
|
||||
model::BinaryPath m_bConf;
|
||||
|
||||
model::BinaryPath m_bConf;
|
||||
|
||||
const long m_dataSize = std::numeric_limits<long long int>::max();
|
||||
};
|
||||
const long m_dataSize = std::numeric_limits<long long int>::max();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,73 +27,71 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace controller {
|
||||
class YearController : public oatpp::web::server::api::ApiController
|
||||
{
|
||||
public:
|
||||
YearController(std::string p, OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_exe_path(p)
|
||||
{ }
|
||||
class YearController : public oatpp::web::server::api::ApiController {
|
||||
public:
|
||||
YearController(const model::BinaryPath& bConf,
|
||||
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper))
|
||||
: oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
|
||||
|
||||
YearController(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)
|
||||
|
||||
#include OATPP_CODEGEN_BEGIN(ApiController)
|
||||
// endpoint for retrieving all year records in json format
|
||||
ENDPOINT("GET", "/api/v1/year", yearRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveYear), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving all year records in json format
|
||||
ENDPOINT("GET", "/api/v1/year", yearRecords,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request))
|
||||
{
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveYear), Status::CODE_403, "Not allowed");
|
||||
std::cout << "starting process of retrieving year\n";
|
||||
database::YearRepository yrRepo(m_bConf);
|
||||
auto yrsDb = yrRepo.retrieveRecords();
|
||||
auto yearRecs = oatpp::data::mapping::type::
|
||||
List<dto::YearDto::ObjectWrapper>::createShared();
|
||||
|
||||
std::cout << "starting process of retrieving year" << std::endl;
|
||||
database::YearRepository yrRepo(m_bConf);
|
||||
auto yrsDb = yrRepo.retrieveRecords();
|
||||
auto yearRecs = oatpp::data::mapping::type::List<dto::YearDto::ObjectWrapper>::createShared();
|
||||
for (auto& yrDb : yrsDb) {
|
||||
auto yr = dto::YearDto::createShared();
|
||||
yr->id = yrDb.id;
|
||||
yr->year = yrDb.year;
|
||||
|
||||
for (auto& yrDb : yrsDb) {
|
||||
auto yr = dto::YearDto::createShared();
|
||||
yr->id = yrDb.id;
|
||||
yr->year = yrDb.year;
|
||||
yearRecs->pushBack(yr);
|
||||
}
|
||||
|
||||
yearRecs->pushBack(yr);
|
||||
}
|
||||
return createDtoResponse(Status::CODE_200, yearRecs);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, yearRecs);
|
||||
}
|
||||
// endpoint for retrieving single year record by the year id in json format
|
||||
ENDPOINT("GET", "/api/v1/year/{id}", yearRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::retrieveYear), Status::CODE_403, "Not allowed");
|
||||
|
||||
// endpoint for retrieving single year record by the year id in json format
|
||||
ENDPOINT("GET", "/api/v1/year/{id}", yearRecord,
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request), PATH(Int32, id)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, type::Scope::retrieveYear), Status::CODE_403, "Not allowed");
|
||||
database::YearRepository yrRepo(m_bConf);
|
||||
model::Year yrDb(id);
|
||||
|
||||
database::YearRepository yrRepo(m_bConf);
|
||||
model::Year yrDb(id);
|
||||
OATPP_ASSERT_HTTP(yrRepo.doesYearExist(yrDb,
|
||||
type::YearFilter::id) , Status::CODE_403, "year does not exist");
|
||||
|
||||
OATPP_ASSERT_HTTP(yrRepo.doesYearExist(yrDb, type::YearFilter::id) , Status::CODE_403, "year does not exist");
|
||||
std::cout << "year exist\n";
|
||||
yrDb = yrRepo.retrieveRecord(yrDb, type::YearFilter::id);
|
||||
|
||||
std::cout << "year exist" << std::endl;
|
||||
yrDb = yrRepo.retrieveRecord(yrDb, type::YearFilter::id);
|
||||
auto year = dto::YearDto::createShared();
|
||||
year->id = yrDb.id;
|
||||
year->year= yrDb.year;
|
||||
|
||||
auto year = dto::YearDto::createShared();
|
||||
year->id = yrDb.id;
|
||||
year->year= yrDb.year;
|
||||
return createDtoResponse(Status::CODE_200, year);
|
||||
}
|
||||
|
||||
return createDtoResponse(Status::CODE_200, year);
|
||||
}
|
||||
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
std::string m_exe_path;
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
#include OATPP_CODEGEN_END(ApiController)
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/AlbumFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class AlbumRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class AlbumRepository : public BaseRepository {
|
||||
public:
|
||||
AlbumRepository(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef ARTISTREPOSITORY_H_
|
||||
#define ARTISTREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -8,16 +9,15 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/ArtistFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class ArtistRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class ArtistRepository : public BaseRepository {
|
||||
public:
|
||||
ArtistRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Artist> retrieveRecords();
|
||||
|
||||
std::pair<model::Artist, int> retrieveRecordWithSongCount(model::Artist&, type::ArtistFilter);
|
||||
std::pair<model::Artist, int> retrieveRecordWithSongCount(
|
||||
model::Artist&, type::ArtistFilter);
|
||||
|
||||
model::Artist retrieveRecord(model::Artist&, type::ArtistFilter);
|
||||
|
||||
@@ -30,9 +30,13 @@ namespace database
|
||||
|
||||
std::pair<model::Artist, int> parseRecordWithSongCount(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Artist parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Artist&,
|
||||
std::tuple<char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> valueBindWithSongCount(model::Artist&,
|
||||
std::tuple<char*>&, int&);
|
||||
|
||||
std::tuple<char*> metadataBuffer();
|
||||
|
||||
model::Artist parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class BaseRepository {
|
||||
public:
|
||||
BaseRepository();
|
||||
BaseRepository() = default;
|
||||
BaseRepository(const std::string&);
|
||||
BaseRepository(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef COVERARTREPOSITORY_H_
|
||||
#define COVERARTREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <mysql/mysql.h>
|
||||
@@ -9,12 +10,9 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/CoverFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class CoverArtRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class CoverArtRepository : public BaseRepository {
|
||||
public:
|
||||
CoverArtRepository(const std::string&);
|
||||
CoverArtRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Cover> retrieveRecords();
|
||||
@@ -23,15 +21,17 @@ namespace database
|
||||
|
||||
bool doesCoverArtExist(const model::Cover&, type::CoverFilter);
|
||||
|
||||
void deleteRecord(const model::Cover&);
|
||||
void deleteRecord(const model::Cover&, type::CoverFilter = type::CoverFilter::id);
|
||||
void saveRecord(const model::Cover&);
|
||||
void updateRecord(const model::Cover&);
|
||||
private:
|
||||
std::vector<model::Cover> parseRecords(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Cover parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Cover&,
|
||||
std::tuple<char*, char*>&);
|
||||
|
||||
std::tuple<char*, char*> metadataBuffer();
|
||||
|
||||
model::Cover parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef GENREREPOSITORY_H_
|
||||
#define GENREREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -8,10 +9,8 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/GenreFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class GenreRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class GenreRepository : public BaseRepository {
|
||||
public:
|
||||
GenreRepository(const model::BinaryPath&);
|
||||
|
||||
@@ -30,9 +29,13 @@ namespace database
|
||||
|
||||
std::pair<model::Genre, int> parseRecordWithSongCount(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Genre parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Genre&,
|
||||
std::tuple<char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> valueBindWithSongCount(model::Genre&,
|
||||
std::tuple<char*>&, int&);
|
||||
|
||||
std::tuple<char*> metadataBuffer();
|
||||
|
||||
model::Genre parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,18 +11,16 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/SongFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class SongRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class SongRepository : public BaseRepository {
|
||||
public:
|
||||
SongRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Song> retrieveRecords();
|
||||
|
||||
model::Song retrieveRecord(const model::Song&, type::SongFilter);
|
||||
model::Song retrieveRecord(const model::Song&, type::SongFilter = type::SongFilter::id);
|
||||
|
||||
bool doesSongExist(const model::Song&, type::SongFilter);
|
||||
bool doesSongExist(const model::Song&, type::SongFilter = type::SongFilter::id);
|
||||
bool deleteRecord(const model::Song&);
|
||||
|
||||
void saveRecord(const model::Song&);
|
||||
|
||||
@@ -11,48 +11,48 @@
|
||||
#include "type/UserFilter.h"
|
||||
|
||||
namespace database {
|
||||
class UserRepository : BaseRepository {
|
||||
public:
|
||||
UserRepository(const model::BinaryPath&);
|
||||
class UserRepository : BaseRepository {
|
||||
public:
|
||||
UserRepository(const model::BinaryPath&);
|
||||
|
||||
model::User retrieveUserRecord(model::User&, type::UserFilter);
|
||||
model::PassSec retrieverUserSaltRecord(model::PassSec&, type::SaltFilter);
|
||||
model::User retrieveUserRecord(model::User&, type::UserFilter);
|
||||
model::PassSec retrieverUserSaltRecord(model::PassSec&, type::SaltFilter);
|
||||
|
||||
bool doesUserRecordExist(const model::User&, type::UserFilter);
|
||||
bool doesUserRecordExist(const model::User&, type::UserFilter);
|
||||
|
||||
void saveUserRecord(const model::User&);
|
||||
void saveUserSalt(const model::PassSec&);
|
||||
private:
|
||||
struct UserLengths;
|
||||
struct SaltLengths;
|
||||
void saveUserRecord(const model::User&);
|
||||
void saveUserSalt(const model::PassSec&);
|
||||
private:
|
||||
struct UserLengths;
|
||||
struct SaltLengths;
|
||||
|
||||
struct UserLengths
|
||||
{
|
||||
unsigned long firstnameLength;
|
||||
unsigned long lastnameLength;
|
||||
unsigned long phoneLength;
|
||||
unsigned long emailLength;
|
||||
unsigned long usernameLength;
|
||||
unsigned long passwordLength;
|
||||
struct UserLengths {
|
||||
unsigned long firstnameLength;
|
||||
unsigned long lastnameLength;
|
||||
unsigned long phoneLength;
|
||||
unsigned long emailLength;
|
||||
unsigned long usernameLength;
|
||||
unsigned long passwordLength;
|
||||
};
|
||||
struct SaltLengths {
|
||||
unsigned long saltLength;
|
||||
};
|
||||
|
||||
std::shared_ptr<MYSQL_BIND> insertUserValues(const model::User&,
|
||||
std::shared_ptr<UserLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> insertSaltValues(const model::PassSec&,
|
||||
std::shared_ptr<SaltLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::User&,
|
||||
std::tuple<char*, char*, char*, char*, char*, char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> saltValueBind(model::PassSec&, char*);
|
||||
std::shared_ptr<UserLengths> fetchUserLengths(const model::User&);
|
||||
std::shared_ptr<SaltLengths> fetchSaltLengths(const model::PassSec&);
|
||||
|
||||
std::tuple<char*, char*, char*, char*, char*, char*> fetchUV();
|
||||
|
||||
model::User parseRecord(MYSQL_STMT*);
|
||||
model::PassSec parseSaltRecord(MYSQL_STMT*);
|
||||
};
|
||||
struct SaltLengths
|
||||
{
|
||||
unsigned long saltLength;
|
||||
};
|
||||
|
||||
std::shared_ptr<MYSQL_BIND> insertUserValues(const model::User&, std::shared_ptr<UserLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> insertSaltValues(const model::PassSec&, std::shared_ptr<SaltLengths>);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::User&, std::tuple<char*, char*, char*, char*, char*, char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> saltValueBind(model::PassSec&, char*);
|
||||
std::shared_ptr<UserLengths> fetchUserLengths(const model::User&);
|
||||
std::shared_ptr<SaltLengths> fetchSaltLengths(const model::PassSec&);
|
||||
|
||||
std::tuple<char*, char*, char*, char*, char*, char*> fetchUV();
|
||||
|
||||
model::User parseRecord(MYSQL_STMT*);
|
||||
model::PassSec parseSaltRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef YEARREPOSITORY_H_
|
||||
#define YEARREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -8,31 +9,31 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/YearFilter.h"
|
||||
|
||||
namespace database
|
||||
{
|
||||
class YearRepository : public BaseRepository
|
||||
{
|
||||
namespace database {
|
||||
class YearRepository : public BaseRepository {
|
||||
public:
|
||||
YearRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Year> retrieveRecords();
|
||||
|
||||
std::pair<model::Year, int> retrieveRecordWithSongCount(model::Year&, type::YearFilter);
|
||||
std::pair<model::Year, int> retrieveRecordWithSongCount(model::Year&,
|
||||
type::YearFilter = type::YearFilter::id);
|
||||
|
||||
model::Year retrieveRecord(model::Year&, type::YearFilter);
|
||||
model::Year retrieveRecord(model::Year&, type::YearFilter = type::YearFilter::id);
|
||||
|
||||
bool doesYearExist(const model::Year&, type::YearFilter);
|
||||
bool doesYearExist(const model::Year&, type::YearFilter = type::YearFilter::id);
|
||||
|
||||
void saveRecord(const model::Year&);
|
||||
void deleteYear(const model::Year&, type::YearFilter);
|
||||
void deleteYear(const model::Year&, type::YearFilter = type::YearFilter::id);
|
||||
private:
|
||||
std::vector<model::Year> parseRecords(MYSQL_STMT*);
|
||||
|
||||
std::pair<model::Year, int> parseRecordWithSongCount(MYSQL_STMT*);
|
||||
|
||||
// TODO: After parseRecord(MYSQL_STMT*) is implemented
|
||||
// remove parseRecord(MYSQL_RES*)
|
||||
model::Year parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Year&);
|
||||
std::shared_ptr<MYSQL_BIND> valueBindWithSongCount(model::Year&,
|
||||
int&);
|
||||
|
||||
model::Year parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
namespace dto
|
||||
{
|
||||
namespace dto {
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class AlbumDto : public oatpp::data::mapping::type::Object
|
||||
{
|
||||
class AlbumDto : public oatpp::data::mapping::type::Object {
|
||||
DTO_INIT(AlbumDto, Object)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
namespace dto
|
||||
{
|
||||
namespace dto {
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class ArtistDto : public oatpp::data::mapping::type::Object
|
||||
{
|
||||
class ArtistDto : public oatpp::data::mapping::type::Object {
|
||||
DTO_INIT(ArtistDto, Object)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
namespace dto
|
||||
{
|
||||
namespace dto {
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class CoverArtDto : public oatpp::data::mapping::type::Object
|
||||
{
|
||||
class CoverArtDto : public oatpp::data::mapping::type::Object {
|
||||
DTO_INIT(CoverArtDto, Object)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
namespace dto
|
||||
{
|
||||
namespace dto {
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class GenreDto : public oatpp::data::mapping::type::Object
|
||||
{
|
||||
class GenreDto : public oatpp::data::mapping::type::Object {
|
||||
DTO_INIT(GenreDto, Object)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -6,12 +6,10 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace dto
|
||||
{
|
||||
namespace dto {
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class SongDto : public oatpp::data::mapping::type::Object
|
||||
{
|
||||
class SongDto : public oatpp::data::mapping::type::Object {
|
||||
DTO_INIT(SongDto, Object)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -4,12 +4,10 @@
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
namespace dto
|
||||
{
|
||||
namespace dto {
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class YearDto : public oatpp::data::mapping::type::Object
|
||||
{
|
||||
class YearDto : public oatpp::data::mapping::type::Object {
|
||||
DTO_INIT(YearDto, Object)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace manager
|
||||
{
|
||||
class AlbumManager
|
||||
{
|
||||
namespace manager {
|
||||
class AlbumManager {
|
||||
public:
|
||||
AlbumManager(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace manager
|
||||
{
|
||||
class ArtistManager
|
||||
{
|
||||
namespace manager {
|
||||
class ArtistManager {
|
||||
public:
|
||||
ArtistManager(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -6,12 +6,9 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace manager
|
||||
{
|
||||
class CoverArtManager
|
||||
{
|
||||
namespace manager {
|
||||
class CoverArtManager {
|
||||
public:
|
||||
CoverArtManager(const std::string&);
|
||||
CoverArtManager(const model::BinaryPath& bConf);
|
||||
|
||||
model::Cover saveCover(const model::Song&);
|
||||
@@ -25,7 +22,6 @@ namespace manager
|
||||
std::string createImagePath(const model::Song&);
|
||||
|
||||
model::BinaryPath m_bConf;
|
||||
std::string path;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
#include "model/Models.h"
|
||||
#include "type/PathType.h"
|
||||
|
||||
namespace manager
|
||||
{
|
||||
class DirectoryManager
|
||||
{
|
||||
namespace manager {
|
||||
class DirectoryManager {
|
||||
public:
|
||||
static std::string createDirectoryProcess(model::Song, const std::string&);
|
||||
static std::string createDirectoryProcess(const model::Song&, const model::BinaryPath&, type::PathType);
|
||||
static std::string createDirectoryProcess(const model::Song&,
|
||||
const model::BinaryPath&, type::PathType);
|
||||
static std::string configPath(std::string_view);
|
||||
static std::string configPath(const model::BinaryPath&);
|
||||
static std::string contentOfPath(const std::string&);
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace manager
|
||||
{
|
||||
class GenreManager
|
||||
{
|
||||
namespace manager {
|
||||
class GenreManager {
|
||||
public:
|
||||
GenreManager(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
#include "type/SongUpload.h"
|
||||
|
||||
namespace manager {
|
||||
class SongManager
|
||||
{
|
||||
class SongManager {
|
||||
public:
|
||||
SongManager(const model::BinaryPath&);
|
||||
|
||||
|
||||
@@ -14,26 +14,26 @@
|
||||
#include "type/Scopes.h"
|
||||
|
||||
namespace manager {
|
||||
class TokenManager {
|
||||
public:
|
||||
TokenManager() = default;
|
||||
class TokenManager {
|
||||
public:
|
||||
TokenManager() = default;
|
||||
|
||||
model::Token retrieveToken(const model::BinaryPath&);
|
||||
model::Token retrieveToken(const model::BinaryPath&);
|
||||
|
||||
bool isTokenValid(std::string&, type::Scope);
|
||||
bool testAuth(const model::BinaryPath&);
|
||||
private:
|
||||
cpr::Response sendRequest(std::string_view, nlohmann::json&);
|
||||
bool isTokenValid(std::string&, type::Scope);
|
||||
bool testAuth(const model::BinaryPath&);
|
||||
private:
|
||||
cpr::Response sendRequest(std::string_view, nlohmann::json&);
|
||||
|
||||
nlohmann::json createTokenBody(const model::AuthCredentials&);
|
||||
nlohmann::json createTokenBody(const model::AuthCredentials&);
|
||||
|
||||
model::AuthCredentials parseAuthCredentials(const model::BinaryPath&);
|
||||
model::AuthCredentials parseAuthCredentials(const model::BinaryPath&);
|
||||
|
||||
std::vector<std::string> extractScopes(const jwt::decoded_jwt&&);
|
||||
std::pair<bool, std::vector<std::string>> fetchAuthHeader(const std::string&);
|
||||
std::vector<std::string> extractScopes(const jwt::decoded_jwt&&);
|
||||
std::pair<bool, std::vector<std::string>> fetchAuthHeader(const std::string&);
|
||||
|
||||
bool tokenSupportsScope(const std::vector<std::string>&, const std::string&&);
|
||||
};
|
||||
bool tokenSupportsScope(const std::vector<std::string>&, const std::string&&);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace manager {
|
||||
class UserManager {
|
||||
public:
|
||||
UserManager(const model::BinaryPath&);
|
||||
class UserManager {
|
||||
public:
|
||||
UserManager(const model::BinaryPath&);
|
||||
|
||||
model::RegisterResult registerUser(model::User&);
|
||||
model::RegisterResult registerUser(model::User&);
|
||||
|
||||
bool doesUserExist(const model::User&);
|
||||
bool validatePassword(const model::User&);
|
||||
bool doesUserExist(const model::User&);
|
||||
bool validatePassword(const model::User&);
|
||||
|
||||
void printUser(const model::User&);
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
void printUser(const model::User&);
|
||||
private:
|
||||
model::BinaryPath m_bConf;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace manager
|
||||
{
|
||||
class YearManager
|
||||
{
|
||||
namespace manager {
|
||||
class YearManager {
|
||||
public:
|
||||
YearManager(const model::BinaryPath&);
|
||||
|
||||
|
||||
+144
-144
@@ -5,172 +5,172 @@
|
||||
#include <vector>
|
||||
|
||||
namespace model {
|
||||
class Song {
|
||||
public:
|
||||
Song() = default;
|
||||
Song(const int id) : id(id) { }
|
||||
Song(const int id, const std::string& title, const std::string& artist,
|
||||
const std::string& album, const std::string& albumArtist,
|
||||
const std::string& genre, const int year, const int duration,
|
||||
const int track, const int disc, const std::string songPath) :
|
||||
id(id), title(title), artist(artist), album(album),
|
||||
albumArtist(albumArtist), genre(genre), year(year),
|
||||
duration(duration), track(track), disc(disc),
|
||||
songPath(songPath) { }
|
||||
class Song {
|
||||
public:
|
||||
Song() = default;
|
||||
Song(const int id) : id(id) { }
|
||||
Song(const int id, const std::string& title, const std::string& artist,
|
||||
const std::string& album, const std::string& albumArtist,
|
||||
const std::string& genre, const int year, const int duration,
|
||||
const int track, const int disc, const std::string songPath) :
|
||||
id(id), title(title), artist(artist), album(album),
|
||||
albumArtist(albumArtist), genre(genre), year(year),
|
||||
duration(duration), track(track), disc(disc),
|
||||
songPath(songPath) { }
|
||||
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string albumArtist;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
int coverArtId;
|
||||
int artistId;
|
||||
int albumId;
|
||||
int genreId;
|
||||
int yearId;
|
||||
};
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string albumArtist;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
int coverArtId;
|
||||
int artistId;
|
||||
int albumId;
|
||||
int genreId;
|
||||
int yearId;
|
||||
};
|
||||
|
||||
class Artist {
|
||||
public:
|
||||
Artist() = default;
|
||||
Artist(const Song& song) : id(song.artistId), artist(song.artist) { }
|
||||
Artist(const int id) : id(id) { }
|
||||
class Artist {
|
||||
public:
|
||||
Artist() = default;
|
||||
Artist(const Song& song) : id(song.artistId), artist(song.artist) { }
|
||||
Artist(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
std::string artist;
|
||||
};
|
||||
int id;
|
||||
std::string artist;
|
||||
};
|
||||
|
||||
class Album {
|
||||
public:
|
||||
Album() = default;
|
||||
Album(const Song& song) :
|
||||
id(song.albumId), title(song.album),artist(song.artist), year(song.year) { }
|
||||
Album(const int id) : id(id) { }
|
||||
class Album {
|
||||
public:
|
||||
Album() = default;
|
||||
Album(const Song& song) :
|
||||
id(song.albumId), title(song.album),artist(song.artist), year(song.year) { }
|
||||
Album(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
int year;
|
||||
std::vector<Song> songs;
|
||||
};
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
int year;
|
||||
std::vector<Song> songs;
|
||||
};
|
||||
|
||||
class Genre {
|
||||
public:
|
||||
Genre() = default;
|
||||
Genre(const Song& song) :
|
||||
id(song.genreId), category(song.genre) { }
|
||||
Genre(const int id) : id(id) { }
|
||||
class Genre {
|
||||
public:
|
||||
Genre() = default;
|
||||
Genre(const Song& song) :
|
||||
id(song.genreId), category(song.genre) { }
|
||||
Genre(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
std::string category;
|
||||
int id;
|
||||
std::string category;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
class Year {
|
||||
public:
|
||||
Year() = default;
|
||||
Year(const Song& song) :
|
||||
id(song.yearId), year(song.year) { }
|
||||
Year(const int id) : id(id) { }
|
||||
class Year {
|
||||
public:
|
||||
Year() = default;
|
||||
Year(const Song& song) :
|
||||
id(song.yearId), year(song.year) { }
|
||||
Year(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
int year;
|
||||
};
|
||||
int id;
|
||||
int year;
|
||||
};
|
||||
|
||||
class Cover {
|
||||
public:
|
||||
Cover() = default;
|
||||
Cover(const Song& song) :
|
||||
id(song.coverArtId), songTitle(song.title) { }
|
||||
Cover(const int id) : id(id) { }
|
||||
class Cover {
|
||||
public:
|
||||
Cover() = default;
|
||||
Cover(const Song& song) :
|
||||
id(song.coverArtId), songTitle(song.title) { }
|
||||
Cover(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Not being used but it should be
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Not being used but it should be
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
class Token {
|
||||
public:
|
||||
Token() = default;
|
||||
Token(const std::string& accessToken) :
|
||||
accessToken(accessToken) { }
|
||||
Token(const std::string& accessToken, const std::string& tokenType,
|
||||
const int expiration) :
|
||||
accessToken(accessToken), tokenType(tokenType),
|
||||
expiration(expiration) { }
|
||||
class Token {
|
||||
public:
|
||||
Token() = default;
|
||||
Token(const std::string& accessToken) :
|
||||
accessToken(accessToken) { }
|
||||
Token(const std::string& accessToken, const std::string& tokenType,
|
||||
const int expiration) :
|
||||
accessToken(accessToken), tokenType(tokenType),
|
||||
expiration(expiration) { }
|
||||
|
||||
std::string accessToken;
|
||||
int expiration;
|
||||
std::string tokenType;
|
||||
};
|
||||
std::string accessToken;
|
||||
int expiration;
|
||||
std::string tokenType;
|
||||
};
|
||||
|
||||
struct LoginResult {
|
||||
int userId;
|
||||
std::string username;
|
||||
std::string accessToken;
|
||||
std::string tokenType;
|
||||
std::string message;
|
||||
int expiration;
|
||||
};
|
||||
struct LoginResult {
|
||||
int userId;
|
||||
std::string username;
|
||||
std::string accessToken;
|
||||
std::string tokenType;
|
||||
std::string message;
|
||||
int expiration;
|
||||
};
|
||||
|
||||
class RegisterResult {
|
||||
public:
|
||||
std::string username;
|
||||
bool registered;
|
||||
std::string message;
|
||||
};
|
||||
class RegisterResult {
|
||||
public:
|
||||
std::string username;
|
||||
bool registered;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
struct User {
|
||||
int id;
|
||||
std::string firstname;
|
||||
std::string lastname;
|
||||
std::string email;
|
||||
std::string phone;
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
struct User {
|
||||
int id;
|
||||
std::string firstname;
|
||||
std::string lastname;
|
||||
std::string email;
|
||||
std::string phone;
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
|
||||
struct PassSec {
|
||||
int id;
|
||||
std::string hashPassword;
|
||||
std::string salt;
|
||||
int userId;
|
||||
};
|
||||
struct PassSec {
|
||||
int id;
|
||||
std::string hashPassword;
|
||||
std::string salt;
|
||||
int userId;
|
||||
};
|
||||
|
||||
struct AuthCredentials {
|
||||
std::string domain;
|
||||
std::string apiIdentifier;
|
||||
std::string clientId;
|
||||
std::string clientSecret;
|
||||
std::string uri;
|
||||
std::string endpoint;
|
||||
};
|
||||
struct AuthCredentials {
|
||||
std::string domain;
|
||||
std::string apiIdentifier;
|
||||
std::string clientId;
|
||||
std::string clientSecret;
|
||||
std::string uri;
|
||||
std::string endpoint;
|
||||
};
|
||||
|
||||
struct DatabaseConnection {
|
||||
std::string server;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string database;
|
||||
};
|
||||
struct DatabaseConnection {
|
||||
std::string server;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string database;
|
||||
};
|
||||
|
||||
class BinaryPath {
|
||||
public:
|
||||
BinaryPath() = default;
|
||||
BinaryPath(const char *p) : path(p) { }
|
||||
BinaryPath(const std::string& p) : path(p) { }
|
||||
BinaryPath(const std::string&& p) : path(p) { }
|
||||
class BinaryPath {
|
||||
public:
|
||||
BinaryPath() = default;
|
||||
BinaryPath(const char *p) : path(p) { }
|
||||
BinaryPath(const std::string& p) : path(p) { }
|
||||
BinaryPath(const std::string&& p) : path(p) { }
|
||||
|
||||
std::string path;
|
||||
};
|
||||
std::string path;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef ALBUMFILTER_H_
|
||||
#define ALBUMFILTER_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class AlbumFilter
|
||||
{
|
||||
namespace type {
|
||||
enum class AlbumFilter {
|
||||
id = 0,
|
||||
title,
|
||||
year
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef ARTISTFILTER_H_
|
||||
#define ARTISTFILTER_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class ArtistFilter
|
||||
{
|
||||
namespace type {
|
||||
enum class ArtistFilter {
|
||||
id = 0,
|
||||
artist
|
||||
};
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef COVERFILTER_H_
|
||||
#define COVERFILTER_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class CoverFilter
|
||||
{
|
||||
namespace type {
|
||||
enum class CoverFilter {
|
||||
id = 0,
|
||||
songTitle,
|
||||
imagePath
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef GENREFILTER_H_
|
||||
#define GENREFILTER_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class GenreFilter
|
||||
{
|
||||
namespace type {
|
||||
enum class GenreFilter {
|
||||
id = 0,
|
||||
category
|
||||
};
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef PATHTYPE_H_
|
||||
#define PATHTYPE_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum PathType
|
||||
{
|
||||
namespace type {
|
||||
enum PathType {
|
||||
music = 0,
|
||||
archive,
|
||||
temp,
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
#define SALTFILTER_H_
|
||||
|
||||
namespace type {
|
||||
enum class SaltFilter
|
||||
{
|
||||
enum class SaltFilter {
|
||||
id = 0,
|
||||
salt,
|
||||
userId
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef SCOPES_H_
|
||||
#define SCOPES_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class Scope
|
||||
{
|
||||
namespace type {
|
||||
enum class Scope {
|
||||
upload = 0,
|
||||
download,
|
||||
stream,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef SONGCHANGED_H_
|
||||
#define SONGCHANGED_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum SongChanged
|
||||
{
|
||||
namespace type {
|
||||
enum SongChanged {
|
||||
title = 0,
|
||||
artist,
|
||||
album,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef SONGFILTER_H_
|
||||
#define SONGFILTER_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class SongFilter
|
||||
{
|
||||
namespace type {
|
||||
enum class SongFilter {
|
||||
id = 0,
|
||||
title,
|
||||
album,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef SONGUPLOAD_H_
|
||||
#define SONGUPLOAD_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class SongUpload
|
||||
{
|
||||
namespace type {
|
||||
enum class SongUpload {
|
||||
Successful = 0,
|
||||
AlreadyExist = 1,
|
||||
Failed = 2
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
#define USERFILTER_H_
|
||||
|
||||
namespace type {
|
||||
enum class UserFilter
|
||||
{
|
||||
enum class UserFilter {
|
||||
id = 0,
|
||||
username
|
||||
};
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#ifndef YEARFILTER_H_
|
||||
#define YEARFILTER_H_
|
||||
|
||||
namespace type
|
||||
{
|
||||
enum class YearFilter
|
||||
{
|
||||
namespace type {
|
||||
enum class YearFilter {
|
||||
id = 0,
|
||||
year
|
||||
};
|
||||
|
||||
@@ -13,10 +13,8 @@
|
||||
#include <tpropertymap.h>
|
||||
#include <id3v2tag.h>
|
||||
|
||||
namespace utility
|
||||
{
|
||||
class ImageFile : public TagLib::File
|
||||
{
|
||||
namespace utility {
|
||||
class ImageFile : public TagLib::File {
|
||||
public:
|
||||
ImageFile(const char *file);
|
||||
|
||||
|
||||
@@ -7,20 +7,19 @@
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace utility {
|
||||
class MetadataRetriever
|
||||
{
|
||||
public:
|
||||
model::Song retrieveMetadata(model::Song&);
|
||||
class MetadataRetriever {
|
||||
public:
|
||||
model::Song retrieveMetadata(model::Song&);
|
||||
|
||||
model::Cover updateCoverArt(const model::Song&, model::Cover&, const std::string&);
|
||||
model::Cover applyStockCoverArt(const model::Song&, model::Cover&, const std::string&);
|
||||
model::Cover applyCoverArt(const model::Song&, model::Cover&);
|
||||
model::Cover updateCoverArt(const model::Song&, model::Cover&, const std::string&);
|
||||
model::Cover applyStockCoverArt(const model::Song&, model::Cover&, const std::string&);
|
||||
model::Cover applyCoverArt(const model::Song&, model::Cover&);
|
||||
|
||||
bool songContainsCoverArt(const model::Song&);
|
||||
bool songContainsCoverArt(const model::Song&);
|
||||
|
||||
void updateMetadata(model::Song&, const model::Song&);
|
||||
private:
|
||||
};
|
||||
void updateMetadata(model::Song&, const model::Song&);
|
||||
private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
|
||||
bool isPasswordValid(const model::User&, const model::PassSec&);
|
||||
private:
|
||||
int saltSize();
|
||||
constexpr int saltSize() noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace verify
|
||||
{
|
||||
class Initialization
|
||||
{
|
||||
namespace verify {
|
||||
class Initialization {
|
||||
public:
|
||||
static bool skipVerification(const std::string&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user