2025-09-05 19:44:26 +08:00
|
|
|
|
#include "httplib.h"
|
2025-08-31 14:38:53 +08:00
|
|
|
|
#include "common/JsonN.h"
|
|
|
|
|
|
#include "errcode.h"
|
2025-09-05 19:44:26 +08:00
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
|
|
class HttpEntity;
|
2025-09-06 15:23:07 +08:00
|
|
|
|
using HandlerFunc = Errcode(HttpEntity::*)(const httplib::Request& req, njson& jnode, std::string& errmsg);
|
2025-09-05 19:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
struct HandlerOptions
|
|
|
|
|
|
{
|
|
|
|
|
|
HandlerFunc func;
|
|
|
|
|
|
std::vector<std::string> requiredKeys;
|
|
|
|
|
|
std::vector<std::string> keys;
|
|
|
|
|
|
|
|
|
|
|
|
HandlerOptions(HandlerFunc func, const std::vector<std::string>& requiredKeys)
|
|
|
|
|
|
: func(func), requiredKeys(requiredKeys)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
|
|
|
|
|
class HttpEntity
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
httplib::Server httpsvr;
|
2025-09-01 20:08:40 +08:00
|
|
|
|
HttpEntity();
|
2025-08-31 14:38:53 +08:00
|
|
|
|
void listen(std::string addr, int port);
|
2025-09-05 19:44:26 +08:00
|
|
|
|
void runHandler(std::string name, const HandlerOptions& handler, const httplib::Request& req, httplib::Response& resp);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
void registGet(std::string name, void (HttpEntity::* func)(const httplib::Request& req, httplib::Response& resp));
|
|
|
|
|
|
|
|
|
|
|
|
//void onGet(const httplib::Request& req, httplib::Response& resp);
|
|
|
|
|
|
|
2025-09-19 18:54:36 +08:00
|
|
|
|
Errcode logqueryBaseinfoin(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode login(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
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);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
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);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode queryRoleList(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-12 18:44:34 +08:00
|
|
|
|
Errcode queryRolePermission(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-06 15:23:07 +08:00
|
|
|
|
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);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
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);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
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);
|
2025-09-04 19:31:04 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
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);
|
2025-09-09 19:26:05 +08:00
|
|
|
|
Errcode queryDeviceBCUDetail(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
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);
|
2025-09-19 18:54:36 +08:00
|
|
|
|
Errcode queryPolicyByType(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode querySystemLogList(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
//Errcode insertSystemLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json);
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode updateSystemLog(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode queryAlertLogList(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
//Errcode insertAlertLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json);
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode updateAlertLog(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode queryPredictionDetail(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-01 20:08:40 +08:00
|
|
|
|
|
2025-09-12 18:44:34 +08:00
|
|
|
|
// 系统总览所有场站统计 (总览页 运行状况)
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-16 19:38:46 +08:00
|
|
|
|
Errcode queryStatStationGroup(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-12 18:44:34 +08:00
|
|
|
|
|
2025-09-10 20:10:51 +08:00
|
|
|
|
// 一个场站的累计统计
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-10 20:10:51 +08:00
|
|
|
|
// 场站按类别按天统计
|
2025-09-06 15:23:07 +08:00
|
|
|
|
Errcode queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-04 19:31:04 +08:00
|
|
|
|
|
2025-09-16 19:38:46 +08:00
|
|
|
|
//Errcode queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg);
|
|
|
|
|
|
|
|
|
|
|
|
Errcode queryStatDetailList(const httplib::Request& req, njson& json, std::string& errmsg);
|
|
|
|
|
|
|
2025-09-10 20:10:51 +08:00
|
|
|
|
// 场站按类某一天的历史曲线数据
|
|
|
|
|
|
Errcode queryStatCharts(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-08 19:34:12 +08:00
|
|
|
|
|
2025-09-10 20:10:51 +08:00
|
|
|
|
Errcode queryEnvironment(const httplib::Request& req, njson& json, std::string& errmsg);
|
2025-09-08 19:34:12 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
2025-08-31 14:38:53 +08:00
|
|
|
|
};
|