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.

instancecenterlogic.go 2.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package inference
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  6. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type InstanceCenterLogic struct {
  10. logx.Logger
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. }
  14. func NewInstanceCenterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InstanceCenterLogic {
  15. return &InstanceCenterLogic{
  16. Logger: logx.WithContext(ctx),
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. }
  20. }
  21. func (l *InstanceCenterLogic) InstanceCenter(req *types.InstanceCenterReq) (*types.InstanceCenterResp, error) {
  22. // todo: add your logic here and delete this line
  23. var resp types.InstanceCenterResp
  24. var InstanceCenter *[]models.AiInstanceCenter
  25. var InstanceCenterLists []types.InstanceCenterList
  26. if req.InstanceType == 0 {
  27. l.svcCtx.DbEngin.Raw("select * from ai_instance_center").Scan(&InstanceCenter)
  28. } else if req.InstanceType != 0 && req.InstanceClass == "" {
  29. l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? ", req.InstanceType).Scan(&InstanceCenter)
  30. } else {
  31. l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? and instance_class = ?", req.InstanceType, req.InstanceClass).Scan(&InstanceCenter)
  32. }
  33. var instanceCenter = *InstanceCenter
  34. for _, instanceCenter := range instanceCenter {
  35. var instanceCenterlist types.InstanceCenterList
  36. instanceCenterlist.InstanceName = instanceCenter.InstanceName
  37. instanceCenterlist.InstanceType = instanceCenter.InstanceType
  38. instanceCenterlist.InstanceClass = instanceCenter.InstanceClass
  39. instanceCenterlist.Description = instanceCenter.Description
  40. instanceCenterlist.InstanceClassChinese = instanceCenter.InstanceClassChinese
  41. instanceCenterlist.Version = instanceCenter.Version
  42. instanceCenterlist.LogoPath = instanceCenter.LogoPath
  43. InstanceCenterLists = append(InstanceCenterLists, instanceCenterlist)
  44. }
  45. resp.Code = 200
  46. resp.Msg = "success"
  47. resp.InstanceCenterList = InstanceCenterLists
  48. resp.TotalCount = len(InstanceCenterLists)
  49. return &resp, nil
  50. }

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.