Working on fixing build errors
This commit is contained in:
@@ -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 <oatpp/core/Types.hpp>
|
||||
#include <oatpp/core/macro/codegen.hpp>
|
||||
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <oatpp/core/Types.hpp>
|
||||
|
||||
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);
|
||||
|
||||
@@ -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 <oatpp/core/Types.hpp>
|
||||
|
||||
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);
|
||||
|
||||
@@ -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 <oatpp/core/Types.hpp>
|
||||
|
||||
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);
|
||||
|
||||
@@ -1,31 +1,136 @@
|
||||
#ifndef DTOCONVERSIONS_H_
|
||||
#define DTOCONVERSIONS_H_
|
||||
|
||||
#include <oatpp/core/data/mapping/type/Type.hpp>
|
||||
#include <oatpp/core/data/mapping/type/Object.hpp>
|
||||
#include <oatpp/core/Types.hpp>
|
||||
|
||||
#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<dto::LoginResultDto> 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<typename D = LoginResultDto>
|
||||
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<typename D = RegisterResultDto>
|
||||
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<typename D = oatpp::Object<AlbumDto>>
|
||||
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<typename D = SongDto>
|
||||
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 D = oatpp::Object<SongDto>, 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<typename D = UserDto>
|
||||
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;
|
||||
}
|
||||
};
|
||||
}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user