From 5724557c7e5ada57bf74ede9e6fd05ab0b8aba14 Mon Sep 17 00:00:00 2001 From: yuanruji Date: Mon, 9 Dec 2024 11:11:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(dbm-services):=20=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=B1=A0=E8=81=9A=E5=90=88=E8=A7=86=E5=9B=BE=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E7=A6=81=E7=94=A8=E8=A7=84=E6=A0=BC=20#8485?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/controller/statistic/statistic.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dbm-services/common/db-resource/internal/controller/statistic/statistic.go b/dbm-services/common/db-resource/internal/controller/statistic/statistic.go index 39a90a8a11..27f04d7d9c 100644 --- a/dbm-services/common/db-resource/internal/controller/statistic/statistic.go +++ b/dbm-services/common/db-resource/internal/controller/statistic/statistic.go @@ -77,6 +77,8 @@ type ResourDistributionParam struct { SubZoneIds []string `json:"subzone_ids"` GroupBy string `json:"group_by" binding:"required"` SpecParam DbmSpecParam `json:"spec_param" ` + // 筛选enable的规格 + EnableSpec bool `json:"enable_spec"` } // DbmSpecParam 规格参数 @@ -87,7 +89,7 @@ type DbmSpecParam struct { SpecIdList []int `json:"spec_id_list"` } -func (m DbmSpecParam) getQueryParam() map[string]string { +func (m DbmSpecParam) getQueryParam(enableSpec bool) map[string]string { p := make(map[string]string) if m.DbType != nil { if *m.DbType != model.PUBLIC_RESOURCE_DBTYEP { @@ -107,6 +109,9 @@ func (m DbmSpecParam) getQueryParam() map[string]string { } p["spec_ids"] = strings.Join(specIdStrList, ",") } + if enableSpec { + p["enable"] = "true" + } return p } @@ -120,7 +125,7 @@ func (s *Handler) ResourceDistribution(c *gin.Context) { } dbmClient := dbmapi.NewDbmClient() - specList, err := dbmClient.GetDbmSpec(param.SpecParam.getQueryParam()) + specList, err := dbmClient.GetDbmSpec(param.SpecParam.getQueryParam(param.EnableSpec)) if err != nil { logger.Error("get dbm spec failed: %v", err) s.SendResponse(c, err, "Failed to get DBM specifications")