#include "httplib.h" #include "common/JsonN.h" #include "errcode.h" #include class HttpEntity; using HandlerFunc = Errcode(HttpEntity::*)(const httplib::Request& req, njson& jnode, std::string& errmsg); 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, njson& json, std::string& errmsg); Errcode queryUserList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertUser(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updateUser(const httplib::Request& req, njson& json, std::string& errmsg); Errcode deleteUser(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryPermissionList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertPermission(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updatePermission(const httplib::Request& req, njson& json, std::string& errmsg); Errcode deletePermission(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryRoleList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryRolePermission(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertRole(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updateRole(const httplib::Request& req, njson& json, std::string& errmsg); Errcode deleteRole(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryStationList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertStation(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updateStation(const httplib::Request& req, njson& json, std::string& errmsg); Errcode deleteStation(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryStationOverview(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryStationInfo(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryStationData(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryDeviceList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertDevice(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updateDevice(const httplib::Request& req, njson& json, std::string& errmsg); Errcode deleteDevice(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryDevicTypeDef(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryDevicByCategory(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryDevicCharts(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryDeviceBCUDetail(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryPolicyList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertPolicy(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updatePolicy(const httplib::Request& req, njson& json, std::string& errmsg); Errcode deletePolicy(const httplib::Request& req, njson& json, std::string& errmsg); Errcode querySystemLogList(const httplib::Request& req, njson& json, std::string& errmsg); //Errcode insertSystemLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateSystemLog(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryAlertLogList(const httplib::Request& req, njson& json, std::string& errmsg); //Errcode insertAlertLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json); Errcode updateAlertLog(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryPredictionDetail(const httplib::Request& req, njson& json, std::string& errmsg); // 系统总览所有场站统计 (总览页 运行状况) Errcode queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryStatStation(const httplib::Request& req, njson& json, std::string& errmsg); // 一个场站的累计统计 Errcode queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg); // 场站按类别按天统计 Errcode queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg); // 场站按类某一天的历史曲线数据 Errcode queryStatCharts(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryEnvironment(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryServiceApiList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertServiceApi(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updateServiceApi(const httplib::Request& req, njson& json, std::string& errmsg); Errcode deleteServiceApi(const httplib::Request& req, njson& json, std::string& errmsg); };