pcm-ac/internal/logic/cpucorelogic.go

42 lines
1.1 KiB
Go

package logic
import (
"context"
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
"gitlink.org.cn/JointCloud/pcm-ac/internal/common"
"gitlink.org.cn/JointCloud/pcm-ac/internal/pkg/utils/httputils"
"gitlink.org.cn/JointCloud/pcm-ac/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type CpuCoreLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewCpuCoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CpuCoreLogic {
return &CpuCoreLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *CpuCoreLogic) CpuCore(in *hpcAC.CpuCoreReq) (*hpcAC.CpuCoreResp, error) {
getTokenLogic := NewGetACTokenLogic(l.ctx, l.svcCtx)
tokenResp, _ := getTokenLogic.GetACToken(&hpcAC.ACTokenReq{})
token := tokenResp.GetData().Token
url := common.HpcCenterUrlPrefix() + "/hpc/openapi/v2/view/cpucore/state"
var cpuCoreResp *hpcAC.CpuCoreResp
acHttpRequest := httputils.GetHttpRequest()
acHttpRequest.SetHeader(httputils.ContentType, httputils.ApplicationJson).
SetResult(&cpuCoreResp).
SetHeader("token", token).
Get(url)
return cpuCoreResp, nil
}