From ebc00c2bfaa7806a6e0b761606db369543e66fc5 Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 19 Oct 2022 17:12:41 +0800 Subject: [PATCH] update --- models/cloudbrain_static.go | 1 + routers/api/v1/repo/cloudbrain_dashboard.go | 31 +++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/models/cloudbrain_static.go b/models/cloudbrain_static.go index ea93015b3..a693e0555 100644 --- a/models/cloudbrain_static.go +++ b/models/cloudbrain_static.go @@ -45,6 +45,7 @@ type CardTypeAndNum struct { } type ResourceOverview struct { Cluster string `json:"cluster"` + AiCenterName string `json:"aiCenterName"` AiCenterCode string `json:"aiCenterCode"` CardTypeAndNum []CardTypeAndNum `json:"cardTypeAndNum"` } diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index 2e5e77078..517905c9b 100755 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -1426,11 +1426,11 @@ func GetCloudbrainResourceOverview(ctx *context.Context) { log.Info("GetCanUseCardInfo err: %v", err) return } - // ResourceAiCenterRes, err := models.GetResourceAiCenters() - // if err != nil { - // log.Error("Can not get ResourceAiCenterRes.", err) - // return - // } + ResourceAiCenterRes, err := models.GetResourceAiCenters() + if err != nil { + log.Error("Can not get ResourceAiCenterRes.", err) + return + } resourceOverviews := []models.ResourceOverview{} resourceOpenIOne := models.ResourceOverview{} resourceOpenITwo := models.ResourceOverview{} @@ -1439,8 +1439,9 @@ func GetCloudbrainResourceOverview(ctx *context.Context) { for _, resourceQueue := range resourceQueues { if resourceQueue.Cluster == models.OpenICluster { if resourceQueue.AiCenterCode == models.AICenterOfCloudBrainOne { - resourceOpenIOne.Cluster = models.OpenICluster - resourceOpenIOne.AiCenterCode = models.AICenterOfCloudBrainOne + resourceOpenIOne.Cluster = resourceQueue.Cluster + resourceOpenIOne.AiCenterCode = resourceQueue.AiCenterCode + resourceOpenIOne.AiCenterName = resourceQueue.AiCenterName cardTypeNum := models.CardTypeAndNum{} cardTypeNum.CardType = resourceQueue.AccCardType cardTypeNum.Num = resourceQueue.CardsTotalNum @@ -1448,8 +1449,9 @@ func GetCloudbrainResourceOverview(ctx *context.Context) { resourceOpenIOne.CardTypeAndNum = append(resourceOpenIOne.CardTypeAndNum, cardTypeNum) } if resourceQueue.AiCenterCode == models.AICenterOfCloudBrainTwo { - resourceOpenITwo.Cluster = models.OpenICluster - resourceOpenITwo.AiCenterCode = models.AICenterOfCloudBrainTwo + resourceOpenITwo.Cluster = resourceQueue.Cluster + resourceOpenITwo.AiCenterCode = resourceQueue.AiCenterCode + resourceOpenITwo.AiCenterName = resourceQueue.AiCenterName cardTypeNum := models.CardTypeAndNum{} cardTypeNum.CardType = resourceQueue.AccCardType cardTypeNum.Num = resourceQueue.CardsTotalNum @@ -1470,6 +1472,17 @@ func GetCloudbrainResourceOverview(ctx *context.Context) { resourceOverviews = append(resourceOverviews, resourceOpenIOne) resourceOverviews = append(resourceOverviews, resourceOpenITwo) // resourceOverviews = append(resourceOverviews, resourceChengdu) + for _, resourceAiCenterRes := range ResourceAiCenterRes { + if resourceAiCenterRes.AiCenterCode != models.AICenterOfCloudBrainOne { + if resourceAiCenterRes.AiCenterCode != models.AICenterOfCloudBrainTwo { + test := models.ResourceOverview{} + test.Cluster = models.C2NetCluster + test.AiCenterCode = resourceAiCenterRes.AiCenterCode + test.AiCenterName = resourceAiCenterRes.AiCenterName + resourceOverviews = append(resourceOverviews, test) + } + } + } ctx.JSON(http.StatusOK, map[string]interface{}{ "resourceOverviews": resourceOverviews,