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.

updateclusterlogic.go 1.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 UpdateClusterLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewUpdateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateClusterLogic {
  17. return &UpdateClusterLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) {
  24. cluster := &types.ClusterInfo{}
  25. result := l.svcCtx.DbEngin.Table("t_cluster").First(&cluster, req.Id)
  26. if errors.Is(result.Error, gorm.ErrRecordNotFound) {
  27. return nil, errors.New("cluster does not exist")
  28. }
  29. utils.Convert(req, &cluster)
  30. // 获取集群经纬度
  31. location, err := GeoMap(req.RegionName)
  32. if err != nil {
  33. return nil, err
  34. }
  35. cluster.Location = location
  36. l.svcCtx.DbEngin.Table("t_cluster").Model(&cluster).Updates(&cluster)
  37. return
  38. }

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.