mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #8319 from swordqiu/hotfix/qj-resolve-with-meta-filter-conflict
fix: resolve with_meta filter conflict
This commit is contained in:
+5
-2
@@ -199,12 +199,15 @@ type MetadataResourceListInput struct {
|
||||
// 返回资源的标签不包含用户标签
|
||||
WithoutUserMeta *bool `json:"without_user_meta"`
|
||||
|
||||
// 返回资源的标签包含用户标签
|
||||
// 返回包含用户标签的资源
|
||||
WithUserMeta *bool `json:"with_user_meta"`
|
||||
|
||||
// 返回资源的标签包含外部标签
|
||||
// 返回包含外部标签的资源
|
||||
WithCloudMeta *bool `json:"with_cloud_meta"`
|
||||
|
||||
// 返回包含任意标签的资源
|
||||
WithAnyMeta *bool `json:"with_any_meta"`
|
||||
|
||||
// 返回列表数据中包含资源的标签数据(Metadata)
|
||||
WithMeta *bool `json:"with_meta"`
|
||||
}
|
||||
|
||||
@@ -90,10 +90,10 @@ func (meta *SMetadataResourceBaseModelManager) ListItemFilter(
|
||||
}
|
||||
}
|
||||
|
||||
if input.WithMeta != nil {
|
||||
if input.WithAnyMeta != nil {
|
||||
metadatas := Metadata.Query().Equals("obj_type", manager.Keyword()).SubQuery()
|
||||
sq := metadatas.Query(metadatas.Field("obj_id")).Distinct().SubQuery()
|
||||
if *input.WithMeta {
|
||||
if *input.WithAnyMeta {
|
||||
q = q.Filter(sqlchemy.In(q.Field("id"), sq))
|
||||
} else {
|
||||
q = q.Filter(sqlchemy.NotIn(q.Field("id"), sq))
|
||||
|
||||
Reference in New Issue
Block a user