forked from JointCloud/pcm-coordinator
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils"
|
|
"k8s.io/apimachinery/pkg/util/json"
|
|
"strings"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type PerCenterComputerPowersLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewPerCenterComputerPowersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerCenterComputerPowersLogic {
|
|
return &PerCenterComputerPowersLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *PerCenterComputerPowersLogic) PerCenterComputerPowers() (resp *types.PerCenterComputerPowersResp, err error) {
|
|
resp = &types.PerCenterComputerPowersResp{}
|
|
statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/percenter", strings.NewReader(``))
|
|
|
|
if statusCode == 200 {
|
|
json.Unmarshal(body, &resp.Chart)
|
|
println(resp)
|
|
} else if statusCode != 200 {
|
|
return nil, err
|
|
}
|
|
return resp, nil
|
|
}
|