package ai import ( "context" "github.com/jinzhu/copier" "github.com/zeromicro/go-zero/core/logx" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc" "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types" "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils" "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts" "gitlink.org.cn/jcce-pcm/utils/result" "k8s.io/apimachinery/pkg/util/json" ) type CreateAlgorithmLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewCreateAlgorithmLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateAlgorithmLogic { return &CreateAlgorithmLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *CreateAlgorithmLogic) CreateAlgorithm(req *types.CreateAlgorithmReq) (resp *types.CreateAlgorithmResp, err error) { modelartsReq := &modelarts.CreateAlgorithmReq{} err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) ListAlgorithmsResp, err := l.svcCtx.ModelArtsRpc.CreateAlgorithm(l.ctx, modelartsReq) if err != nil { return nil, result.NewDefaultError(err.Error()) } marshal, err := json.Marshal(&ListAlgorithmsResp) if err != nil { return nil, result.NewDefaultError(err.Error()) } json.Unmarshal(marshal, &resp) err = copier.CopyWithOption(&resp, &ListAlgorithmsResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters}) return resp, nil }