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.

getclustersumlogic.go 1.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package adapters
  2. import (
  3. "context"
  4. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  5. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type GetClusterSumLogic struct {
  9. logx.Logger
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. }
  13. func NewGetClusterSumLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterSumLogic {
  14. return &GetClusterSumLogic{
  15. Logger: logx.WithContext(ctx),
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. func (l *GetClusterSumLogic) GetClusterSum(req *types.ClusterSumReq) (resp *types.ClusterSumReqResp, err error) {
  21. // todo: add your logic here and delete this line
  22. resp = &types.ClusterSumReqResp{}
  23. var AdapterSum int //
  24. var ClusterSum int //
  25. var TaskSum int //
  26. //
  27. sqlStr := "SELECT COUNT(*) FROM `t_adapter` t where t.type = 0`"
  28. tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&AdapterSum)
  29. if tx.Error != nil {
  30. logx.Error(err)
  31. return nil, tx.Error
  32. }
  33. //
  34. sqlStrCluster := "SELECT COUNT(*) FROM `t_cluster`t where t.label ='openstack' || t.label='kubernetes'\n"
  35. txCluster := l.svcCtx.DbEngin.Raw(sqlStrCluster).Scan(&ClusterSum)
  36. if txCluster.Error != nil {
  37. logx.Error(err)
  38. return nil, txCluster.Error
  39. }
  40. //
  41. sqlStrTask := "SELECT COUNT(*) FROM `task`"
  42. txTask := l.svcCtx.DbEngin.Raw(sqlStrTask).Scan(&TaskSum)
  43. if txTask.Error != nil {
  44. logx.Error(err)
  45. return nil, txTask.Error
  46. }
  47. resp.TaskSum = TaskSum
  48. resp.ClusterSum = ClusterSum
  49. resp.AdapterSum = AdapterSum
  50. return resp, nil
  51. }

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.