123 lines
2.9 KiB
Go
123 lines
2.9 KiB
Go
package system
|
|
|
|
import (
|
|
"ai4m/global"
|
|
"ai4m/model/common/response"
|
|
"ai4m/model/other"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type ScreenApi struct{}
|
|
|
|
func (s *ScreenApi) ComputingPowerTrend(c *gin.Context) {
|
|
var result other.Screen
|
|
resp, err := global.HTTP_CLIENT.R().
|
|
SetResult(&result).
|
|
ForceContentType("application/json").
|
|
Get("https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/dailytrend")
|
|
if resp.IsError() {
|
|
response.FailWithMessage(resp.Status(), c)
|
|
return
|
|
}
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(result, c)
|
|
}
|
|
|
|
func (s *ScreenApi) ComputingPowerCondition(c *gin.Context) {
|
|
var result other.Screen
|
|
resp, err := global.HTTP_CLIENT.R().
|
|
SetResult(&result).
|
|
ForceContentType("application/json").
|
|
Get("https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/percenter")
|
|
if resp.IsError() {
|
|
response.FailWithMessage(resp.Status(), c)
|
|
return
|
|
}
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(result, c)
|
|
}
|
|
|
|
func (s *ScreenApi) Jobs(c *gin.Context) {
|
|
var result other.Screen
|
|
resp, err := global.HTTP_CLIENT.R().
|
|
SetResult(&result).
|
|
ForceContentType("application/json").
|
|
Get("https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/alljobinfo")
|
|
if resp.IsError() {
|
|
response.FailWithMessage(resp.Status(), c)
|
|
return
|
|
}
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(result, c)
|
|
}
|
|
|
|
func (s *ScreenApi) ScreenAiTask(c *gin.Context) {
|
|
aiTasks, err := aiService.ScreenAi()
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(aiTasks, c)
|
|
}
|
|
|
|
func (s *ScreenApi) ScreenInfo(c *gin.Context) {
|
|
aiTasks, err := aiService.ScreenAi()
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(aiTasks, c)
|
|
}
|
|
func (s *ScreenApi) ScreenAiCenter(c *gin.Context) {
|
|
var result other.Screen
|
|
resp, err := global.HTTP_CLIENT.R().
|
|
SetResult(&result).
|
|
ForceContentType("application/json").
|
|
Get("https://grampus.openi.org.cn/openapi/v1/sharescreen/aicenter?sortBy=weight&orderBy=asc")
|
|
if resp.IsError() {
|
|
response.FailWithMessage(resp.Status(), c)
|
|
return
|
|
}
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(result, c)
|
|
}
|
|
|
|
func (s *ScreenApi) ScreenStorage(c *gin.Context) {
|
|
storage, err := screenService.ScreenStorage()
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(storage, c)
|
|
}
|
|
|
|
func (s *ScreenApi) ScreenClusterResource(c *gin.Context) {
|
|
clustersResource, err := clusterService.ScreenClusterResource()
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(clustersResource, c)
|
|
}
|
|
|
|
func (s *ScreenApi) PieChart(c *gin.Context) {
|
|
pieCharts, err := aiService.ScreenPieChart()
|
|
if err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
response.OkWithData(pieCharts, c)
|
|
}
|