mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
cloudcommon: virtualresource: optimize list with --field specified
No functional change
This commit is contained in:
@@ -314,10 +314,11 @@ func query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fieldFilter := jsonutils.GetQueryStringArray(query, "field")
|
||||
listF := listFields(manager, userCred)
|
||||
if len(fieldFilter) > 0 && userCred.IsSystemAdmin() { // only sysadmin can extend list Fields
|
||||
listF = append(listF, fieldFilter...)
|
||||
fieldFilter := jsonutils.GetQueryStringArray(query, "field")
|
||||
if len(fieldFilter) > 0 && userCred.IsSystemAdmin() {
|
||||
// only sysadmin can specify list Fields
|
||||
listF = fieldFilter
|
||||
}
|
||||
showDetails := false
|
||||
showDetailsJson, _ := query.Get("details")
|
||||
@@ -356,9 +357,6 @@ func query2List(manager IModelManager, ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
jsonDict = getModelExtraDetails(item, ctx, jsonDict)
|
||||
}
|
||||
if len(fieldFilter) > 0 {
|
||||
jsonDict = jsonDict.CopyIncludes(fieldFilter...)
|
||||
}
|
||||
results = append(results, jsonDict)
|
||||
}
|
||||
return results, nil
|
||||
|
||||
Reference in New Issue
Block a user