Added albumArtist field memeber to Song model. Automatically apply disc value 1 for song's metadata that have an empty disc field. Switched from TagLib::FileRef to TagLib::MPEG::File
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "database/AlbumRepository.h"
|
||||
#include "dto/AlbumDto.hpp"
|
||||
#include "dto/conversion/DtoConversions.h"
|
||||
#include "manager/AlbumManager.h"
|
||||
#include "manager/TokenManager.h"
|
||||
#include "model/Models.h"
|
||||
@@ -57,10 +58,7 @@ public:
|
||||
auto albums = oatpp::data::mapping::type::List<dto::AlbumDto::ObjectWrapper>::createShared();
|
||||
|
||||
for (auto& albDb : albsDb) {
|
||||
auto alb = dto::AlbumDto::createShared();
|
||||
alb->id = albDb.id;
|
||||
alb->title = albDb.title.c_str();
|
||||
alb->year = albDb.year;
|
||||
auto alb = dto::conversion::DtoConversions::toAlbumDto(albDb);
|
||||
|
||||
albums->pushBack(alb);
|
||||
}
|
||||
@@ -85,10 +83,7 @@ public:
|
||||
std::cout << "album exists" << std::endl;
|
||||
albDb = albRepo.retrieveRecord(albDb, type::AlbumFilter::id);
|
||||
|
||||
auto album = dto::AlbumDto::createShared();
|
||||
album->id = albDb.id;
|
||||
album->title = albDb.title.c_str();
|
||||
album->year = albDb.year;
|
||||
auto album = dto::conversion::DtoConversions::toAlbumDto(albDb);
|
||||
|
||||
return createDtoResponse(Status::CODE_200, album);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef ALBUMREPOSITORY_H_
|
||||
#define ALBUMREPOSITORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -30,9 +31,13 @@ namespace database
|
||||
|
||||
std::pair<model::Album, int> parseRecordWithSongCount(MYSQL_STMT*);
|
||||
|
||||
// TODO: after parseRecord(MYSQL_STMT*) is implemented remove
|
||||
// parseRecord(MYSQL_RES*)
|
||||
model::Album parseRecord(MYSQL_RES*);
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Album&,
|
||||
std::tuple<char*, char*>&);
|
||||
std::shared_ptr<MYSQL_BIND> valueBindWithSongCount(model::Album&,
|
||||
std::tuple<char*, char*>&, int&);
|
||||
|
||||
std::tuple<char*, char*> metadataBuffer();
|
||||
|
||||
model::Album parseRecord(MYSQL_STMT*);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace database
|
||||
class SongRepository : public BaseRepository
|
||||
{
|
||||
public:
|
||||
SongRepository(const std::string&);
|
||||
SongRepository(const model::BinaryPath&);
|
||||
|
||||
std::vector<model::Song> retrieveRecords();
|
||||
@@ -30,9 +29,9 @@ namespace database
|
||||
void updateRecord(const model::Song&);
|
||||
private:
|
||||
std::shared_ptr<MYSQL_BIND> valueBind(model::Song&,
|
||||
std::tuple<char*, char*, char*, char*, char*>&);
|
||||
std::tuple<char*, char*, char*, char*, char*, char*>&);
|
||||
|
||||
std::tuple<char*, char*, char*, char*, char*> metadataBuffer();
|
||||
std::tuple<char*, char*, char*, char*, char*, char*> metadataBuffer();
|
||||
|
||||
std::vector<model::Song> parseRecords(MYSQL_STMT*);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace dto
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
DTO_FIELD(String, title);
|
||||
DTO_FIELD(String, artist);
|
||||
DTO_FIELD(Int32, year);
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace dto
|
||||
DTO_FIELD(Int32, id);
|
||||
DTO_FIELD(String, title);
|
||||
DTO_FIELD(String, artist);
|
||||
DTO_FIELD(String, album_artist);
|
||||
DTO_FIELD(String, album);
|
||||
DTO_FIELD(String, genre);
|
||||
DTO_FIELD(Int32, track);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef DTOCONVERSIONS_H_
|
||||
#define DTOCONVERSIONS_H_
|
||||
|
||||
#include "dto/AlbumDto.hpp"
|
||||
#include "dto/LoginResultDto.hpp"
|
||||
#include "dto/SongDto.hpp"
|
||||
#include "model/Models.h"
|
||||
@@ -13,6 +14,8 @@ namespace dto { namespace conversion {
|
||||
static dto::RegisterResultDto::ObjectWrapper toRegisterResultDto(
|
||||
const model::RegisterResult&);
|
||||
|
||||
static dto::AlbumDto::ObjectWrapper toAlbumDto(const model::Album&);
|
||||
|
||||
static dto::SongDto::ObjectWrapper toSongDto(const model::Song&);
|
||||
|
||||
static model::Song toSong(dto::SongDto::ObjectWrapper&);
|
||||
|
||||
+35
-35
@@ -5,14 +5,24 @@
|
||||
#include <vector>
|
||||
|
||||
namespace model {
|
||||
struct Song {
|
||||
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;
|
||||
@@ -27,42 +37,35 @@ struct Song {
|
||||
int yearId;
|
||||
};
|
||||
|
||||
struct Artist {
|
||||
class Artist {
|
||||
public:
|
||||
Artist() = default;
|
||||
Artist(const Song& song)
|
||||
{
|
||||
id = song.artistId;
|
||||
artist = song.artist;
|
||||
}
|
||||
Artist(const Song& song) : id(song.artistId), artist(song.artist) { }
|
||||
Artist(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
std::string artist;
|
||||
};
|
||||
|
||||
struct Album {
|
||||
class Album {
|
||||
public:
|
||||
Album() = default;
|
||||
Album(const Song& song)
|
||||
{
|
||||
id = song.albumId;
|
||||
title = song.album;
|
||||
year = song.year;
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
struct Genre {
|
||||
class Genre {
|
||||
public:
|
||||
Genre() = default;
|
||||
Genre(const Song& song)
|
||||
{
|
||||
id = song.genreId;
|
||||
category = song.genre;
|
||||
}
|
||||
Genre(const Song& song) :
|
||||
id(song.genreId), category(song.genre) { }
|
||||
Genre(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
@@ -70,26 +73,22 @@ struct Genre {
|
||||
|
||||
};
|
||||
|
||||
struct Year {
|
||||
class Year {
|
||||
public:
|
||||
Year() = default;
|
||||
Year(const Song& song)
|
||||
{
|
||||
id = song.yearId;
|
||||
year = song.year;
|
||||
}
|
||||
Year(const Song& song) :
|
||||
id(song.yearId), year(song.year) { }
|
||||
Year(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
int year;
|
||||
};
|
||||
|
||||
struct Cover {
|
||||
class Cover {
|
||||
public:
|
||||
Cover() = default;
|
||||
Cover(const Song& song)
|
||||
{
|
||||
id = song.coverArtId;
|
||||
songTitle = song.title;
|
||||
}
|
||||
Cover(const Song& song) :
|
||||
id(song.coverArtId), songTitle(song.title) { }
|
||||
Cover(const int id) : id(id) { }
|
||||
|
||||
int id;
|
||||
@@ -163,11 +162,12 @@ struct DatabaseConnection {
|
||||
std::string database;
|
||||
};
|
||||
|
||||
struct BinaryPath {
|
||||
class BinaryPath {
|
||||
public:
|
||||
BinaryPath() = default;
|
||||
BinaryPath(const char *p) : path(std::move(p)) { }
|
||||
BinaryPath(std::string& p) : path(p) { }
|
||||
BinaryPath(const char *p) : path(p) { }
|
||||
BinaryPath(const std::string& p) : path(p) { }
|
||||
BinaryPath(const std::string&& p) : path(p) { }
|
||||
|
||||
std::string path;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace utility {
|
||||
class MetadataRetriever
|
||||
{
|
||||
public:
|
||||
model::Song retrieveMetadata(std::string&);
|
||||
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&);
|
||||
|
||||
Reference in New Issue
Block a user