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.6 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. tx := l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_name like CONCAT(?, '%')", req.InstanceName).Scan(&InstanceCenter)
  28. if tx.Error == nil {
  29. logx.Error("find nil")
  30. }
  31. } else if req.InstanceType != 0 && req.InstanceClass == "" {
  32. tx := l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? and instance_name like CONCAT(?, '%')", req.InstanceType, req.InstanceName).Scan(&InstanceCenter)
  33. if tx.Error == nil {
  34. logx.Error("find nil")
  35. }
  36. } else {
  37. tx := l.svcCtx.DbEngin.Raw("select * from ai_instance_center where instance_type = ? and instance_class = ? and instance_name like CONCAT(?, '%')", req.InstanceType, req.InstanceClass, req.InstanceName).Scan(&InstanceCenter)
  38. if tx.Error == nil {
  39. logx.Error("find nil")
  40. }
  41. }
  42. if InstanceCenter == nil {
  43. resp.Code = 200
  44. resp.Msg = "No content found"
  45. } else {
  46. var instanceCenter = *InstanceCenter
  47. for _, instanceCenter := range instanceCenter {
  48. var instanceCenterlist types.InstanceCenterList
  49. instanceCenterlist.InstanceName = instanceCenter.InstanceName
  50. instanceCenterlist.InstanceType = instanceCenter.InstanceType
  51. instanceCenterlist.InstanceClass = instanceCenter.InstanceClass
  52. instanceCenterlist.Description = instanceCenter.Description
  53. instanceCenterlist.InstanceClassChinese = instanceCenter.InstanceClassChinese
  54. instanceCenterlist.Version = instanceCenter.Version
  55. instanceCenterlist.LogoPath = instanceCenter.LogoPath
  56. InstanceCenterLists = append(InstanceCenterLists, instanceCenterlist)
  57. }
  58. resp.Code = 200
  59. resp.Msg = "success"
  60. resp.InstanceCenterList = InstanceCenterLists
  61. resp.TotalCount = len(InstanceCenterLists)
  62. }
  63. return &resp, nil
  64. }

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.