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.

showservicelogic.go 1.9 kB

2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package ai
  13. import (
  14. "context"
  15. "github.com/jinzhu/copier"
  16. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
  17. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  18. "gitlink.org.cn/JointCloud/pcm-modelarts/modelarts"
  19. "k8s.io/apimachinery/pkg/util/json"
  20. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  21. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  22. "github.com/zeromicro/go-zero/core/logx"
  23. )
  24. type ShowServiceLogic struct {
  25. logx.Logger
  26. ctx context.Context
  27. svcCtx *svc.ServiceContext
  28. }
  29. func NewShowServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowServiceLogic {
  30. return &ShowServiceLogic{
  31. Logger: logx.WithContext(ctx),
  32. ctx: ctx,
  33. svcCtx: svcCtx,
  34. }
  35. }
  36. func (l *ShowServiceLogic) ShowService(req *types.ShowServiceReq) (resp *types.ShowServiceResp, err error) {
  37. modelartsReq := &modelarts.ShowServiceReq{}
  38. err = copier.CopyWithOption(modelartsReq, req, copier.Option{Converters: utils.Converters})
  39. ShowServiceResp, err := l.svcCtx.ModelArtsRpc.ShowService(l.ctx, modelartsReq)
  40. if err != nil {
  41. return nil, result.NewDefaultError(err.Error())
  42. }
  43. marshal, err := json.Marshal(&ShowServiceResp)
  44. if err != nil {
  45. return nil, result.NewDefaultError(err.Error())
  46. }
  47. json.Unmarshal(marshal, &resp)
  48. err = copier.CopyWithOption(&resp, &ShowServiceResp, copier.Option{IgnoreEmpty: true, DeepCopy: true, Converters: utils.Converters})
  49. return resp, nil
  50. }

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.