实现HTTP服务架构

This commit is contained in:
lixiaoyuan
2025-08-31 14:38:53 +08:00
parent 4af4e670d2
commit e0b64a20c4
46 changed files with 1436 additions and 545 deletions

58
src/protocol/HttpEntity.h Normal file
View File

@@ -0,0 +1,58 @@
#include "httplib.h"
#include "common/JsonN.h"
#include "errcode.h"
class HttpEntity
{
public:
httplib::Server httpsvr;
void listen(std::string addr, int port);
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 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);
};