37 lines
702 B
Go
37 lines
702 B
Go
package services
|
|
|
|
import (
|
|
"cmii-uav-watchdog-common/models"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// CMIIService CMII服务
|
|
type CMIIService struct {
|
|
authService *AuthService
|
|
}
|
|
|
|
// NewCMIIService 创建CMII服务
|
|
func NewCMIIService() *CMIIService {
|
|
return &CMIIService{
|
|
authService: NewAuthService(),
|
|
}
|
|
}
|
|
|
|
// HandleHostInfo 处理主机信息
|
|
func (cs *CMIIService) HandleHostInfo(c *gin.Context) {
|
|
|
|
// 获取主机信息
|
|
hostInfo := cs.authService.GetAllHostInfo()
|
|
|
|
// 返回单纯的主机信息
|
|
hostInfoList := make([]models.HostInfo, 0)
|
|
for _, host := range hostInfo {
|
|
hostInfoList = append(hostInfoList, host)
|
|
}
|
|
|
|
// 返回主机信息
|
|
c.JSON(http.StatusOK, hostInfoList)
|
|
}
|