diff --git a/CMakeLists.txt b/CMakeLists.txt index 118d511..2497bde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ set(SOURCES src/database/SongRepository.cpp src/database/UserRepository.cpp src/database/YearRepository.cpp - src/dto/conversion/DtoConversions.cpp + # src/dto/conversion/DtoConversions.cpp src/Main.cpp src/manager/AlbumManager.cpp src/manager/ArtistManager.cpp diff --git a/include/component/AppComponent.hpp b/include/component/AppComponent.hpp index e24368a..47de59a 100644 --- a/include/component/AppComponent.hpp +++ b/include/component/AppComponent.hpp @@ -4,7 +4,8 @@ #include #include "oatpp/core/macro/component.hpp" -#include "oatpp/network/server/SimpleTCPConnectionProvider.hpp" +// #include "oatpp/network/server/SimpleTCPConnectionProvider.hpp" +#include "oatpp/network/tcp/server/ConnectionProvider.hpp" #include "oatpp/parser/json/mapping/ObjectMapper.hpp" #include "oatpp/web/server/HttpConnectionHandler.hpp" @@ -12,28 +13,37 @@ namespace component { class AppComponent { public: OATPP_CREATE_COMPONENT(std::shared_ptr, - serverConnectionProvider)([&] { - return oatpp::network::server::SimpleTCPConnectionProvider:: - createShared(appPort()); + serverConnectionProvider)([&] + { + // return oatpp::network::tcp::server::ConnectionProvider::createShared({"localhost", appPort(), oatpp::network::Address::IP_4}); + return oatpp::network::tcp::server::ConnectionProvider::createShared({"localhost", appPort(), oatpp::network::Address::IP_4}); }()); - OATPP_CREATE_COMPONENT(std::shared_ptr, httpRouter)([] { + OATPP_CREATE_COMPONENT(std::shared_ptr, httpRouter)([] + { return oatpp::web::server::HttpRouter::createShared(); }()); - OATPP_CREATE_COMPONENT(std::shared_ptr, - serverConnectionHandler)([] { + OATPP_CREATE_COMPONENT(std::shared_ptr, + serverConnectionHandler)([] + { OATPP_COMPONENT(std::shared_ptr, router); return oatpp::web::server::HttpConnectionHandler::createShared(router); }()); OATPP_CREATE_COMPONENT(std::shared_ptr, - apiObjectMapper)([] { + apiObjectMapper)([] + { return oatpp::parser::json::mapping::ObjectMapper::createShared(); }()); private: - constexpr int appPort() noexcept { return 5002; } + template + // constexpr Val appPort() noexcept + Val appPort() noexcept + { + return 5002; + } }; } diff --git a/include/controller/AlbumController.hpp b/include/controller/AlbumController.hpp index 2a5ca04..59bec1b 100644 --- a/include/controller/AlbumController.hpp +++ b/include/controller/AlbumController.hpp @@ -16,6 +16,7 @@ #include "oatpp/web/mime/multipart/InMemoryPartReader.hpp" #include "oatpp/web/mime/multipart/Reader.hpp" #include "oatpp/web/server/api/ApiController.hpp" +#include "oatpp/core/Types.hpp" #include "database/AlbumRepository.h" #include "dto/AlbumDto.hpp" @@ -27,68 +28,85 @@ #include "type/AlbumFilter.h" namespace fs = std::filesystem; +using namespace dto; namespace controller { class AlbumController : public oatpp::web::server::api::ApiController { public: - AlbumController(const model::BinaryPath& bConf, - OATPP_COMPONENT(std::shared_ptr, objectMapper)) - : oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { } + AlbumController(const model::BinaryPath& bConf, + OATPP_COMPONENT(std::shared_ptr, 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, 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, + // endpoint for retrieving all album records in json format + ENDPOINT("GET", "/api/v1/album", albumRecords, + REQUEST(std::shared_ptr, 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::createShared(); + std::cout << "starting process of retrieving album\n"; - for (auto& albDb : albsDb) { - auto alb = dto::conversion::DtoConversions::toAlbumDto(albDb); + database::AlbumRepository albRepo(m_bConf); - albums->pushBack(alb); - } + auto albsDb = albRepo.retrieveRecords(); - return createDtoResponse(Status::CODE_200, albums); - } + auto albums = oatpp::Vector>::createShared(); + albums->reserve(albsDb.size()); - // endpoint for retrieving single album record by the album id in json format - ENDPOINT("GET", "/api/v1/album/{id}", albumRecord, - REQUEST(std::shared_ptr, 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, + for (auto& albDb : albsDb) { + auto alb = dto::conversion::DtoConversions::toAlbumDto>(albDb); + + albums->push_back(alb); + } + + 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, 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, + 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\n"; + 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) + #include OATPP_CODEGEN_END(ApiController) private: - model::BinaryPath m_bConf; + model::BinaryPath m_bConf; }; } #endif diff --git a/include/controller/ArtistController.hpp b/include/controller/ArtistController.hpp index 4db305a..f3cf3f4 100644 --- a/include/controller/ArtistController.hpp +++ b/include/controller/ArtistController.hpp @@ -49,15 +49,18 @@ namespace controller { std::cout << "starting process of retrieving artist\n"; database::ArtistRepository artRepo(m_bConf); auto artsDb = artRepo.retrieveRecords(); - auto artists = oatpp::data::mapping::type:: - List::createShared(); + auto artists = oatpp::Vector>::createShared(); + // List::createShared(); + for (auto& artDb : artsDb) { auto art = dto::ArtistDto::createShared(); art->id = artDb.id; art->artist = artDb.artist.c_str(); - artists->pushBack(art); + // artists->push_back(art); + artists->push_back(art); + // artists.push_back(art); } return createDtoResponse(Status::CODE_200, artists); diff --git a/include/controller/CoverArtController.hpp b/include/controller/CoverArtController.hpp index 10e2039..c48ffb7 100644 --- a/include/controller/CoverArtController.hpp +++ b/include/controller/CoverArtController.hpp @@ -48,15 +48,14 @@ namespace controller { 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::createShared(); + auto coverArts = oatpp::Vector>::createShared(); for (auto& covDb : covsDb) { auto cov = dto::CoverArtDto::createShared(); cov->id = covDb.id; cov->songTitle = covDb.songTitle.c_str(); - coverArts->pushBack(cov); + coverArts->push_back(cov); } return createDtoResponse(Status::CODE_200, coverArts); diff --git a/include/controller/GenreController.hpp b/include/controller/GenreController.hpp index 327a26a..c77ecb0 100644 --- a/include/controller/GenreController.hpp +++ b/include/controller/GenreController.hpp @@ -49,15 +49,14 @@ namespace controller { std::cout << "starting process of retrieving genre\n"; database::GenreRepository gnrRepo(m_bConf); auto gnrsDb = gnrRepo.retrieveRecords(); - auto genres = oatpp::data::mapping::type:: - List::createShared(); + auto genres = oatpp::Vector>::createShared(); for (auto& gnrDb : gnrsDb) { auto gnr = dto::GenreDto::createShared(); gnr->id = gnrDb.id; gnr->category = gnrDb.category.c_str(); - genres->pushBack(gnr); + genres->push_back(gnr); } return createDtoResponse(Status::CODE_200, genres); diff --git a/include/controller/RegisterController.hpp b/include/controller/RegisterController.hpp index 2e3d479..42862eb 100644 --- a/include/controller/RegisterController.hpp +++ b/include/controller/RegisterController.hpp @@ -23,7 +23,8 @@ namespace controller { #include OATPP_CODEGEN_BEGIN(ApiController) ENDPOINT("POST", "api/v1/register", registerUser, - BODY_DTO(dto::UserDto::ObjectWrapper, usr)) { + // BODY_DTO(dto::UserDto::ObjectWrapper, usr)) { + BODY_DTO(oatpp::data::mapping::type::ObjectWrapper, usr)) { manager::UserManager usrMgr(m_bConf); auto user = dto::conversion::DtoConversions::toUser(usr); if (usrMgr.doesUserExist(user)) { diff --git a/include/controller/SongController.hpp b/include/controller/SongController.hpp index fad2a5c..08b89af 100644 --- a/include/controller/SongController.hpp +++ b/include/controller/SongController.hpp @@ -104,13 +104,16 @@ namespace controller { std::cout << "starting process of retrieving songs\n"; database::SongRepository songRepo(m_bConf); auto songsDb = songRepo.retrieveRecords(); - auto songs = oatpp::data::mapping::type::List::createShared(); + // auto songs = oatpp::data::mapping::type::List::createShared(); + auto songs = oatpp::Vector>::createShared(); + + // auto yearRecs = oatpp::Vector>::createShared(); std::cout << "creating object to send\n"; for (auto& songDb : songsDb) { auto song = dto::conversion::DtoConversions::toSongDto(songDb); - songs->pushBack(song); + songs->push_back(song); } return createDtoResponse(Status::CODE_200, songs); @@ -167,7 +170,8 @@ namespace controller { ENDPOINT("UPDATE", "/api/v1/song/{id}", songUpdate, REQUEST(std::shared_ptr, request), - BODY_DTO(dto::SongDto::ObjectWrapper, songDto), PATH(Int32, id)) { + // BODY_DTO(dto::SongDto::ObjectWrapper, songDto), PATH(Int32, id)) { + BODY_DTO(oatpp::data::mapping::type::ObjectWrapper, songDto), PATH(Int32, id)) { songDto->id = id; auto authHeader = request->getHeader("Authorization"); OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope"); diff --git a/include/controller/YearController.hpp b/include/controller/YearController.hpp index 90c4892..c8b3d6c 100644 --- a/include/controller/YearController.hpp +++ b/include/controller/YearController.hpp @@ -48,15 +48,20 @@ namespace controller { std::cout << "starting process of retrieving year\n"; database::YearRepository yrRepo(m_bConf); auto yrsDb = yrRepo.retrieveRecords(); - auto yearRecs = oatpp::data::mapping::type:: - List::createShared(); + // auto yearRecs = oatpp::data::mapping::type:: + // List::createShared(); + // List::createShared(); + auto yearRecs = oatpp::Vector>::createShared(); + // List::createShared(); + // List::createShared(); for (auto& yrDb : yrsDb) { auto yr = dto::YearDto::createShared(); yr->id = yrDb.id; yr->year = yrDb.year; - yearRecs->pushBack(yr); + // yearRecs->pushBack(yr); + yearRecs->push_back(yr); } return createDtoResponse(Status::CODE_200, yearRecs); diff --git a/include/dto/AlbumDto.hpp b/include/dto/AlbumDto.hpp index 8eff244..482b236 100644 --- a/include/dto/AlbumDto.hpp +++ b/include/dto/AlbumDto.hpp @@ -1,14 +1,14 @@ #ifndef ALBUMDTO_H_ #define ALBUMDTO_H_ -#include "oatpp/core/data/mapping/type/Object.hpp" -#include "oatpp/core/macro/codegen.hpp" +#include +#include namespace dto { #include OATPP_CODEGEN_BEGIN(DTO) - class AlbumDto : public oatpp::data::mapping::type::Object { - DTO_INIT(AlbumDto, Object) + class AlbumDto : public oatpp::DTO { + DTO_INIT(AlbumDto, DTO) DTO_FIELD(Int32, id); DTO_FIELD(String, title); diff --git a/include/dto/ArtistDto.hpp b/include/dto/ArtistDto.hpp index 7d4c8ba..44f848f 100644 --- a/include/dto/ArtistDto.hpp +++ b/include/dto/ArtistDto.hpp @@ -1,14 +1,15 @@ #ifndef ARTISTDTO_H_ #define ARTISTDTO_H_ -#include "oatpp/core/data/mapping/type/Object.hpp" +// #include "oatpp/core/data/mapping/type/Object.hpp" +#include "oatpp/core/Types.hpp" #include "oatpp/core/macro/codegen.hpp" namespace dto { #include OATPP_CODEGEN_BEGIN(DTO) - class ArtistDto : public oatpp::data::mapping::type::Object { - DTO_INIT(ArtistDto, Object) + class ArtistDto : public oatpp::DTO { + DTO_INIT(ArtistDto, DTO) DTO_FIELD(Int32, id); DTO_FIELD(String, artist); diff --git a/include/dto/CoverArtDto.hpp b/include/dto/CoverArtDto.hpp index 22dca2c..75f7786 100644 --- a/include/dto/CoverArtDto.hpp +++ b/include/dto/CoverArtDto.hpp @@ -1,14 +1,14 @@ #ifndef COVERARTDTO_H_ #define COVERARTDTO_H_ -#include "oatpp/core/data/mapping/type/Object.hpp" #include "oatpp/core/macro/codegen.hpp" +#include namespace dto { #include OATPP_CODEGEN_BEGIN(DTO) - class CoverArtDto : public oatpp::data::mapping::type::Object { - DTO_INIT(CoverArtDto, Object) + class CoverArtDto : public oatpp::DTO { + DTO_INIT(CoverArtDto, DTO) DTO_FIELD(Int32, id); DTO_FIELD(String, songTitle); diff --git a/include/dto/GenreDto.hpp b/include/dto/GenreDto.hpp index f1b6753..490a1bb 100644 --- a/include/dto/GenreDto.hpp +++ b/include/dto/GenreDto.hpp @@ -1,14 +1,14 @@ #ifndef GENREDTO_H_ #define GENREDTO_H_ -#include "oatpp/core/data/mapping/type/Object.hpp" #include "oatpp/core/macro/codegen.hpp" +#include namespace dto { #include OATPP_CODEGEN_BEGIN(DTO) - class GenreDto : public oatpp::data::mapping::type::Object { - DTO_INIT(GenreDto, Object) + class GenreDto : public oatpp::DTO { + DTO_INIT(GenreDto, DTO) DTO_FIELD(Int32, id); DTO_FIELD(String, category); diff --git a/include/dto/YearDto.hpp b/include/dto/YearDto.hpp index 915c270..e2c190b 100644 --- a/include/dto/YearDto.hpp +++ b/include/dto/YearDto.hpp @@ -1,14 +1,14 @@ #ifndef YEARDTO_H_ #define YEARDTO_H_ -#include "oatpp/core/data/mapping/type/Object.hpp" #include "oatpp/core/macro/codegen.hpp" +#include namespace dto { #include OATPP_CODEGEN_BEGIN(DTO) - class YearDto : public oatpp::data::mapping::type::Object { - DTO_INIT(YearDto, Object) + class YearDto : public oatpp::DTO { + DTO_INIT(YearDto, DTO) DTO_FIELD(Int32, id); DTO_FIELD(Int32, year); diff --git a/include/dto/conversion/DtoConversions.h b/include/dto/conversion/DtoConversions.h index 5294407..3b7074f 100644 --- a/include/dto/conversion/DtoConversions.h +++ b/include/dto/conversion/DtoConversions.h @@ -1,31 +1,136 @@ #ifndef DTOCONVERSIONS_H_ #define DTOCONVERSIONS_H_ +#include +#include +#include + #include "dto/AlbumDto.hpp" #include "dto/LoginResultDto.hpp" #include "dto/SongDto.hpp" #include "model/Models.h" +#include "oatpp/core/data/mapping/ObjectMapper.hpp" + +using model::User; +using model::Song; +using model::Token; +using model::RegisterResult; + +using namespace model; +using namespace dto; namespace dto { namespace conversion { class DtoConversions { public: // static dto::LoginResultDto::ObjectWrapper toLoginResultDto(const model::User&, const model::Token&); - static dto::LoginResultDto toLoginResultDto(const model::User&, const model::Token&); + // static oatpp::data::mapping::type::ObjectWrapper toLoginResultDto(const model::User &user, const model::Token &token) + // static dto::LoginResultDto::ObjectWrapper toLoginResultDto(const model::User &user, const model::Token &token) + // static dto::LoginResultDto::ObjectWrapper toLoginResultDto(const User &user, const Token &token) + template + static D toLoginResultDto(const User &user, const Token &token) + { + // const model::Token& token) { + auto logRes = LoginResultDto::createShared(); + /** + logRes->username = user.username.c_str(); + logRes->token = token.accessToken.c_str(); + logRes->token_type = token.tokenType.c_str(); + logRes->expiration = token.expiration; + */ + + return logRes; + } // static dto::RegisterResultDto::ObjectWrapper toRegisterResultDto( - static dto::RegisterResultDto toRegisterResultDto( - const model::RegisterResult&); + template + static D toRegisterResultDto( + const model::RegisterResult ®Res) + { + auto result = RegisterResultDto::createShared(); + /** + result->message = regRes.message.c_str(); + result->registered = regRes.registered; + result->username = regRes.username.c_str(); + */ + + return result; + } // static dto::AlbumDto::ObjectWrapper toAlbumDto(const model::Album&); - static dto::AlbumDto toAlbumDto(const model::Album&); + template> + static D toAlbumDto(const Album &album) + { + auto result = AlbumDto::createShared(); + result->id = (album.id != 0) ? album.id : 0; + result->title = (!album.title.empty()) ? album.title.c_str() : ""; + result->artist = (!album.artist.empty()) ? album.artist.c_str() : ""; + result->year = (album.year != 0) ? album.year : 0; - static dto::SongDto toSongDto(const model::Song&); + return result; + } + + template + static D toSongDto(const model::Song &song) + { + auto result = SongDto::createShared(); + /** + result->id = (song.id != 0) ? song.id : 0; + result->title = (!song.title.empty()) ? song.title.c_str() : ""; + result->album = (!song.album.empty()) ? song.album.c_str() : ""; + result->artist = (!song.artist.empty()) ? song.artist.c_str() : ""; + result->album_artist = (!song.albumArtist.empty()) ? song.albumArtist.c_str() : ""; + result->genre = (!song.genre.empty()) ? song.genre.c_str() : ""; + result->duration = (song.duration != 0) ? song.duration : 0; + result->year = (song.year != 0) ? song.year : 0; + result->track = (song.track != 0) ? song.track : 0; + result->disc = (song.disc != 0) ? song.disc : 0; + result->coverart_id = (song.coverArtId != 0) ? song.coverArtId : 0; + */ + + return result; + } // static model::Song toSong(dto::SongDto::ObjectWrapper&); - static model::Song toSong(dto::SongDto*); + template, typename Song = Song> + static model::Song toSong(D songDto) + { + Song song; + /** + song.id = (songDto.id.getPtr() == nullptr) ? 0 : songDto.id->getValue(); + song.title = (songDto.title == nullptr) ? "" : songDto.title.c_str(); + song.album = (songDto.album == nullptr) ? "" : songDto.album.c_str(); + song.artist = (songDto.artist == nullptr) ? "" : songDto.artist.c_str(); + song.albumArtist = (songDto.album_artist == nullptr) ? + "" : songDto.album_artist.c_str(); + song.genre = (songDto.genre == nullptr) ? "" : songDto.genre.c_str(); + song.year = (songDto.year.getPtr() == nullptr) ? 0 : songDto.year.getValue(); + song.track = (songDto.track.getPtr() == nullptr) ? 0 : songDto.track.getValue(); + song.disc = (songDto.disc.getPtr() == nullptr) ? 0 : songDto.disc.getValue(); + song.coverArtId = (songDto.coverart_id.getPtr() == nullptr) ? + 0 : songDto.coverart_id.getValue(); + */ + + return song; + + } // static model::User toUser(dto::UserDto::ObjectWrapper&); - static model::User toUser(dto::UserDto&); + template + static User toUser(D &userDto) + { + model::User user; + /** + user.id = (userDto->userId.getPtr() == nullptr) ? 0 : userDto->userId->getValue(); + user.firstname = (userDto->firstname == nullptr) ? "" : userDto->firstname->c_str(); + user.lastname = (userDto->lastname == nullptr) ? "" : userDto->lastname->c_str(); + user.phone = (userDto->phone == nullptr) ? "" : userDto->phone->c_str(); + user.email = (userDto->email == nullptr) ? "" : userDto->email->c_str(); + user.username = (userDto->username == nullptr) ? "" : userDto->username->c_str(); + user.password = (userDto->password == nullptr) ? "" : userDto->password->c_str(); + */ + + return user; + } }; }} diff --git a/src/Main.cpp b/src/Main.cpp index f502e80..4fc3dfb 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -5,19 +5,29 @@ #include #include -#include -#include "oatpp/network/server/SimpleTCPConnectionProvider.hpp" -#include "oatpp/web/server/HttpConnectionHandler.hpp" +// #include +// #include "oatpp/network/server/SimpleTCPConnectionProvider.hpp" +// #include "oatpp/web/server/HttpConnectionHandler.hpp" + +#include + +// #include +#include +// #include +#include + #include "component/AppComponent.hpp" -#include "controller/ArtistController.hpp" +// #include "controller/ArtistController.hpp" #include "controller/AlbumController.hpp" +/** #include "controller/CoverArtController.hpp" #include "controller/GenreController.hpp" #include "controller/LoginController.hpp" #include "controller/RegisterController.hpp" #include "controller/SongController.hpp" #include "controller/YearController.hpp" +*/ #include "model/Models.h" #include "verify/Initialization.h" @@ -26,9 +36,13 @@ namespace fs = std::filesystem; void run(const model::BinaryPath& bConf) { component::AppComponent component; - OATPP_COMPONENT(std::shared_ptr, router); + // OATPP_COMPONENT(std::shared_ptr, router); + auto router = oatpp::web::server::HttpRouter::createShared(); + + auto connectionHandler = oatpp::web::server::HttpConnectionHandler::createShared(router); auto albumController = std::make_shared(bConf); + /** auto artistController = std::make_shared(bConf); auto coverArtController = std::make_shared(bConf); auto gnrController = std::make_shared(bConf); @@ -36,8 +50,10 @@ void run(const model::BinaryPath& bConf) { auto regController = std::make_shared(bConf); auto sngController = std::make_shared(bConf); auto yearController = std::make_shared(bConf); + */ albumController->addEndpointsToRouter(router); + /** artistController->addEndpointsToRouter(router); coverArtController->addEndpointsToRouter(router); gnrController->addEndpointsToRouter(router); @@ -45,12 +61,13 @@ void run(const model::BinaryPath& bConf) { regController->addEndpointsToRouter(router); sngController->addEndpointsToRouter(router); yearController->addEndpointsToRouter(router); + */ - OATPP_COMPONENT(std::shared_ptr, connectionHandler); + // OATPP_COMPONENT(std::shared_ptr, connectionHandler); OATPP_COMPONENT(std::shared_ptr, connectionProvider); - oatpp::network::server::Server server(connectionProvider, connectionHandler); + oatpp::network::Server server(connectionProvider, connectionHandler); OATPP_LOGI("icarus", "Server running on port %s", connectionProvider->getProperty("port").getData()); diff --git a/src/dto/conversion/DtoConversions.cpp b/src/dto/conversion/DtoConversions.cpp index cb52a4e..1391413 100644 --- a/src/dto/conversion/DtoConversions.cpp +++ b/src/dto/conversion/DtoConversions.cpp @@ -1,20 +1,18 @@ #include "dto/conversion/DtoConversions.h" + namespace dto { namespace conversion { // LoginResultDto::ObjectWrapper DtoConversions::toLoginResultDto(const model::User& user, - LoginResultDto DtoConversions::toLoginResultDto(const model::User& user, - const model::Token& token) { - auto logRes = dto::LoginResultDto::createShared(); - logRes->username = user.username.c_str(); - logRes->token = token.accessToken.c_str(); - logRes->token_type = token.tokenType.c_str(); - logRes->expiration = token.expiration; + // dto::LoginResultDto DtoConversions::toLoginResultDto(const model::User& user, - return logRes; + /** + oatpp::data::mapping::type::DTOWrapper DtoConversions::toLoginResultDto(const model::User& user, } + */ // dto::RegisterResultDto::ObjectWrapper DtoConversions::toRegisterResultDto( + /** dto::RegisterResultDto DtoConversions::toRegisterResultDto( const model::RegisterResult& regRes) { auto result = dto::RegisterResultDto::createShared(); @@ -24,9 +22,11 @@ namespace dto { namespace conversion { return result; } + */ // dto::AlbumDto::ObjectWrapper DtoConversions::toAlbumDto(const model::Album& album) { + /** dto::AlbumDto DtoConversions::toAlbumDto(const model::Album& album) { auto result = dto::AlbumDto::createShared(); result->id = (album.id != 0) ? album.id : 0; @@ -36,9 +36,11 @@ namespace dto { namespace conversion { return result; } + */ // dto::SongDto::ObjectWrapper DtoConversions::toSongDto(const model::Song& song) { + /** dto::SongDto DtoConversions::toSongDto(const model::Song& song) { auto result = dto::SongDto::createShared(); result->id = (song.id != 0) ? song.id : 0; @@ -55,9 +57,11 @@ namespace dto { namespace conversion { return result; } + */ // model::Song DtoConversions::toSong(dto::SongDto::ObjectWrapper& songDto) { + /** model::Song DtoConversions::toSong(dto::SongDto *songDto) { model::Song song; song.id = (songDto->id.getPtr() == nullptr) ? 0 : songDto->id->getValue(); @@ -75,6 +79,7 @@ namespace dto { namespace conversion { return song; } + */ // model::User DtoConversions::toUser(dto::UserDto::ObjectWrapper& userDto) {