fix(region): filter eips by associated (#21065)

This commit is contained in:
屈轩
2024-08-21 10:50:51 +08:00
committed by GitHub
parent d1e91ac543
commit c6f9773eeb
3 changed files with 12 additions and 0 deletions
+3
View File
@@ -87,6 +87,9 @@ type ElasticipListInput struct {
// example: elastic_ip
Mode string `json:"mode"`
// 是否已关联资源
IsAssociated *bool `json:"is_associated"`
// IP地址
IpAddr []string `json:"ip_addr"`
+8
View File
@@ -261,6 +261,14 @@ func (manager *SElasticipManager) ListItemFilter(
q = q.Filter(sqlchemy.OR(sqlchemy.IsNull(q.Field("associate_id")), sqlchemy.IsEmpty(q.Field("associate_id"))))
}
if query.IsAssociated != nil {
if *query.IsAssociated {
q = q.IsNotEmpty("associate_type")
} else {
q = q.IsNullOrEmpty("associate_type")
}
}
if len(query.Mode) > 0 {
q = q.In("mode", query.Mode)
}
+1
View File
@@ -30,6 +30,7 @@ type ElasticipListOptions struct {
AssociateId []string
AssociateType []string
AssociateName []string
IsAssociated *bool
IpAddr []string
options.BaseListOptions