You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

createservicelogic.go 1.5 kB

2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package ai
  2. import (
  3. "context"
  4. "github.com/jinzhu/copier"
  5. "gitlink.org.cn/jcce-pcm/pcm-participant-modelarts/modelarts"
  6. "gitlink.org.cn/jcce-pcm/utils/result"
  7. "gitlink.org.cn/jcce-pcm/utils/tool"
  8. "k8s.io/apimachinery/pkg/util/json"
  9. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  10. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type CreateServiceLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewCreateServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateServiceLogic {
  19. return &CreateServiceLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *CreateServiceLogic) CreateService(req *types.CreateServiceReq) (resp *types.CreateServiceResp, err error) {
  26. modelartsReq := &modelarts.CreateServiceReq{}
  27. err = copier.CopyWithOption(modelartsReq, req, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: tool.Converters})
  28. CreateServiceResp, err := l.svcCtx.ModelArtsRpc.CreateService(l.ctx, modelartsReq)
  29. if err != nil {
  30. return nil, result.NewDefaultError(err.Error())
  31. }
  32. marshal, err := json.Marshal(&CreateServiceResp)
  33. if err != nil {
  34. return nil, result.NewDefaultError(err.Error())
  35. }
  36. json.Unmarshal(marshal, &resp)
  37. err = copier.CopyWithOption(&resp, &CreateServiceResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: tool.Converters})
  38. return resp, nil
  39. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.