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.

deployinstancelistlogic.go 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package inference
  2. import (
  3. "context"
  4. "errors"
  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. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  9. )
  10. type DeployInstanceListLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewDeployInstanceListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeployInstanceListLogic {
  16. return &DeployInstanceListLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *DeployInstanceListLogic) DeployInstanceList(req *types.DeployInstanceListReq) (resp *types.DeployInstanceListResp, err error) {
  23. limit := req.PageSize
  24. offset := req.PageSize * (req.PageNum - 1)
  25. resp = &types.DeployInstanceListResp{}
  26. var list []*models.AiInferDeployInstance
  27. tx := l.svcCtx.DbEngin.Raw("select * from ai_infer_deploy_instance").Scan(&list)
  28. if tx.Error != nil {
  29. logx.Errorf(tx.Error.Error())
  30. return nil, tx.Error
  31. }
  32. //count total
  33. var total int64
  34. err = tx.Count(&total).Error
  35. tx.Limit(limit).Offset(offset)
  36. if err != nil {
  37. return resp, err
  38. }
  39. err = tx.Order("create_time desc").Find(&list).Error
  40. if err != nil {
  41. return nil, errors.New(err.Error())
  42. }
  43. resp.List = &list
  44. resp.PageSize = req.PageSize
  45. resp.PageNum = req.PageNum
  46. resp.Total = total
  47. return
  48. }

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.