|
- package ai
-
- import (
- "context"
- "github.com/jinzhu/copier"
- "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"
-
- "github.com/zeromicro/go-zero/core/logx"
- )
-
- type CreateServiceLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic {
- return &CreateServiceLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *types.CreateServiceResp, err error) {
- modelartsReq := &modelarts.CreateServiceReq{}
- err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
- CreateServiceResp, err := l.svcCtx.ModelArtsRpc.CreateService(l.ctx, modelartsReq)
- if err != nil {
- return nil, result.NewDefaultError(err.Error())
- }
- marshal, err := json.Marshal(&CreateServiceResp)
- if err != nil {
- return nil, result.NewDefaultError(err.Error())
- }
- json.Unmarshal(marshal, &resp)
- err = copier.CopyWithOption(&resp, &CreateServiceResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
- return resp, nil
- }
|