Skip to content

Commit

Permalink
feat(dbm-services): 资源统计视图增加筛选启用规格 TencentBlueKing#8326
Browse files Browse the repository at this point in the history
  • Loading branch information
ymakedaq committed Dec 2, 2024
1 parent 3a857db commit e24ee29
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ type ResourDistributionParam struct {
City string `json:"city"`
SubZoneIds []string `json:"subzone_ids"`
GroupBy string `json:"group_by" binding:"required"`
SpecParam DbmSpecParam `json:"spec_param" `
SpecParam DbmSpecParam `json:"spec_param"`
// 筛选enable的规格
EnableSpec bool `json:"enable_spec"`
}

// DbmSpecParam 规格参数
Expand All @@ -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 {
Expand All @@ -107,6 +109,9 @@ func (m DbmSpecParam) getQueryParam() map[string]string {
}
p["spec_ids"] = strings.Join(specIdStrList, ",")
}
if enableSpec {
p["enable"] = "true"
}
return p
}

Expand All @@ -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")
Expand Down

0 comments on commit e24ee29

Please sign in to comment.