Made some more changes

This commit is contained in:
kdeng00
2020-12-19 11:51:15 -05:00
parent 8306851dcb
commit eb928d0f9e
17 changed files with 198 additions and 295 deletions
+18 -7
View File
@@ -6,6 +6,7 @@
#include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp"
#include "oatpp/core/Types.hpp"
#include "oatpp/web/server/api/ApiController.hpp"
#include "dto/LoginResultDto.hpp"
@@ -13,20 +14,30 @@
#include "manager/UserManager.h"
#include "model/Models.h"
namespace controller {
class RegisterController : public oatpp::web::server::api::ApiController {
using namespace dto;
namespace controller
{
class RegisterController : public oatpp::web::server::api::ApiController
{
public:
RegisterController(const model::BinaryPath& bConf,
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper)) :
oatpp::web::server::api::ApiController(objectMapper), m_bConf(bConf) { }
OATPP_COMPONENT(std::shared_ptr<ObjectMapper>, objectMapper)) :
oatpp::web::server::api::ApiController(objectMapper),
m_bConf(bConf)
{
}
#include OATPP_CODEGEN_BEGIN(ApiController)
ENDPOINT("POST", "api/v1/register", registerUser,
// BODY_DTO(dto::UserDto::ObjectWrapper, usr)) {
BODY_DTO(oatpp::data::mapping::type::ObjectWrapper<dto::UserDto>, usr)) {
BODY_DTO(oatpp::Object<UserDto>, usr))
{
manager::UserManager usrMgr(m_bConf);
auto user = dto::conversion::DtoConversions::toUser(usr);
auto user = conversion::DtoConversions::toUser(usr);
OATPP_LOGI("icarus", "Dto converted");
if (usrMgr.doesUserExist(user)) {
return createResponse(Status::CODE_401, "user already exists");
}