pcm-octopus/internal/logic/getnotebooklistlogic.go

55 lines
1.3 KiB
Go

package logic
import (
"context"
"errors"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-octopus/internal/common"
"gitlink.org.cn/JointCloud/pcm-octopus/internal/svc"
"gitlink.org.cn/JointCloud/pcm-octopus/octopus"
"log"
"strconv"
)
type GetNotebookListLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetNotebookListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNotebookListLogic {
return &GetNotebookListLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ModelDeployService
func (l *GetNotebookListLogic) GetNotebookList(in *octopus.GetNotebookListReq) (*octopus.GetNotebookListResp, error) {
resp := &octopus.GetNotebookListResp{}
var url_prefix = common.OctopusUrls[in.Platform]
var reqUrl = url_prefix + l.svcCtx.Config.OctopusApi.GetNotebookList
token := common.GetToken(in.Platform)
if token == "" {
log.Println("获取token失败, platform : ", in.Platform)
return nil, errors.New("获取token失败")
}
req := common.GetRestyRequest()
_, err := req.
SetHeader("Authorization", "Bearer "+token).
SetQueryString("pageIndex=" + strconv.Itoa(int(in.PageIndex))).
SetQueryString("pageSize=" + strconv.Itoa(int(in.PageSize))).
SetResult(resp).
Get(reqUrl)
if err != nil {
return nil, err
}
return resp, nil
}