Left off at adding album record to the database and retrieving the album record to assign the album id to the song record's album id foreign key

This commit is contained in:
kdeng00
2019-09-01 18:46:02 -04:00
parent ab3000c2a0
commit fafb39326b
17 changed files with 320 additions and 59 deletions
+38
View File
@@ -0,0 +1,38 @@
#ifndef APPCOMPONENT_H_
#define APPCOMPONENT_H_
#include <memory>
#include "oatpp/core/macro/component.hpp"
#include "oatpp/network/server/SimpleTCPConnectionProvider.hpp"
#include "oatpp/parser/json/mapping/ObjectMapper.hpp"
#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(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::network::server::ConnectionHandler>, serverConnectionHandler)([] {
OATPP_COMPONENT(std::shared_ptr<oatpp::web::server::HttpRouter>, 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:
};
}
#endif
+11
View File
@@ -1,8 +1,11 @@
#ifndef ALBUMREPOSITORY_H_
#define ALBUMREPOSITORY_H_
#include <vector>
#include "database/base_repository.h"
#include "models/models.h"
#include "types/albumFilter.h"
namespace Database
{
@@ -10,7 +13,15 @@ namespace Database
{
public:
albumRepository(const Model::BinaryPath&);
std::vector<Model::Album> retrieveRecords();
Model::Album retrieveRecord(Model::Album&, Type::albumFilter);
void saveAlbum(const Model::Album&);
private:
std::vector<Model::Album> parseRecords(MYSQL_RES*);
Model::Album parseRecord(MYSQL_RES*);
};
}
+2
View File
@@ -9,6 +9,8 @@ namespace Manager
{
public:
albumManager(const Model::BinaryPath&);
void saveAlbum(const Model::Song&);
private:
Model::BinaryPath m_bConf;
};
+1
View File
@@ -22,6 +22,7 @@ namespace Manager
static void printSong(const Model::Song&);
private:
void saveSongTemp(Model::Song&);
void saveMisc(Model::Song&);
Model::BinaryPath m_bConf;
std::string exe_path;
+2
View File
@@ -92,6 +92,8 @@ namespace Model
struct BinaryPath
{
BinaryPath() = default;
BinaryPath(const char *p) : path(std::move(p)) { }
std::string path;
};
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef ALBUMFILTER_H_
#define ALBUMFILTER_H_
namespace Type
{
enum class albumFilter
{
id = 0,
title,
year
};
}
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef ARTISTFILTER_H_
#define ARTISTFILTER_H_
namespace Type
{
enum class artistFilter
{
id = 0,
artist
};
}
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef GENREFILTER_H_
#define GENREFILTER_H_
namespace Type
{
enum class genreFilter
{
id = 0,
category
};
}
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef YEARFILTER_H_
#define YEARFILTER_H_
namespace Type
{
enum class yearFilter
{
id = 0,
year
};
}
#endif