pcm-ac/internal/logic/walltimelogic.go

42 lines
1.1 KiB
Go

package logic
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"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"
)
type WallTimeLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewWallTimeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WallTimeLogic {
return &WallTimeLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *WallTimeLogic) WallTime(in *hpcAC.WallTimeReq) (*hpcAC.WallTimeResp, error) {
getTokenLogic := NewGetACTokenLogic(l.ctx, l.svcCtx)
tokenResp, _ := getTokenLogic.GetACToken(&hpcAC.ACTokenReq{})
token := tokenResp.GetData().Token
url := common.HpcCenterUrlPrefix() + "/hpc/openapi/v2/view/walltime/users/" + in.Username
var wallTimeResp *hpcAC.WallTimeResp
acHttpRequest := httputils.GetHttpRequest()
acHttpRequest.
SetResult(&wallTimeResp).
SetHeader(httputils.ContentType, httputils.ApplicationJson).
SetHeader("token", token).
Get(url)
return wallTimeResp, nil
}