Skip to content

Commit

Permalink
Repair registration center only has guide page (#3051) (#3053)
Browse files Browse the repository at this point in the history
* modify menu permission GetInstanceByTenantGroup

* modify tenants to tenant

Co-authored-by: panjiayao <[email protected]>
  • Loading branch information
erda-bot and Counterflowwind authored Nov 16, 2021
1 parent 860951d commit 8a12314
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
4 changes: 1 addition & 3 deletions modules/msp/instance/db/instance_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ func (db *InstanceTenantDB) GetByTenantGroup(group string) ([]*InstanceTenant, e
}
var list []*InstanceTenant
if err := db.query().
Where("tenant_group=?", group).
Where("engine=?", "monitor").Limit(1).
Find(&list).Error; err != nil {
Where("tenant_group=?", group).Find(&list).Error; err != nil {
return nil, err
}
return list, nil
Expand Down
33 changes: 12 additions & 21 deletions modules/msp/instance/permission/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,26 @@ func (p *provider) getProjectIDByGroupID(group string) (string, error) {
return id, nil
}

tenants, err := p.instanceTenantDB.GetByTenantGroup(group)
tenant, err := p.instanceTenantDB.GetInstanceByTenantGroup(group)
if err != nil {
return "", errors.NewDatabaseError(err)
}
if len(tenants) <= 0 {
return "", errors.NewNotFoundError(group)
tmc, err := p.tmcDB.GetByEngine(tenant.Engine)
if err != nil {
return "", errors.NewDatabaseError(err)
}
var monitorId = ""
for _, tenant := range tenants {
if tenant.Engine == instance.Monitor {
monitorId = tenant.ID
}
tmc, err := p.tmcDB.GetByEngine(tenant.Engine)
if err != nil {
return "", errors.NewDatabaseError(err)
}
if tmc == nil {
continue
}
if strings.EqualFold(tmc.ServiceType, string(instance.ServiceTypeMicroService)) {
id := p.getProjectIDByTenant(tenant)
if len(id) > 0 {
return id, nil
}
if tmc == nil {
return "", errors.NewDatabaseError(err)
}
if strings.EqualFold(tmc.ServiceType, string(instance.ServiceTypeMicroService)) {
id := p.getProjectIDByTenant(tenant)
if len(id) > 0 {
return id, nil
}
}

monitor, err := p.monitorDB.GetByFields(map[string]interface{}{
"MonitorId": monitorId,
"MonitorId": tenant.ID,
})
if monitor != nil {
return monitor.ProjectId, nil
Expand Down

0 comments on commit 8a12314

Please sign in to comment.