Switching to C++ #60

Merged
kdeng00 merged 36 commits from experiment into master 2019-09-03 16:17:20 -04:00
7 changed files with 72 additions and 66 deletions
Showing only changes of commit c0fba2c9d8 - Show all commits
+2 -2
View File
@@ -16,8 +16,6 @@ set(SOURCES
src/database/genreRepository.cpp
src/database/songRepository.cpp
src/database/yearRepository.cpp
src/dto/loginResultDto.hpp
src/dto/songDto.hpp
src/main.cpp
src/managers/albumManager.cpp
src/managers/artistManager.cpp
@@ -38,6 +36,8 @@ set(HEADERS
include/database/genreRepository.h
include/database/songRepository.h
include/database/yearRepository.h
include/dto/loginResultDto.hpp
include/dto/songDto.hpp
include/managers/albumManager.h
include/managers/artistManager.h
include/managers/coverArtManager.h
+34
View File
@@ -0,0 +1,34 @@
#ifndef LOGINRESULTDTO_H_
#define LOGINRESULTDTO_H_
#include "oatpp/core/data/mapping/type/Object.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace Dto
{
#include OATPP_CODEGEN_BEGIN(DTO)
class loginResultDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(loginResultDto, Object)
DTO_FIELD(Int32, id);
DTO_FIELD(String, username);
DTO_FIELD(String, token);
DTO_FIELD(String, token_type);
DTO_FIELD(Int32, expiration);
DTO_FIELD(String, message);
};
class userDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(userDto, Object)
DTO_FIELD(String, username);
DTO_FIELD(String, password);
};
#include OATPP_CODEGEN_END(DTO)
}
#endif
+29
View File
@@ -0,0 +1,29 @@
#ifndef SONGDTO_H_
#define SONGDTO_H_
#include "oatpp/core/data/mapping/type/Object.hpp"
#include "oatpp/core/macro/codegen.hpp"
namespace Dto
{
#include OATPP_CODEGEN_BEGIN(DTO)
class songDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(songDto, Object)
DTO_FIELD(Int32, id);
DTO_FIELD(String, title);
DTO_FIELD(String, artist);
DTO_FIELD(String, album);
DTO_FIELD(String, genre);
DTO_FIELD(Int32, track);
DTO_FIELD(Int32, disc);
DTO_FIELD(Int32, year);
DTO_FIELD(Int32, duration);
};
#include OATPP_CODEGEN_END(DTO)
}
#endif
+3 -3
View File
@@ -9,7 +9,7 @@
#include "oatpp/core/macro/component.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "../dto/loginResultDto.hpp"
#include "dto/loginResultDto.hpp"
#include "managers/token_manager.h"
namespace Controller
@@ -27,14 +27,14 @@ namespace Controller
#include OATPP_CODEGEN_BEGIN(ApiController)
ENDPOINT("POST", "/api/v1/login", data, BODY_DTO(userDto::ObjectWrapper, usr)) {
ENDPOINT("POST", "/api/v1/login", data, BODY_DTO(Dto::userDto::ObjectWrapper, usr)) {
OATPP_LOGI("icarus", "logging in");
Manager::token_manager tok;
//auto token = tok.retrieve_token(exe_path);
auto token = tok.retrieve_token(m_bConf);
auto logRes = loginResultDto::createShared();
auto logRes = Dto::loginResultDto::createShared();
logRes->id = 0; // TODO: change this later on to something meaningful
logRes->username = usr->username->c_str();
logRes->token = token.access_token.c_str();
+4 -4
View File
@@ -18,7 +18,7 @@
#include "oatpp/web/server/api/ApiController.hpp"
#include "database/songRepository.h"
#include "../dto/songDto.hpp"
#include "dto/songDto.hpp"
#include "managers/song_manager.h"
#include "managers/token_manager.h"
#include "models/models.h"
@@ -88,11 +88,11 @@ namespace Controller
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<songDto::ObjectWrapper>::createShared();
auto songs = oatpp::data::mapping::type::List<Dto::songDto::ObjectWrapper>::createShared();
std::cout << "creating object to send" << std::endl;
for (auto& songDb : songsDb) {
auto song = songDto::createShared();
auto song = Dto::songDto::createShared();
song->id = songDb.id;
song->title = songDb.title.c_str();
song->artist = songDb.artist.c_str();
@@ -119,7 +119,7 @@ namespace Controller
songDb = songRepo.retrieveRecord(songDb, Type::songFilter::id);
auto song = songDto::createShared();
auto song = Dto::songDto::createShared();
song->id = songDb.id;
song->title = songDb.title.c_str();
song->artist = songDb.artist.c_str();
-31
View File
@@ -1,31 +0,0 @@
#ifndef LOGINRESULTDTO_H_
#define LOGINRESULTDTO_H_
#include "oatpp/core/data/mapping/type/Object.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include OATPP_CODEGEN_BEGIN(DTO)
class loginResultDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(loginResultDto, Object)
DTO_FIELD(Int32, id);
DTO_FIELD(String, username);
DTO_FIELD(String, token);
DTO_FIELD(String, token_type);
DTO_FIELD(Int32, expiration);
DTO_FIELD(String, message);
};
class userDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(userDto, Object)
DTO_FIELD(String, username);
DTO_FIELD(String, password);
};
#include OATPP_CODEGEN_END(DTO)
#endif
-26
View File
@@ -1,26 +0,0 @@
#ifndef SONGDTO_H_
#define SONGDTO_H_
#include "oatpp/core/data/mapping/type/Object.hpp"
#include "oatpp/core/macro/codegen.hpp"
#include OATPP_CODEGEN_BEGIN(DTO)
class songDto : public oatpp::data::mapping::type::Object
{
DTO_INIT(songDto, Object)
DTO_FIELD(Int32, id);
DTO_FIELD(String, title);
DTO_FIELD(String, artist);
DTO_FIELD(String, album);
DTO_FIELD(String, genre);
DTO_FIELD(Int32, track);
DTO_FIELD(Int32, disc);
DTO_FIELD(Int32, year);
DTO_FIELD(Int32, duration);
};
#include OATPP_CODEGEN_END(DTO)
#endif