Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
sabudilovskiy committed Nov 30, 2023
1 parent c9437cd commit 682bca2
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gen/unittest.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
utests/test_ct.cpp
utests/remove_namespace.cpp
utests/openapi/raw/to_tuple.cpp
utests/openapi/raw/from_tuple.cpp
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.12)
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(USERVER_FEATURE_GRPC OFF)
project(timetable_vsu_backend CXX)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.local
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CMAKE_COMMON_FLAGS += -DUSERVER_FEATURE_CRYPTOPP_BLAKE=0 -DUSERVER_FEATURE_GRPC_CHANNELZ=0
CMAKE_COMMON_FLAGS += -DUSERVER_FEATURE_CRYPTOPP_BLAKE=0 -DUSERVER_FEATURE_GRPC_CHANNELZ=0 -DCMAKE_CXX_COMPILER=g++
33 changes: 30 additions & 3 deletions src/legacy/models/day/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@

namespace legacy::models
{
DECLARE_OPENAPI_ENUM(Day, int, monday, tuesday, wednesday, thursday, friday,
saturday);
}
// enum struct Day : int
// {
// monday,
// tuesday,
// wednesday,
// thursday,
// friday,
// saturday
// };
// struct enum_introspector_Day;
// consteval enum_introspector_Day* get_enum_introspector(std ::type_identity<Day>)
// {
// return nullptr;
// }
// struct enum_introspector_Day
// {
// using enum Day;
// static constexpr std::array<std::string_view, 6> names = {
// "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
// static constexpr std::array<Day, 6> values = {monday, tuesday, wednesday,
// thursday, friday, saturday};
// };
DECLARE_OPENAPI_ENUM(Day, int,
monday,
tuesday,
wednesday,
thursday,
friday,
saturday);
} // namespace legacy::models
3 changes: 1 addition & 2 deletions src/legacy/models/education_type/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ namespace userver::storages::postgres::io
{
template <>
struct CppToUserPg<::legacy::models::EducationType>
: openapi::PgMapper<::legacy::models::EducationType,
"timetable_vsu.grouptype">
: openapi::PgMapper<::legacy::models::EducationType, "timetable_vsu.grouptype">
{
};
} // namespace userver::storages::postgres::io
30 changes: 27 additions & 3 deletions src/legacy/models/education_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@

