42 lines
1.2 KiB
Go
42 lines
1.2 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 QueueJobsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewQueueJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueueJobsLogic {
|
|
return &QueueJobsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
// QueueJobs
|
|
func (l *QueueJobsLogic) QueueJobs(in *hpcAC.QueueJobsReq) (*hpcAC.QueueJobsResp, error) {
|
|
|
|
getTokenLogic := NewGetACTokenLogic(l.ctx, l.svcCtx)
|
|
tokenResp, _ := getTokenLogic.GetACToken(&hpcAC.ACTokenReq{})
|
|
token := tokenResp.GetData().Token
|
|
|
|
url := common.HpcCenterUrlPrefix() + "/hpc/openapi/v2/view/queue/jobs?userName=" + in.UserName
|
|
var queueJobsResp *hpcAC.QueueJobsResp
|
|
acHttpRequest := httputils.GetHttpRequest()
|
|
acHttpRequest.SetHeader(httputils.ContentType, httputils.ApplicationJson).
|
|
SetResult(&queueJobsResp).
|
|
SetHeader("token", token).
|
|
Get(url)
|
|
return queueJobsResp, nil
|
|
}
|