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 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package adapters
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  6. "github.com/zeromicro/go-zero/core/logx"
  7. )
  8. type ClusterListLogic struct {
  9. logx.Logger
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. }
  13. func NewClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClusterListLogic {
  14. return &ClusterListLogic{
  15. Logger: logx.WithContext(ctx),
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. }
  19. }
  20. func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.PageResult, err error) {
  21. limit := req.PageSize
  22. offset := req.PageSize * (req.PageNum - 1)
  23. resp = &types.PageResult{}
  24. var list []types.ClusterInfo
  25. db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_cluster")
  26. db = db.Joins("left join t_adapter on t_adapter.id = t_cluster.adapter_id").
  27. Where("t_cluster.deleted_at is null")
  28. if req.Name != "" {
  29. db = db.Where("t_cluster.name LIKE ?", "%"+req.Name+"%")
  30. }
  31. if req.AdapterId != "" {
  32. db = db.Where("t_cluster.adapter_id = ?", req.AdapterId)
  33. }
  34. if req.Nickname != "" {
  35. db = db.Where("t_cluster.nickname LIKE ?", "%"+req.Nickname+"%")
  36. }
  37. if req.Label != "" {
  38. db = db.Where("t_cluster.label = ?", req.Label)
  39. }
  40. if req.Version != "" {
  41. db = db.Where("t_cluster.version = ?", req.Version)
  42. }
  43. if req.ProducerDict != "" {
  44. db = db.Where("t_cluster.producer_dict = ?", req.ProducerDict)
  45. }
  46. if req.RegionDict != "" {
  47. db = db.Where("t_cluster.region_dict = ?", req.RegionDict)
  48. }
  49. if req.Type != "" {
  50. db = db.Where("t_adapter.type = ?", req.Type)
  51. }
  52. //count total
  53. var total int64
  54. err = db.Select("*").Count(&total).Error
  55. if err != nil {
  56. return resp, err
  57. }
  58. db = db.Limit(limit).Offset(offset)
  59. err = db.Select("t_cluster.*").Order("t_cluster.create_time desc").Scan(&list).Error
  60. if err != nil {
  61. return resp, err
  62. }
  63. resp.List = list
  64. resp.PageSize = req.PageSize
  65. resp.PageNum = req.PageNum
  66. resp.Total = total
  67. return resp, nil
  68. }

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.