#include "httplib.h" #include "common/JsonN.h" #include "errcode.h" #include class HttpEntity; using HandlerFunc = Errcode(HttpEntity::*)(const httplib::Request& req, httplib::Response& resp, NJsonNode& jnode); struct HandlerOptions { HandlerFunc func; std::vector requiredKeys; std::vector keys; HandlerOptions(HandlerFunc func, const std::vector& requiredKeys) : func(func), requiredKeys(requiredKeys) { } }; class HttpEntity { public: httplib::Server httpsvr; HttpEntity(); void listen(std::string addr, int port); void runHandler(std::string name, const HandlerOptions& handler, const httplib::Request& req, httplib::Response& resp); void registGet(std::string name, void (HttpEntity::* func)(const httplib::Request& req, httplib::Response& resp)); //void onGet(const httplib::Request& req, httplib::Response& resp); Errcode login(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryUserList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode insertUser(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateUser(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode deleteUser(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryPermissionList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode insertPermission(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updatePermission(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode deletePermission(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryRoleList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode insertRole(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateRole(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode deleteRole(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryStationList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode insertStation(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateStation(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode deleteStation(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryStationInfo(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryStationData(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryDeviceList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode insertDevice(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateDevice(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode deleteDevice(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryDevicTypeDef(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryPolicyList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode insertPolicy(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updatePolicy(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode deletePolicy(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode querySystemLogList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); //Errcode insertSystemLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateSystemLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryAlertLogList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); //Errcode insertAlertLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateAlertLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryPredictionDetail(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryStatSystem(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryStatTotal(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryStatStation(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryStatDayList(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode queryEnvironment(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); };