From 682bca2d025edbc7e92ff9248c71f1b87972dbe0 Mon Sep 17 00:00:00 2001 From: sabudilovskiy Date: Thu, 30 Nov 2023 15:32:19 +0000 Subject: [PATCH] - --- .gen/unittest.txt | 1 + CMakeLists.txt | 1 + Makefile.local | 2 +- src/legacy/models/day/type.hpp | 33 +++++++++++++++++-- src/legacy/models/education_type/postgre.hpp | 3 +- src/legacy/models/education_type/type.hpp | 30 +++++++++++++++-- src/legacy/models/lesson_type/postgre.hpp | 4 +-- src/legacy/models/lesson_type/type.hpp | 22 ++++++++++++- .../models/lesson_week_type/postgre.hpp | 4 +-- src/legacy/models/lesson_week_type/type.hpp | 21 +++++++++++- src/legacy/models/subgroup/type.hpp | 27 +++++++++++++-- src/legacy/models/user_type/type.hpp | 22 +++++++++++++ src/openapi/enum/pg_mapper.hpp | 11 +++++++ vsu_timetable.code-workspace | 12 +++---- 14 files changed, 170 insertions(+), 23 deletions(-) diff --git a/.gen/unittest.txt b/.gen/unittest.txt index 3e564128..4d40c5c0 100644 --- a/.gen/unittest.txt +++ b/.gen/unittest.txt @@ -1,3 +1,4 @@ +utests/test_ct.cpp utests/remove_namespace.cpp utests/openapi/raw/to_tuple.cpp utests/openapi/raw/from_tuple.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 46e01e11..fd15784e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile.local b/Makefile.local index 5e40df6f..f093cd4c 100644 --- a/Makefile.local +++ b/Makefile.local @@ -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++ diff --git a/src/legacy/models/day/type.hpp b/src/legacy/models/day/type.hpp index 52ac1462..baad782e 100644 --- a/src/legacy/models/day/type.hpp +++ b/src/legacy/models/day/type.hpp @@ -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) +// { +// return nullptr; +// } +// struct enum_introspector_Day +// { +// using enum Day; +// static constexpr std::array names = { +// "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"}; +// static constexpr std::array values = {monday, tuesday, wednesday, +// thursday, friday, saturday}; +// }; +DECLARE_OPENAPI_ENUM(Day, int, + monday, + tuesday, + wednesday, + thursday, + friday, + saturday); +} // namespace legacy::models diff --git a/src/legacy/models/education_type/postgre.hpp b/src/legacy/models/education_type/postgre.hpp index b4b76b05..f8b3357d 100644 --- a/src/legacy/models/education_type/postgre.hpp +++ b/src/legacy/models/education_type/postgre.hpp @@ -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 diff --git a/src/legacy/models/education_type/type.hpp b/src/legacy/models/education_type/type.hpp index 38bd3054..9d4005d3 100644 --- a/src/legacy/models/education_type/type.hpp +++ b/src/legacy/models/education_type/type.hpp @@ -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) +// { +// return nullptr; +// } +// struct enum_introspector_EducationType +// { +// using enum EducationType; +// static constexpr std::array names = { +// "undergraduate", "magistracy", "postgraduate", "specialty"}; +// static constexpr std::array values = { +// undergraduate, magistracy, postgraduate, specialty}; +// }; +DECLARE_OPENAPI_ENUM(EducationType, int, + undergraduate, + magistracy, + postgraduate, + specialty); +} // namespace legacy::models diff --git a/src/legacy/models/lesson_type/postgre.hpp b/src/legacy/models/lesson_type/postgre.hpp index 2c8a96ea..f1267b45 100644 --- a/src/legacy/models/lesson_type/postgre.hpp +++ b/src/legacy/models/lesson_type/postgre.hpp @@ -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 diff --git a/src/legacy/models/lesson_type/type.hpp b/src/legacy/models/lesson_type/type.hpp index d5fd5eda..64c6bf04 100644 --- a/src/legacy/models/lesson_type/type.hpp +++ b/src/legacy/models/lesson_type/type.hpp @@ -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) +// { +// return nullptr; +// } +// struct enum_introspector_LessonType +// { +// using enum LessonType; +// static constexpr std::array names = { +// "labaratory", "lection", "practice"}; +// static constexpr std::array values = {labaratory, lection, +// practice}; +// }; +} // namespace legacy::models diff --git a/src/legacy/models/lesson_week_type/postgre.hpp b/src/legacy/models/lesson_week_type/postgre.hpp index f30202ed..580adc41 100644 --- a/src/legacy/models/lesson_week_type/postgre.hpp +++ b/src/legacy/models/lesson_week_type/postgre.hpp @@ -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 diff --git a/src/legacy/models/lesson_week_type/type.hpp b/src/legacy/models/lesson_week_type/type.hpp index 830a9e06..525b1086 100644 --- a/src/legacy/models/lesson_week_type/type.hpp +++ b/src/legacy/models/lesson_week_type/type.hpp @@ -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) +// { +// return nullptr; +// } +// struct enum_introspector_LessonWeekType +// { +// using enum LessonWeekType; +// static constexpr std::array names = {"all", "even", +// "odd"}; +// static constexpr std::array values = {all, even, odd}; +// }; +} // namespace legacy::models diff --git a/src/legacy/models/subgroup/type.hpp b/src/legacy/models/subgroup/type.hpp index c167c808..bdc2531b 100644 --- a/src/legacy/models/subgroup/type.hpp +++ b/src/legacy/models/subgroup/type.hpp @@ -3,5 +3,28 @@ #include 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) +// { +// return nullptr; +// } +// struct enum_introspector_Subgroup +// { +// using enum Subgroup; +// static constexpr std::array names = {"all", "first", +// "second"}; +// static constexpr std::array values = {all, first, second}; +// }; + +DECLARE_OPENAPI_ENUM(Subgroup, int, + all, + even, + odd); +} // namespace legacy::models diff --git a/src/legacy/models/user_type/type.hpp b/src/legacy/models/user_type/type.hpp index 110482a8..c7a8c0e1 100644 --- a/src/legacy/models/user_type/type.hpp +++ b/src/legacy/models/user_type/type.hpp @@ -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) +// { +// return nullptr; +// } +// struct enum_introspector_UserType +// { +// using enum UserType; +// static constexpr std::array names = { +// "user", "admin", "root", "teacher"}; +// static constexpr std::array values = {user, admin, root, +// teacher}; +// }; } // namespace legacy::models diff --git a/src/openapi/enum/pg_mapper.hpp b/src/openapi/enum/pg_mapper.hpp index cf89522b..b8d49edf 100644 --- a/src/openapi/enum/pg_mapper.hpp +++ b/src/openapi/enum/pg_mapper.hpp @@ -18,4 +18,15 @@ requires HasIntrospector struct PgMapper create_enumerator_func(); }; +template +requires HasIntrospector struct PgMapperFixed + : userver::storages::postgres::io::EnumMappingBase +{ + static constexpr userver::storages::postgres::DBTypeName postgres_name{ + schema.AsStringView(), name.AsStringView()}; + static constexpr userver::utils::TrivialBiMap enumerators = + create_enumerator_func(); +}; + } // namespace openapi diff --git a/vsu_timetable.code-workspace b/vsu_timetable.code-workspace index 6c36a952..11071035 100644 --- a/vsu_timetable.code-workspace +++ b/vsu_timetable.code-workspace @@ -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, },