mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): support eip search (#20683)
This commit is contained in:
@@ -91,10 +91,13 @@ type ElasticipListInput struct {
|
||||
IpAddr []string `json:"ip_addr"`
|
||||
|
||||
// 绑定资源类型
|
||||
AssociateType string `json:"associate_type"`
|
||||
AssociateType []string `json:"associate_type"`
|
||||
|
||||
// 绑定资源名称,模糊查询
|
||||
AssociateName []string `json:"associate_name"`
|
||||
|
||||
// 绑定资源Id
|
||||
AssociateId string `json:"associate_id"`
|
||||
AssociateId []string `json:"associate_id"`
|
||||
|
||||
// 计费类型: 流量、带宽
|
||||
// example: bandwidth
|
||||
|
||||
@@ -286,6 +286,27 @@ func (manager *SElasticipManager) ListItemFilter(
|
||||
q = q.IsFalse("auto_dellocate")
|
||||
}
|
||||
}
|
||||
if len(query.AssociateName) > 0 {
|
||||
filters := []sqlchemy.ICondition{}
|
||||
likeQuery := func(sq *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
conditions := []sqlchemy.ICondition{}
|
||||
for _, name := range query.AssociateName {
|
||||
conditions = append(conditions, sqlchemy.Contains(sq.Field("name"), name))
|
||||
}
|
||||
return sq.Filter(sqlchemy.OR(conditions...))
|
||||
}
|
||||
for _, m := range []db.IModelManager{
|
||||
GuestManager,
|
||||
GroupManager,
|
||||
LoadbalancerManager,
|
||||
NatGatewayManager,
|
||||
} {
|
||||
sq := m.Query("id")
|
||||
sq = likeQuery(sq)
|
||||
filters = append(filters, sqlchemy.In(q.Field("associate_id"), sq))
|
||||
}
|
||||
q = q.Filter(sqlchemy.OR(filters...))
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ type ElasticipListOptions struct {
|
||||
UsableEipForAssociateType string `help:"With associate id filter which eip can associate" choices:"server|natgateway|loadbalancer"`
|
||||
UsableEipForAssociateId string `help:"With associate type filter which eip can associate"`
|
||||
OrderByIp string
|
||||
AssociateId []string
|
||||
AssociateType []string
|
||||
AssociateName []string
|
||||
|
||||
IpAddr []string
|
||||
options.BaseListOptions
|
||||
|
||||
Reference in New Issue
Block a user