mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: 返回项目信息
This commit is contained in:
@@ -81,6 +81,7 @@ type DBInstancePrivilege struct {
|
||||
|
||||
type DBInstanceAccountDetails struct {
|
||||
apis.StatusStandaloneResourceDetails
|
||||
apis.ProjectizedResourceInfo
|
||||
DBInstanceResourceInfo
|
||||
|
||||
SDBInstanceAccount
|
||||
|
||||
@@ -63,6 +63,7 @@ type DBInstanceDatabaseCreateInput struct {
|
||||
|
||||
type DBInstancedatabaseDetails struct {
|
||||
apis.StatusStandaloneResourceDetails
|
||||
apis.ProjectizedResourceInfo
|
||||
DBInstanceResourceInfo
|
||||
|
||||
SDBInstanceDatabase
|
||||
|
||||
@@ -69,6 +69,7 @@ type ElasticcacheFilterListInput struct {
|
||||
|
||||
type ElasticcacheAccountDetails struct {
|
||||
apis.StatusStandaloneResourceDetails
|
||||
apis.ProjectizedResourceInfo
|
||||
ElasticcacheResourceInfo
|
||||
|
||||
SElasticcacheAccount
|
||||
@@ -76,6 +77,7 @@ type ElasticcacheAccountDetails struct {
|
||||
|
||||
type ElasticcacheAclDetails struct {
|
||||
apis.StandaloneResourceDetails
|
||||
apis.ProjectizedResourceInfo
|
||||
ElasticcacheResourceInfo
|
||||
|
||||
SElasticcacheAcl
|
||||
|
||||
@@ -18,6 +18,7 @@ import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
type ElasticcacheBackupDetails struct {
|
||||
apis.StatusStandaloneResourceDetails
|
||||
apis.ProjectizedResourceInfo
|
||||
ElasticcacheResourceInfo
|
||||
|
||||
SElasticcacheBackup
|
||||
|
||||
@@ -18,6 +18,7 @@ import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
type SecgroupRuleDetails struct {
|
||||
apis.ResourceBaseDetails
|
||||
apis.ProjectizedResourceInfo
|
||||
SSecurityGroupRule
|
||||
SecurityGroupResourceInfo
|
||||
}
|
||||
|
||||
@@ -179,13 +179,36 @@ func (manager *SDBInstanceAccountManager) FetchCustomizeColumns(
|
||||
rows := make([]api.DBInstanceAccountDetails, len(objs))
|
||||
stdRows := manager.SStatusStandaloneResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
dbRows := manager.SDBInstanceResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
dbinstanceIds := make([]string, len(objs))
|
||||
for i := range rows {
|
||||
rows[i] = api.DBInstanceAccountDetails{
|
||||
StatusStandaloneResourceDetails: stdRows[i],
|
||||
DBInstanceResourceInfo: dbRows[i],
|
||||
}
|
||||
rows[i], _ = objs[i].(*SDBInstanceAccount).getMoreDetails(ctx, userCred, rows[i])
|
||||
account := objs[i].(*SDBInstanceAccount)
|
||||
rows[i], _ = account.getMoreDetails(ctx, userCred, rows[i])
|
||||
dbinstanceIds[i] = account.DBInstanceId
|
||||
}
|
||||
|
||||
dbinstances := make(map[string]SDBInstance)
|
||||
err := db.FetchStandaloneObjectsByIds(DBInstanceManager, dbinstanceIds, &dbinstances)
|
||||
if err != nil {
|
||||
log.Errorf("FetchStandaloneObjectsByIds fail: %v", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
virObjs := make([]interface{}, len(objs))
|
||||
for i := range rows {
|
||||
if dbinstance, ok := dbinstances[dbinstanceIds[i]]; ok {
|
||||
virObjs[i] = &dbinstance
|
||||
}
|
||||
}
|
||||
|
||||
projRows := DBInstanceManager.SProjectizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, virObjs, stringutils2.SSortedStrings{}, isList)
|
||||
for i := range rows {
|
||||
rows[i].ProjectizedResourceInfo = projRows[i]
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
|
||||
@@ -302,13 +302,36 @@ func (manager *SDBInstanceDatabaseManager) FetchCustomizeColumns(
|
||||
rows := make([]api.DBInstancedatabaseDetails, len(objs))
|
||||
stdRows := manager.SStatusStandaloneResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
dbRows := manager.SDBInstanceResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
dbinstanceIds := make([]string, len(objs))
|
||||
for i := range rows {
|
||||
rows[i] = api.DBInstancedatabaseDetails{
|
||||
StatusStandaloneResourceDetails: stdRows[i],
|
||||
DBInstanceResourceInfo: dbRows[i],
|
||||
}
|
||||
rows[i], _ = objs[i].(*SDBInstanceDatabase).getMoreDetails(ctx, userCred, rows[i])
|
||||
database := objs[i].(*SDBInstanceDatabase)
|
||||
rows[i], _ = database.getMoreDetails(ctx, userCred, rows[i])
|
||||
dbinstanceIds[i] = database.DBInstanceId
|
||||
}
|
||||
|
||||
dbinstances := make(map[string]SDBInstance)
|
||||
err := db.FetchStandaloneObjectsByIds(DBInstanceManager, dbinstanceIds, &dbinstances)
|
||||
if err != nil {
|
||||
log.Errorf("FetchStandaloneObjectsByIds fail: %v", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
virObjs := make([]interface{}, len(objs))
|
||||
for i := range rows {
|
||||
if dbinstance, ok := dbinstances[dbinstanceIds[i]]; ok {
|
||||
virObjs[i] = &dbinstance
|
||||
}
|
||||
}
|
||||
|
||||
projRows := DBInstanceManager.SProjectizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, virObjs, fields, isList)
|
||||
for i := range rows {
|
||||
rows[i].ProjectizedResourceInfo = projRows[i]
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
|
||||
@@ -536,11 +536,33 @@ func (manager *SElasticcacheAccountManager) FetchCustomizeColumns(
|
||||
stdRows := manager.SStatusStandaloneResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
cacheRows := manager.SElasticcacheResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
cacheIds := make([]string, len(objs))
|
||||
for i := range rows {
|
||||
rows[i] = api.ElasticcacheAccountDetails{
|
||||
StatusStandaloneResourceDetails: stdRows[i],
|
||||
ElasticcacheResourceInfo: cacheRows[i],
|
||||
}
|
||||
account := objs[i].(*SElasticcacheAccount)
|
||||
cacheIds[i] = account.ElasticcacheId
|
||||
}
|
||||
|
||||
caches := make(map[string]SElasticcache)
|
||||
err := db.FetchStandaloneObjectsByIds(ElasticcacheManager, cacheIds, &caches)
|
||||
if err != nil {
|
||||
log.Errorf("FetchStandaloneObjectsByIds fail: %v", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
virObjs := make([]interface{}, len(objs))
|
||||
for i := range rows {
|
||||
if cache, ok := caches[cacheIds[i]]; ok {
|
||||
virObjs[i] = &cache
|
||||
}
|
||||
}
|
||||
|
||||
projRows := ElasticcacheManager.SProjectizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, virObjs, fields, isList)
|
||||
for i := range rows {
|
||||
rows[i].ProjectizedResourceInfo = projRows[i]
|
||||
}
|
||||
|
||||
return rows
|
||||
|
||||
@@ -420,11 +420,33 @@ func (manager *SElasticcacheAclManager) FetchCustomizeColumns(
|
||||
stdRows := manager.SStandaloneResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
elasticRows := manager.SElasticcacheResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
cacheIds := make([]string, len(objs))
|
||||
for i := range rows {
|
||||
rows[i] = api.ElasticcacheAclDetails{
|
||||
StandaloneResourceDetails: stdRows[i],
|
||||
ElasticcacheResourceInfo: elasticRows[i],
|
||||
}
|
||||
acl := objs[i].(*SElasticcacheAcl)
|
||||
cacheIds[i] = acl.ElasticcacheId
|
||||
}
|
||||
|
||||
caches := make(map[string]SElasticcache)
|
||||
err := db.FetchStandaloneObjectsByIds(ElasticcacheManager, cacheIds, &caches)
|
||||
if err != nil {
|
||||
log.Errorf("FetchStandaloneObjectsByIds fail: %v", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
virObjs := make([]interface{}, len(objs))
|
||||
for i := range rows {
|
||||
if cache, ok := caches[cacheIds[i]]; ok {
|
||||
virObjs[i] = &cache
|
||||
}
|
||||
}
|
||||
|
||||
projRows := ElasticcacheManager.SProjectizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, virObjs, fields, isList)
|
||||
for i := range rows {
|
||||
rows[i].ProjectizedResourceInfo = projRows[i]
|
||||
}
|
||||
|
||||
return rows
|
||||
|
||||
@@ -433,12 +433,33 @@ func (manager *SElasticcacheBackupManager) FetchCustomizeColumns(
|
||||
|
||||
stdRows := manager.SStatusStandaloneResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
cacheRows := manager.SElasticcacheResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
|
||||
cacheIds := make([]string, len(objs))
|
||||
for i := range rows {
|
||||
rows[i] = api.ElasticcacheBackupDetails{
|
||||
StatusStandaloneResourceDetails: stdRows[i],
|
||||
ElasticcacheResourceInfo: cacheRows[i],
|
||||
}
|
||||
backup := objs[i].(*SElasticcacheBackup)
|
||||
cacheIds[i] = backup.ElasticcacheId
|
||||
}
|
||||
|
||||
caches := make(map[string]SElasticcache)
|
||||
err := db.FetchStandaloneObjectsByIds(ElasticcacheManager, cacheIds, &caches)
|
||||
if err != nil {
|
||||
log.Errorf("FetchStandaloneObjectsByIds fail: %v", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
virObjs := make([]interface{}, len(objs))
|
||||
for i := range rows {
|
||||
if cache, ok := caches[cacheIds[i]]; ok {
|
||||
virObjs[i] = &cache
|
||||
}
|
||||
}
|
||||
|
||||
projRows := ElasticcacheManager.SProjectizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, virObjs, fields, isList)
|
||||
for i := range rows {
|
||||
rows[i].ProjectizedResourceInfo = projRows[i]
|
||||
}
|
||||
|
||||
return rows
|
||||
|
||||
@@ -217,12 +217,35 @@ func (manager *SSecurityGroupRuleManager) FetchCustomizeColumns(
|
||||
rows := make([]api.SecgroupRuleDetails, len(objs))
|
||||
bRows := manager.SResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
secRows := manager.SSecurityGroupResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
secIds := make([]string, len(objs))
|
||||
for i := range rows {
|
||||
rows[i] = api.SecgroupRuleDetails{
|
||||
ResourceBaseDetails: bRows[i],
|
||||
SecurityGroupResourceInfo: secRows[i],
|
||||
}
|
||||
rule := objs[i].(*SSecurityGroupRule)
|
||||
secIds[i] = rule.SecgroupId
|
||||
}
|
||||
|
||||
secgroups := make(map[string]SSecurityGroup)
|
||||
err := db.FetchStandaloneObjectsByIds(SecurityGroupManager, secIds, &secgroups)
|
||||
if err != nil {
|
||||
log.Errorf("FetchStandaloneObjectsByIds fail: %v", err)
|
||||
return rows
|
||||
}
|
||||
|
||||
virObjs := make([]interface{}, len(objs))
|
||||
for i := range rows {
|
||||
if secgroup, ok := secgroups[secIds[i]]; ok {
|
||||
virObjs[i] = &secgroup
|
||||
}
|
||||
}
|
||||
|
||||
projRows := SecurityGroupManager.SProjectizedResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, virObjs, fields, isList)
|
||||
for i := range rows {
|
||||
rows[i].ProjectizedResourceInfo = projRows[i]
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user