Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
sabudilovskiy committed Oct 12, 2023
1 parent 8cc2ecb commit 1b7ddcd
Show file tree
Hide file tree
Showing 70 changed files with 452 additions and 443 deletions.
1 change: 0 additions & 1 deletion service/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "views/test-openapi-view/view.hpp"
#include "views/timetable/get/view.hpp"


void AppendPgControllers(userver::components::ComponentList& component_list)
{
using namespace components::controllers::postgres;
Expand Down
9 changes: 3 additions & 6 deletions src/components/controllers/postgres/admin/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ std::optional<models::AdminAccount> Controller::GetAccountByAdminId(
const boost::uuids::uuid& admin_id,
::utils::SharedTransaction transaction) const
{
::utils::FillSharedTransaction(transaction,
pg_cluster_);
::utils::FillSharedTransaction(transaction, pg_cluster_);
auto pg_result = transaction->transaction_.Execute(
sql::qGetAdminAccountByAdminId, admin_id);
return utils::ConvertPgResultToOptionalItem<models::AdminAccount>(
Expand All @@ -58,8 +57,7 @@ std::optional<models::AdminAccount> Controller::CreateAdmin(
const models::UserCredentials& user,
::utils::SharedTransaction transaction) const
{
::utils::FillSharedTransaction(transaction,
pg_cluster_);
::utils::FillSharedTransaction(transaction, pg_cluster_);
auto tuple_user = utils::convert::DropPropertiesToConstRefs(user);
auto result_id =
transaction->transaction_.Execute(sql::qCreateAdminAccount, tuple_user);
Expand All @@ -75,8 +73,7 @@ std::vector<models::AdminAccount> Controller::GetByFilter(
std::optional<models::AdminFilter>& filter,
::utils::SharedTransaction transaction) const
{
::utils::FillSharedTransaction(transaction,
pg_cluster_);
::utils::FillSharedTransaction(transaction, pg_cluster_);
auto pg_result =
utils::PgExecute(transaction, sql::qGetAdminsByFilter, filter);
return utils::ConvertPgResultToArray<models::AdminAccount>(pg_result);
Expand Down
2 changes: 1 addition & 1 deletion src/components/controllers/postgres/faculty/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ std::vector<models::Faculty> Controller::GetByFilter(
return utils::ConvertPgResultToArray<models::Faculty>(pg_result);
}

} // namespace
} // namespace components::controllers::postgres::faculty
// ::components::controllers::postgres::faculty
2 changes: 1 addition & 1 deletion src/components/controllers/postgres/faculty/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class Controller final : public userver::components::LoggableComponentBase
protected:
userver::storages::postgres::ClusterPtr pg_cluster_;
};
} // namespace
} // namespace components::controllers::postgres::faculty
// ::components::controllers::postgres::faculty
2 changes: 1 addition & 1 deletion src/components/controllers/postgres/faculty/fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ void Append(userver::components::ComponentList& component_list)
{
component_list.Append<Controller>();
}
} // namespace
} // namespace components::controllers::postgres::faculty
// ::components::controllers::postgres::faculty
2 changes: 1 addition & 1 deletion src/components/controllers/postgres/faculty/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace components::controllers::postgres::faculty
{
class Controller;
void Append(userver::components::ComponentList& component_list);
} // namespace
} // namespace components::controllers::postgres::faculty
// ::components::controllers::postgres::faculty
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ std::vector<models::GroupStage> Controller::GetByFilter(
return utils::ConvertPgResultToArray<models::GroupStage>(pg_result);
}

} // namespace
} // namespace components::controllers::postgres::group_stage
// ::components::controllers::postgres::group_stage
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class Controller final : public userver::components::LoggableComponentBase
protected:
userver::storages::postgres::ClusterPtr pg_cluster_;
};
} // namespace
} // namespace components::controllers::postgres::group_stage
// ::components::controllers::postgres::group_stage
2 changes: 1 addition & 1 deletion src/components/controllers/postgres/group_stage/fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ void Append(userver::components::ComponentList& component_list)
{
component_list.Append<Controller>();
}
} // namespace
} // namespace components::controllers::postgres::group_stage
// ::components::controllers::postgres::group_stage
2 changes: 1 addition & 1 deletion src/components/controllers/postgres/group_stage/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace components::controllers::postgres::group_stage
{
class Controller;
void Append(userver::components::ComponentList& component_list);
} // namespace
} // namespace components::controllers::postgres::group_stage
// ::components::controllers::postgres::group_stage
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once
#include <userver/storages/postgres/query.hpp>

