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.

updateadapterlogic.go 1.0 kB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package adapters
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
  6. "gorm.io/gorm"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  8. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type UpdateAdapterLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewUpdateAdapterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAdapterLogic {
  17. return &UpdateAdapterLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *UpdateAdapterLogic) UpdateAdapter(req *types.AdapterReq) (resp *types.AdapterResp, err error) {
  24. adapter := &types.AdapterInfo{}
  25. result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.Id)
  26. if errors.Is(result.Error, gorm.ErrRecordNotFound) {
  27. return nil, errors.New("adapter does not exist")
  28. }
  29. utils.Convert(req, &adapter)
  30. l.svcCtx.DbEngin.Table("t_adapter").Model(&adapter).Updates(&adapter)
  31. return
  32. }

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.