namespace legacy::models
{
DECLARE_OPENAPI_ENUM(EducationType, int, undergraduate, magistracy,
postgraduate, specialty);
}
// enum struct EducationType : int
// {
// undergraduate,
// magistracy,
// postgraduate,
// specialty
// };
// struct enum_introspector_EducationType;
// consteval enum_introspector_EducationType* get_enum_introspector(
// std ::type_identity<EducationType>)
// {
// return nullptr;
// }
// struct enum_introspector_EducationType
// {
// using enum EducationType;
// static constexpr std::array<std::string_view, 4> names = {
// "undergraduate", "magistracy", "postgraduate", "specialty"};
// static constexpr std::array<EducationType, 4> values = {
// undergraduate, magistracy, postgraduate, specialty};
// };
DECLARE_OPENAPI_ENUM(EducationType, int,
undergraduate,
magistracy,
postgraduate,
specialty);
} // namespace legacy::models
4 changes: 2 additions & 2 deletions src/legacy/models/lesson_type/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace userver::storages::postgres::io
{
template <>
struct CppToUserPg<::legacy::models::LessonType>
: openapi::PgMapper<::legacy::models::LessonType,
"timetable_vsu.type_lesson">
: openapi::PgMapperFixed<::legacy::models::LessonType, "timetable_vsu",
"type_lesson">
{
};
} // namespace userver::storages::postgres::io
22 changes: 21 additions & 1 deletion src/legacy/models/lesson_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,24 @@ namespace legacy::models
{
DECLARE_OPENAPI_ENUM(LessonType, int, labaratory, lection, practice, some_test,
some_test2, some_test3);
}
// enum struct LessonType : int
// {
// labaratory,
// lection,
// practice
// };
// struct enum_introspector_LessonType;
// consteval enum_introspector_LessonType* get_enum_introspector(
// std ::type_identity<LessonType>)
// {
// return nullptr;
// }
// struct enum_introspector_LessonType
// {
// using enum LessonType;
// static constexpr std::array<std::string_view, 3> names = {
// "labaratory", "lection", "practice"};
// static constexpr std::array<LessonType, 3> values = {labaratory, lection,
// practice};
// };
} // namespace legacy::models
4 changes: 2 additions & 2 deletions src/legacy/models/lesson_week_type/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace userver::storages::postgres::io
{
template <>
struct CppToUserPg<::legacy::models::LessonWeekType>
: openapi::PgMapper<::legacy::models::LessonWeekType,
"timetable_vsu.type_of_week">
: openapi::PgMapperFixed<::legacy::models::LessonWeekType, "timetable_vsu",
"type_of_week">
{
};
} // namespace userver::storages::postgres::io
21 changes: 20 additions & 1 deletion src/legacy/models/lesson_week_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,23 @@
namespace legacy::models
{
DECLARE_OPENAPI_ENUM(LessonWeekType, int, all, even, odd);
}
// enum struct LessonWeekType : int
// {
// all,
// even,
// odd
// };
// struct enum_introspector_LessonWeekType;
// consteval enum_introspector_LessonWeekType* get_enum_introspector(
// std ::type_identity<LessonWeekType>)
// {
// return nullptr;
// }
// struct enum_introspector_LessonWeekType
// {
// using enum LessonWeekType;
// static constexpr std::array<std::string_view, 3> names = {"all", "even",
// "odd"};
// static constexpr std::array<LessonWeekType, 3> values = {all, even, odd};
// };
} // namespace legacy::models
27 changes: 25 additions & 2 deletions src/legacy/models/subgroup/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,28 @@
#include <openapi/enum/declare.hpp>
namespace legacy::models
{
DECLARE_OPENAPI_ENUM(Subgroup, int, all, first, second);
}
// enum struct Subgroup : int
// {
// all,
// first,
// second
// };
// struct enum_introspector_Subgroup;
// consteval enum_introspector_Subgroup* get_enum_introspector(
// std ::type_identity<Subgroup>)
// {
// return nullptr;
// }
// struct enum_introspector_Subgroup
// {
// using enum Subgroup;
// static constexpr std::array<std::string_view, 3> names = {"all", "first",
// "second"};
// static constexpr std::array<Subgroup, 3> values = {all, first, second};
// };

DECLARE_OPENAPI_ENUM(Subgroup, int,
all,
even,
odd);
} // namespace legacy::models
22 changes: 22 additions & 0 deletions src/legacy/models/user_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,26 @@ DECLARE_OPENAPI_ENUM(UserType, int,
root,
teacher);
// clang-format on

// enum struct UserType : int
// {
// user,
// admin,
// root,
// teacher
// };
// struct enum_introspector_UserType;
// consteval enum_introspector_UserType* get_enum_introspector(
// std ::type_identity<UserType>)
// {
// return nullptr;
// }
// struct enum_introspector_UserType
// {
// using enum UserType;
// static constexpr std::array<std::string_view, 4> names = {
// "user", "admin", "root", "teacher"};
// static constexpr std::array<UserType, 4> values = {user, admin, root,
// teacher};
// };
} // namespace legacy::models
11 changes: 11 additions & 0 deletions src/openapi/enum/pg_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@ requires HasIntrospector<T> struct PgMapper
create_enumerator_func<T>();
};

template <typename T, utils::ConstexprString schema,
utils::ConstexprString name>
requires HasIntrospector<T> struct PgMapperFixed
: userver::storages::postgres::io::EnumMappingBase<T>
{
static constexpr userver::storages::postgres::DBTypeName postgres_name{
schema.AsStringView(), name.AsStringView()};
static constexpr userver::utils::TrivialBiMap enumerators =
create_enumerator_func<T>();
};

} // namespace openapi
12 changes: 6 additions & 6 deletions vsu_timetable.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
},
"settings": {
"files.exclude": {
"third_party": true,
"build*": true,
".*" : true,
"dependencies" : true,
"compile_commands.json" : true,
"configs/static_config.yaml" : true
// "third_party": true,
// "build*": true,
// ".*" : true,
// "dependencies" : true,
// "compile_commands.json" : true,
// "configs/static_config.yaml" : true
},
"C_Cpp.codeAnalysis.clangTidy.useBuildPath": true,
},
Expand Down

0 comments on commit 682bca2

Please sign in to comment.