mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(keystone): support filter project by multi admin user (#19539)
This commit is contained in:
@@ -166,7 +166,7 @@ type ProjectListInput struct {
|
||||
PolicyProjectTags tagutils.TTagSetList `json:"policy_project_tags"`
|
||||
|
||||
// 通过项目管理员id过滤
|
||||
AdminId string `json:"admin_id"`
|
||||
AdminId []string `json:"admin_id"`
|
||||
}
|
||||
|
||||
type DomainListInput struct {
|
||||
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/keystone/options"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -288,11 +287,14 @@ func (manager *SProjectManager) ListItemFilter(
|
||||
}
|
||||
|
||||
if len(query.AdminId) > 0 {
|
||||
_, err := validators.ValidateModel(ctx, nil, UserManager, &query.AdminId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
q = q.Equals("admin_id", query.AdminId)
|
||||
sq := UserManager.Query("id")
|
||||
sq = sq.Filter(
|
||||
sqlchemy.OR(
|
||||
sqlchemy.In(sq.Field("id"), query.AdminId),
|
||||
sqlchemy.In(sq.Field("name"), query.AdminId),
|
||||
),
|
||||
)
|
||||
q = q.In("admin_id", sq.SubQuery())
|
||||
}
|
||||
|
||||
groupStr := query.GroupId
|
||||
|
||||
@@ -28,7 +28,7 @@ type ProjectListOptions struct {
|
||||
UserId string `help:"filter by user id"`
|
||||
GroupId string `help:"filter by group id"`
|
||||
IdpId string `help:"filter by idp id"`
|
||||
AdminId string
|
||||
AdminId []string
|
||||
|
||||
OrderByDomain string `help:"order by domain name" choices:"asc|desc"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user