File tree Expand file tree Collapse file tree 4 files changed +13
-19
lines changed
Expand file tree Collapse file tree 4 files changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,9 @@ target_include_directories(crud-lib PUBLIC src)
2525
2626## link libs
2727
28- find_package (oatpp 1.2.5 REQUIRED)
29- find_package (oatpp-swagger 1.2.5 REQUIRED)
30- find_package (oatpp-sqlite 1.2.5 REQUIRED)
28+ find_package (oatpp 1.3.0 REQUIRED)
29+ find_package (oatpp-swagger 1.3.0 REQUIRED)
30+ find_package (oatpp-sqlite 1.3.0 REQUIRED)
3131
3232target_link_libraries (crud-lib
3333 # Oat++
Original file line number Diff line number Diff line change @@ -14,21 +14,15 @@ void run() {
1414
1515 AppComponent components; // Create scope Environment components
1616
17- /* create ApiControllers and add endpoints to router */
18-
19- auto router = components.httpRouter .getObject ();
20- auto docEndpoints = oatpp::swagger::Controller::Endpoints::createShared ();
21-
22- auto userController = UserController::createShared ();
23- userController->addEndpointsToRouter (router);
24-
25- docEndpoints->pushBackAll (userController->getEndpoints ());
26-
27- auto swaggerController = oatpp::swagger::Controller::createShared (docEndpoints);
28- swaggerController->addEndpointsToRouter (router);
17+ /* Get router component */
18+ OATPP_COMPONENT (std::shared_ptr<oatpp::web::server::HttpRouter>, router);
19+
20+ oatpp::web::server::api::Endpoints docEndpoints;
21+
22+ docEndpoints.append (router->addController (UserController::createShared ())->getEndpoints ());
2923
30- auto staticController = StaticController:: createShared ();
31- staticController-> addEndpointsToRouter (router );
24+ router-> addController ( oatpp::swagger::Controller:: createShared (docEndpoints) );
25+ router-> addController ( StaticController::createShared () );
3226
3327 /* Get connection handler component */
3428 OATPP_COMPONENT (std::shared_ptr<oatpp::network::ConnectionHandler>, connectionHandler);
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ oatpp::Object<UserDto> UserService::updateUser(const oatpp::Object<UserDto>& dto
2020
2121}
2222
23- oatpp::Object<UserDto> UserService::getUserById (const oatpp::Int32& id, const std::shared_ptr <oatpp::orm::Connection>& connection) {
23+ oatpp::Object<UserDto> UserService::getUserById (const oatpp::Int32& id, const oatpp::provider::ResourceHandle <oatpp::orm::Connection>& connection) {
2424
2525 auto dbResult = m_database->getUserById (id, connection);
2626 OATPP_ASSERT_HTTP (dbResult->isSuccess (), Status::CODE_500, dbResult->getErrorMessage ());
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class UserService {
1818
1919 oatpp::Object<UserDto> createUser (const oatpp::Object<UserDto>& dto);
2020 oatpp::Object<UserDto> updateUser (const oatpp::Object<UserDto>& dto);
21- oatpp::Object<UserDto> getUserById (const oatpp::Int32& id, const std::shared_ptr <oatpp::orm::Connection>& connection = nullptr );
21+ oatpp::Object<UserDto> getUserById (const oatpp::Int32& id, const oatpp::provider::ResourceHandle <oatpp::orm::Connection>& connection = nullptr );
2222 oatpp::Object<PageDto<oatpp::Object<UserDto>>> getAllUsers (const oatpp::UInt32& offset, const oatpp::UInt32& limit);
2323 oatpp::Object<StatusDto> deleteUserById (const oatpp::Int32& id);
2424
You can’t perform that action at this time.
0 commit comments