Made some more changes
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
#include <oatpp/core/Types.hpp>
|
||||
#include <oatpp/core/macro/codegen.hpp>
|
||||
|
||||
namespace dto {
|
||||
namespace dto
|
||||
{
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class AlbumDto : public oatpp::DTO {
|
||||
class AlbumDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(AlbumDto, DTO)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
#include "oatpp/core/Types.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
|
||||
namespace dto {
|
||||
namespace dto
|
||||
{
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class ArtistDto : public oatpp::DTO {
|
||||
class ArtistDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(ArtistDto, DTO)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include <oatpp/core/Types.hpp>
|
||||
|
||||
namespace dto {
|
||||
namespace dto
|
||||
{
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class CoverArtDto : public oatpp::DTO {
|
||||
class CoverArtDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(CoverArtDto, DTO)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include <oatpp/core/Types.hpp>
|
||||
|
||||
namespace dto {
|
||||
namespace dto
|
||||
{
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class GenreDto : public oatpp::DTO {
|
||||
class GenreDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(GenreDto, DTO)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#ifndef LOGINRESULTDTO_H_
|
||||
#define LOGINRESULTDTO_H_
|
||||
|
||||
// #include <oatpp/core/data/mapping/type/Object.hpp>
|
||||
#include <oatpp/core/Types.hpp>
|
||||
#include <oatpp/core/macro/codegen.hpp>
|
||||
#include <oatpp/core/Types.hpp>
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace dto {
|
||||
namespace dto
|
||||
{
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
// class LoginResultDto : public oatpp::data::mapping::type::Object {
|
||||
class LoginResultDto : public oatpp::DTO {
|
||||
class LoginResultDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(LoginResultDto, DTO)
|
||||
|
||||
DTO_FIELD(oatpp::Int32, id);
|
||||
@@ -22,7 +22,8 @@ namespace dto {
|
||||
DTO_FIELD(oatpp::String, message);
|
||||
};
|
||||
|
||||
class RegisterResultDto : public oatpp::DTO {
|
||||
class RegisterResultDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(RegisterResultDto, DTO)
|
||||
|
||||
DTO_FIELD(oatpp::String, username);
|
||||
@@ -30,7 +31,8 @@ namespace dto {
|
||||
DTO_FIELD(oatpp::String, message);
|
||||
};
|
||||
|
||||
class UserDto : public oatpp::DTO {
|
||||
class UserDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(UserDto, DTO)
|
||||
|
||||
DTO_FIELD(oatpp::Int32, userId);
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
#define SONGDTO_H_
|
||||
|
||||
#include <oatpp/core/Types.hpp>
|
||||
// #include <oatpp/core/data/mapping/type/Object.hpp>
|
||||
#include <oatpp/core/macro/codegen.hpp>
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace dto {
|
||||
namespace dto
|
||||
{
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class SongDto : public oatpp::DTO {
|
||||
class SongDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(SongDto, DTO)
|
||||
|
||||
DTO_FIELD(oatpp::Int32, id);
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include <oatpp/core/Types.hpp>
|
||||
|
||||
namespace dto {
|
||||
namespace dto
|
||||
{
|
||||
#include OATPP_CODEGEN_BEGIN(DTO)
|
||||
|
||||
class YearDto : public oatpp::DTO {
|
||||
class YearDto : public oatpp::DTO
|
||||
{
|
||||
DTO_INIT(YearDto, DTO)
|
||||
|
||||
DTO_FIELD(Int32, id);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef DTOCONVERSIONS_H_
|
||||
#define DTOCONVERSIONS_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <oatpp/core/data/mapping/ObjectMapper.hpp>
|
||||
#include <oatpp/core/data/mapping/type/Type.hpp>
|
||||
#include <oatpp/core/data/mapping/type/Object.hpp>
|
||||
@@ -18,8 +22,10 @@
|
||||
using namespace model;
|
||||
using namespace dto;
|
||||
|
||||
namespace dto { namespace conversion {
|
||||
class DtoConversions {
|
||||
namespace dto::conversion
|
||||
{
|
||||
class DtoConversions
|
||||
{
|
||||
public:
|
||||
template<typename D = oatpp::Object<LoginResultDto>>
|
||||
static D toLoginResultDto(const User &user, const Token &token)
|
||||
@@ -124,22 +130,18 @@ namespace dto { namespace conversion {
|
||||
static Song toSong(const D &songDto)
|
||||
{
|
||||
Song song;
|
||||
int id = songDto->id;
|
||||
song.id = (songDto->id.getPtr() == nullptr) ? 0 : id;
|
||||
auto title = songDto->title.get();
|
||||
/**
|
||||
song.title = (songDto->title == nullptr) ? "" : songDto->title;
|
||||
song.album = (songDto->album == nullptr) ? "" : songDto->album.c_str();
|
||||
song.artist = (songDto->artist == nullptr) ? "" : songDto->artist.c_str();
|
||||
song.id = (songDto->id.getPtr() == nullptr) ? 0 : *songDto->id;
|
||||
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();
|
||||
"" : songDto->album_artist->c_str();
|
||||
song.genre = (songDto->genre == nullptr) ? "" : songDto->genre->c_str();
|
||||
song.year = (songDto->year.getPtr() == nullptr) ? 0 : *songDto->year;
|
||||
song.track = (songDto->track.getPtr() == nullptr) ? 0 : *songDto->track;
|
||||
song.disc = (songDto->disc.getPtr() == nullptr) ? 0 : *songDto->disc;
|
||||
song.coverArtId = (songDto->coverart_id.getPtr() == nullptr) ?
|
||||
0 : songDto->coverart_id.getValue();
|
||||
*/
|
||||
0 : *songDto->coverart_id;
|
||||
|
||||
return song;
|
||||
|
||||
@@ -149,20 +151,20 @@ namespace dto { namespace conversion {
|
||||
static User toUser(const D &userDto)
|
||||
{
|
||||
User user;
|
||||
int id = userDto->userId;
|
||||
/**
|
||||
user.id = (userDto->userId.getPtr() == nullptr) ? 0 : userDto->userId.getValue();
|
||||
user.id = (userDto->userId.getPtr()) ? 0 : *userDto->userId;
|
||||
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();
|
||||
*/
|
||||
|
||||
|
||||
std::cout << "Over\n";
|
||||
|
||||
return user;
|
||||
}
|
||||
};
|
||||
}}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user