42 lines
986 B
Go
42 lines
986 B
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/svc"
|
|
)
|
|
|
|
type GetImageAiByIdLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetImageAiByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetImageAiByIdLogic {
|
|
return &GetImageAiByIdLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetImageAiByIdLogic) GetImageAiById(in *hpcAC.GetImageAiByIdReq) (*hpcAC.GetImageAiByIdResp, error) {
|
|
resp := &hpcAC.GetImageAiByIdResp{}
|
|
|
|
getImageListLogic := NewGetImageListAiLogic(l.ctx, l.svcCtx)
|
|
imageListResp, err := getImageListLogic.GetImageListAi(&hpcAC.GetImageListAiReq{AcceleratorType: DCU, TaskType: PYTORCH})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, image := range imageListResp.Data {
|
|
if image.ImageId == in.ImageId {
|
|
resp.Image = image
|
|
break
|
|
}
|
|
}
|
|
|
|
return resp, nil
|
|
}
|