版本封存

This commit is contained in:
zeaslity
2025-12-06 11:26:05 +08:00
parent 13949e1ba8
commit c0ae5e30c4
57 changed files with 2443 additions and 1428 deletions

View File

@@ -2,10 +2,10 @@ package controllers
import (
models2 "cmii-uav-watchdog-common/models"
"cmii-uav-watchdog/models"
"cmii-uav-watchdog-common/wdd_log"
"cmii-uav-watchdog/services"
"net/http"
"github.com/gin-gonic/gin"
)
@@ -25,28 +25,36 @@ func NewHeartbeatController() *HeartbeatController {
func (hc *HeartbeatController) HandleHeartbeat(c *gin.Context) {
var req models2.HeartbeatRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, models.Response{
Code: 400,
Message: "无效的请求参数",
Data: nil,
})
c.JSON(http.StatusBadRequest, req)
return
}
// 处理心跳
resp, err := hc.heartbeatService.ProcessHeartbeat(req)
if err != nil {
c.JSON(http.StatusInternalServerError, models.Response{
Code: 500,
Message: "处理心跳失败: " + err.Error(),
Data: nil,
c.JSON(http.StatusInternalServerError, resp)
return
}
c.JSON(http.StatusOK, resp)
}
// GetAllHeartbeatHosts 获取所有心跳主机信息
func (hc *HeartbeatController) GetAllHeartbeatHosts(c *gin.Context) {
// 获取所有主机信息
hostInfoMap, err := hc.heartbeatService.GetAllHostInfo()
if err != nil {
wdd_log.Error("获取所有心跳主机信息失败: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{
"error": "获取所有心跳主机信息失败",
"message": err.Error(),
})
return
}
c.JSON(http.StatusOK, models.Response{
Code: 200,
Message: "处理心跳成功",
Data: resp,
// 返回主机信息
c.JSON(http.StatusOK, gin.H{
"host_count": len(hostInfoMap),
"hosts": hostInfoMap,
})
}