namespace components::controllers::postgres::
group_stage::sql
namespace components::controllers::postgres::group_stage::sql
{
const userver::storages::postgres::Query qGetGroupStages(R"(
WITH group_stages_info AS(SELECT
Expand Down
3 changes: 1 addition & 2 deletions src/components/controllers/postgres/lesson/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ std::vector<models::LessonV1> Controller::Search(
const std::optional<models::LessonFilter>& filter,
::utils::SharedTransaction transaction) const
{
::utils::FillSharedTransaction(transaction,
pg_cluster_);
::utils::FillSharedTransaction(transaction, pg_cluster_);
auto pg_result =
utils::PgExecute(transaction, sql::qGetLessonsByFilter, filter);
return utils::ConvertPgResultToArray<models::LessonV1>(pg_result);
Expand Down
3 changes: 1 addition & 2 deletions src/components/controllers/postgres/lesson/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Controller final : public userver::components::LoggableComponentBase
"lesson_details_controller";
std::vector<models::LessonV1> Search(
const std::optional<models::LessonFilter>& filter,
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;
Controller(const userver::components::ComponentConfig& config,
const userver::components::ComponentContext& context);

Expand Down
5 changes: 2 additions & 3 deletions src/components/controllers/postgres/teacher/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ std::vector<models::Teacher> Controller::GetByFilter(
std::optional<models::TeacherFilter>& filter,
::utils::SharedTransaction transaction) const
{
::utils::FillSharedTransaction(transaction,
pg_cluster_);
::utils::FillSharedTransaction(transaction, pg_cluster_);
auto pg_result =
utils::PgExecute(transaction, sql::qGetTeachersByFilter, filter);
return utils::ConvertPgResultToArray<models::Teacher>(pg_result);
Expand Down Expand Up @@ -150,5 +149,5 @@ std::optional<boost::uuids::uuid> Controller::DropRequest(
return utils::ConvertPgResultToOptionalItem<boost::uuids::uuid>(pg_result);
}

} // namespace
} // namespace components::controllers::postgres::teacher
// ::components::controllers::postgres::teacher
23 changes: 8 additions & 15 deletions src/components/controllers/postgres/teacher/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,35 @@ class Controller final : public userver::components::LoggableComponentBase
public:
std::optional<boost::uuids::uuid> DropRequest(
const boost::uuids::uuid& request_id,
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;
std::vector<models::RequestPrivileges> GetAllRequests(
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;
std::optional<boost::uuids::uuid> ApproveAndLink(
const boost::uuids::uuid& request_id,
const boost::uuids::uuid& teacher_id,
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;

std::optional<boost::uuids::uuid> ApproveAndCreateAccount(
const boost::uuids::uuid& request_id,
const models::TeacherInfo& teacher_info,
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;

std::optional<boost::uuids::uuid> Link(
const boost::uuids::uuid& user_id, const boost::uuids::uuid& teacher_id,
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;

std::vector<models::Teacher> GetByFilter(
std::optional<models::TeacherFilter>& filter,
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;

std::optional<boost::uuids::uuid> CreateTeacher(
const models::TeacherInfo& teacher_info,
::utils::SharedTransaction transaction =
nullptr) const;
::utils::SharedTransaction transaction = nullptr) const;

::utils::SharedTransaction CreateTransaction();

protected:
userver::storages::postgres::ClusterPtr pg_cluster_;
};
} // namespace
} // namespace components::controllers::postgres::teacher
// ::components::controllers::postgres::teacher
2 changes: 1 addition & 1 deletion src/components/controllers/postgres/teacher/fwd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ void Append(userver::components::ComponentList& component_list)
{
component_list.Append<Controller>();
}
} // namespace
} // namespace components::controllers::postgres::teacher
// ::components::controllers::postgres::teacher
1 change: 1 addition & 0 deletions src/components/controllers/postgres/user/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Controller final : public userver::components::LoggableComponentBase
protected:
std::optional<models::User> HandleUserFromPg(
userver::storages::postgres::ResultSet& result) const;

private:
std::optional<boost::uuids::uuid> root_id;
userver::storages::postgres::ClusterPtr pg_cluster_;
Expand Down
3 changes: 1 addition & 2 deletions src/models/admin_account/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
namespace models
{
using AdminAccountTuple =
::utils::convert::drop_properties_to_ref_mut_t<
AdminAccount>;
::utils::convert::drop_properties_to_ref_mut_t<AdminAccount>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
3 changes: 1 addition & 2 deletions src/models/admin_filter/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
namespace models
{
using TupleAdminFilter =
::utils::convert::drop_properties_to_ref_const_t<
AdminFilter>;
::utils::convert::drop_properties_to_ref_const_t<AdminFilter>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
4 changes: 1 addition & 3 deletions src/models/faculty/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include "models/faculty/type.hpp"
namespace models
{
using TupleFaculty =
::utils::convert::drop_properties_to_ref_const_t<
Faculty>;
using TupleFaculty = ::utils::convert::drop_properties_to_ref_const_t<Faculty>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
3 changes: 1 addition & 2 deletions src/models/faculty_filter/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
namespace models
{
using TupleFacultyFilter =
::utils::convert::drop_properties_to_ref_const_t<
FacultyFilter>;
::utils::convert::drop_properties_to_ref_const_t<FacultyFilter>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
3 changes: 1 addition & 2 deletions src/models/group_stage/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
namespace models
{
using TupleGroupStage =
::utils::convert::drop_properties_to_ref_const_t<
GroupStage>;
::utils::convert::drop_properties_to_ref_const_t<GroupStage>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
3 changes: 1 addition & 2 deletions src/models/group_stage_filter/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
namespace models
{
using TupleGroupStageFilter =
::utils::convert::drop_properties_to_ref_const_t<
GroupStageFilter>;
::utils::convert::drop_properties_to_ref_const_t<GroupStageFilter>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
3 changes: 1 addition & 2 deletions src/models/lesson_filter/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
namespace models
{
using TupleLessonFilter =
::utils::convert::drop_properties_to_ref_const_t<
LessonFilter>;
::utils::convert::drop_properties_to_ref_const_t<LessonFilter>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
4 changes: 1 addition & 3 deletions src/models/lesson_v1/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@
#include "models/timestring/postgre.hpp"
namespace models
{
using TupleLessonV1 =
::utils::convert::drop_properties_to_ref_mut_t<
LessonV1>;
using TupleLessonV1 = ::utils::convert::drop_properties_to_ref_mut_t<LessonV1>;
}
3 changes: 1 addition & 2 deletions src/models/teacher/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
namespace models
{
using ConstTupleTeacher =
::utils::convert::drop_properties_to_ref_const_t<
Teacher>;
::utils::convert::drop_properties_to_ref_const_t<Teacher>;

} // namespace models

Expand Down
3 changes: 1 addition & 2 deletions src/models/teacher_filter/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
namespace models
{
using TupleTeacherFilter =
::utils::convert::drop_properties_to_ref_const_t<
TeacherFilter>;
::utils::convert::drop_properties_to_ref_const_t<TeacherFilter>;
} // namespace models

namespace userver::storages::postgres::io
Expand Down
3 changes: 1 addition & 2 deletions src/models/teacher_info/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
namespace models
{
using ConstTupleTeacherInfo =
::utils::convert::drop_properties_to_ref_const_t<
TeacherInfo>;
::utils::convert::drop_properties_to_ref_const_t<TeacherInfo>;

} // namespace models

Expand Down
3 changes: 1 addition & 2 deletions src/models/user/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#include "models/user_type/postgre.hpp"
namespace models
{
using TupleUserRaw =
::utils::convert::drop_properties_to_ref_const_t<User>;
using TupleUserRaw = ::utils::convert::drop_properties_to_ref_const_t<User>;

// using TupleUser =
// userver::utils::StrongTypedef<struct TupleLessonFilterTag,
Expand Down
3 changes: 1 addition & 2 deletions src/models/user_credentials/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
namespace models
{
using TupleUserCredentialsRaw =
::utils::convert::drop_properties_to_ref_const_t<
UserCredentials>;
::utils::convert::drop_properties_to_ref_const_t<UserCredentials>;
using TupleUserCredentials = TupleUserCredentialsRaw;
} // namespace models

Expand Down
5 changes: 3 additions & 2 deletions src/openapi/all.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#pragma once

#include <openapi/as_tuple/all.hpp>
#include <openapi/base/all.hpp>
#include <openapi/doc/serialize/all.hpp>
#include <openapi/from_tuple/all.hpp>
#include <openapi/http/all.hpp>
#include <openapi/json/all.hpp>
#include <openapi/as_tuple/all.hpp>
#include <openapi/postgres/mapping.hpp>
#include <openapi/to_tuple/all.hpp>
#include <openapi/from_tuple/all.hpp>
#include <openapi/types/all.hpp>
2 changes: 1 addition & 1 deletion src/openapi/as_tuple/property.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <openapi/base/property_base.hpp>
#include <openapi/as_tuple/default.hpp>
#include <openapi/base/property_base.hpp>
namespace openapi::raw
{
template <IsProperty U>
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/as_tuple/reflective.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <boost/pfr/core.hpp>
#include <boost/pfr/tuple_size.hpp>
#include <openapi/base/object_property.hpp>
#include <openapi/as_tuple/default.hpp>
#include <openapi/base/object_property.hpp>
#include <type_traits>
#include <utility>

Expand Down
12 changes: 1 addition & 11 deletions src/openapi/base/object_property.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
#pragma once

#include <openapi/base/reflective_checks.hpp>
#include <type_traits>

#include "property_base.hpp"

namespace openapi
{
namespace checks
{
template <typename T>
concept IsReflective = requires
{
requires std::is_class_v<T>;
requires std::is_aggregate_v<T>;
requires !IsProperty<T>;
};
} // namespace checks

template <checks::IsReflective T, typename Traits = EmptyTraits>
struct ObjectProperty : public PropertyBase<T, Traits>
{
Expand Down
Loading

0 comments on commit 1b7ddcd

Please sign in to comment.