60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/internal/common"
|
|
"log"
|
|
"strconv"
|
|
|
|
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
|
|
"gitlink.org.cn/JointCloud/pcm-ac/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetInstanceListAiLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetInstanceListAiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetInstanceListAiLogic {
|
|
return &GetInstanceListAiLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetInstanceListAiLogic) GetInstanceListAi(in *hpcAC.GetInstanceListReq) (*hpcAC.GetInstanceListResp, error) {
|
|
resp := &hpcAC.GetInstanceListResp{}
|
|
var reqUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.ContainerConf.GetInstanceAi + "/task"
|
|
|
|
token := common.GetToken()
|
|
if token == "" {
|
|
log.Println("获取token失败")
|
|
return nil, errors.New("获取token失败")
|
|
}
|
|
|
|
req := common.GetRestyRequest(3)
|
|
_, err := req.
|
|
SetHeader("token", token).
|
|
SetQueryString("start" + EQUAL + strconv.Itoa(int(in.Start))).
|
|
SetQueryString("limit" + EQUAL + strconv.Itoa(int(in.Limit))).
|
|
SetQueryString("sort" + EQUAL + in.Sort).
|
|
SetQueryString("instanceServiceName" + EQUAL + in.InstanceServiceName).
|
|
SetQueryString("taskType" + EQUAL + in.TaskType).
|
|
SetQueryString("status" + EQUAL + in.Status).
|
|
SetQueryString("userName" + EQUAL + in.UserName).
|
|
SetQueryString("taskClassification" + EQUAL + in.TaskClassification).
|
|
SetResult(resp).
|
|
Get(reqUrl)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return resp, nil
|
|
}
|