forked from JointCloud/pcm-ac
56 lines
1.3 KiB
Go
56 lines
1.3 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 GetInstanceLogLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetInstanceLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetInstanceLogLogic {
|
|
return &GetInstanceLogLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetInstanceLogLogic) GetInstanceLog(in *hpcAC.GetInstanceLogReq) (*hpcAC.GetInstanceLogResp, error) {
|
|
resp := &hpcAC.GetInstanceLogResp{}
|
|
var reqUrl = common.AiCenterUrlPrefix() + l.svcCtx.Config.AiConf.GetInstanceLog
|
|
|
|
token := common.GetToken()
|
|
if token == "" {
|
|
log.Println("获取token失败")
|
|
return nil, errors.New("获取token失败")
|
|
}
|
|
|
|
req := common.GetRestyRequest(3)
|
|
_, err := req.
|
|
SetHeader("token", token).
|
|
SetPathParam("instanceNum", in.InstanceNum).
|
|
SetPathParam("taskId", in.TaskId).
|
|
SetQueryParam("lineCount", strconv.FormatInt(in.LineCount, 10)).
|
|
SetQueryParam("startLineNum", strconv.FormatInt(in.StartLineNum, 10)).
|
|
SetResult(resp).
|
|
Get(reqUrl)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return resp, nil
|
|
}
|