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.

clusterlistlogic.go 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package adapters
  2. import (
  3. "context"
  4. "fmt"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type ClusterListLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterListLogic {
  15. return &ClusterListLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.ClusterListResp, err error) {
  22. resp = &types.ClusterListResp{}
  23. sql := fmt.Sprintf(`select c.* from t_cluster c left join t_adapter a on c.adapter_id = a.id where c.deleted_at is null`)
  24. if req.AdapterId != "" {
  25. sql = fmt.Sprintf(`select * from t_cluster where adapter_id = %s and deleted_at is null `, req.AdapterId)
  26. }
  27. if req.Type != "" {
  28. sql = fmt.Sprintf(`select c.* from t_cluster c left join t_adapter a on c.adapter_id = a.id where c.deleted_at is null and a.type = %s`, req.Type)
  29. }
  30. tx := l.svcCtx.DbEngin.Raw(sql).Scan(&resp.List)
  31. if tx.Error != nil {
  32. logx.Errorf(tx.Error.Error())
  33. return nil, tx.Error
  34. }
  35. return resp, nil
  36. }

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.