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.

listinstancecenterlogic.go 1.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package hpc
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  8. )
  9. type ListInstanceCenterLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewListInstanceCenterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListInstanceCenterLogic {
  15. return &ListInstanceCenterLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *ListInstanceCenterLogic) ListInstanceCenter(req *types.HpcInstanceCenterReq) (resp *types.PageResult, err error) {
  22. limit := req.PageSize
  23. offset := req.PageSize * (req.PageNum - 1)
  24. resp = &types.PageResult{}
  25. var list *[]models.HpcInstanceCenter
  26. db := l.svcCtx.DbEngin.Model(&models.HpcInstanceCenter{}).Table("hpc_instance_center")
  27. if req.InstanceName != "" {
  28. db = db.Where("instance_name like ?", "%"+req.InstanceName+"%")
  29. }
  30. if req.InstanceType != 0 {
  31. db = db.Where("instance_type = ?", req.InstanceType)
  32. }
  33. if req.InstanceClass != "" {
  34. db = db.Where("instance_class = ?", req.InstanceClass)
  35. }
  36. var total int64
  37. err = db.Count(&total).Error
  38. if err != nil {
  39. return resp, err
  40. }
  41. db = db.Where("deleted_at is null").Limit(limit).Offset(offset)
  42. err = db.Order("created_at desc").Find(&list).Error
  43. if err != nil {
  44. return nil, err
  45. }
  46. resp.List = list
  47. resp.PageSize = req.PageSize
  48. resp.PageNum = req.PageNum
  49. resp.Total = total
  50. return
  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.