Adding coverart id field to Song dto object to return the coverart id that the song is associated with so it is easier to get the cover art
This commit is contained in:
@@ -23,6 +23,7 @@ namespace dto
|
||||
DTO_FIELD(Int32, disc);
|
||||
DTO_FIELD(Int32, year);
|
||||
DTO_FIELD(Int32, duration);
|
||||
DTO_FIELD(Int32, coverart_id);
|
||||
};
|
||||
|
||||
#include OATPP_CODEGEN_END(DTO)
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace dto { namespace conversion {
|
||||
static dto::RegisterResultDto::ObjectWrapper toRegisterResultDto(
|
||||
const model::RegisterResult&);
|
||||
|
||||
static dto::SongDto::ObjectWrapper toSongDto(const model::Song&);
|
||||
|
||||
static model::Song toSong(dto::SongDto::ObjectWrapper&);
|
||||
|
||||
static model::User toUser(dto::UserDto::ObjectWrapper&);
|
||||
|
||||
@@ -24,6 +24,22 @@ namespace dto { namespace conversion {
|
||||
}
|
||||
|
||||
|
||||
dto::SongDto::ObjectWrapper DtoConversions::toSongDto(const model::Song& song) {
|
||||
auto result = dto::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->genre = (!song.genre.empty()) ? song.genre.c_str() : "";
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
model::Song DtoConversions::toSong(dto::SongDto::ObjectWrapper& songDto) {
|
||||
model::Song song;
|
||||
song.id = (songDto->id.getPtr() == nullptr) ? 0 : songDto->id->getValue();
|
||||
@@ -34,6 +50,8 @@ namespace dto { namespace conversion {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user