<%inc#include "create_model.h" using namespace drogon_ctl; %> /** * * [[fileName]]Base.h * DO NOT EDIT. This file is generated by drogon_ctl automatically. * Users should implement business logic in the derived class. */ #pragma once #include #include <%c++ auto tableInfo = @@.get("tableInfo"); auto modelName = tableInfo.get("className"); $$<<"#include \""<("hasPrimaryKey")==1); $$<<"using namespace drogon;\n"; $$<<"using namespace drogon_model::"<("dbName"); auto &schema=tableInfo.get("schema"); if(!schema.empty()) { $$<<"::"<>("namespaceVector"); for(auto &name:namespaceVector) { %> namespace {%name%} { <%c++}%> /** * @brief this class is created by the drogon_ctl command. * this class is a restful API controller for reading and writing the [[tableName]] table. */ class [[className]]Base : public RestfulController { public: <%c++if(hasPrimaryKey) { %> void getOne(const HttpRequestPtr &req, std::function &&callback, {%modelName%}::PrimaryKeyType &&id); void updateOne(const HttpRequestPtr &req, std::function &&callback, {%modelName%}::PrimaryKeyType &&id); void deleteOne(const HttpRequestPtr &req, std::function &&callback, {%modelName%}::PrimaryKeyType &&id); <%c++} %> void get(const HttpRequestPtr &req, std::function &&callback); void create(const HttpRequestPtr &req, std::function &&callback); // void update(const HttpRequestPtr &req, // std::function &&callback); orm::DbClientPtr getDbClient() { return drogon::app().get{%(@@.get("isFastDbClient")?"Fast":"")%}DbClient(dbClientName_); } protected: /// Ensure that subclasses inherited from this class are instantiated. [[className]]Base(); const std::string dbClientName_{"[[dbClientName]]"}; }; <%c++ for(size_t i=0;i