fix: issue of tenant status for all features
This commit is contained in:
@@ -15,9 +15,9 @@ import (
|
||||
// 实例化数据层 SysTenantImpl 结构体
|
||||
var NewSysTenantImpl = &SysTenantImpl{
|
||||
selectSql: `select
|
||||
t.tenant_id, t.parent_id, t.ancestors, t.tenant_name, t.order_num, t.tenancy_type, t.tenancy_key, t.status,
|
||||
t.del_flag, t.create_by, t.create_time
|
||||
from sys_tenant t`,
|
||||
t.tenant_id, t.parent_id, t.ancestors, t.tenant_name, t.order_num, t.tenancy_type, t.tenancy_key, t.status,
|
||||
t.del_flag, t.create_by, t.create_time
|
||||
from sys_tenant t `,
|
||||
|
||||
resultMap: map[string]string{
|
||||
"tenant_id": "TenantID",
|
||||
@@ -103,17 +103,17 @@ func (r *SysTenantImpl) SelectTenantList(sysTenant model.SysTenant, dataScopeSQL
|
||||
|
||||
// SelectTenantListByRoleId 根据角色ID查询租户树信息
|
||||
func (r *SysTenantImpl) SelectTenantListByRoleId(roleId string, tenantCheckStrictly bool) []string {
|
||||
querySql := `select t.tenant_id as 'str' from sys_tenant d
|
||||
left join sys_role_tenant rd on t.tenant_id = rt.tenant_id
|
||||
where rt.role_id = ? `
|
||||
querySql := `select t.tenant_id as 'str' from sys_tenant t
|
||||
left join sys_role_tenant rt on t.tenant_id = rt.tenant_id
|
||||
where rt.role_id = ? and t.status = 1 `
|
||||
var params []any
|
||||
params = append(params, roleId)
|
||||
// 展开
|
||||
if tenantCheckStrictly {
|
||||
querySql += ` and t.tenant_id not in
|
||||
(select t.parent_id from sys_tenant d
|
||||
inner join sys_role_tenant rd on t.tenant_id = rt.tenant_id
|
||||
and rt.role_id = ?) `
|
||||
(select t.parent_id from sys_tenant t
|
||||
inner join sys_role_tenant rt on t.tenant_id = rt.tenant_id
|
||||
and rt.role_id = ?) `
|
||||
params = append(params, roleId)
|
||||
}
|
||||
querySql += "order by t.parent_id, t.order_num"
|
||||
@@ -138,9 +138,9 @@ func (r *SysTenantImpl) SelectTenantListByRoleId(roleId string, tenantCheckStric
|
||||
// SelectTenantById 根据租户ID查询信息
|
||||
func (r *SysTenantImpl) SelectTenantById(tenantId string) model.SysTenant {
|
||||
querySql := `select t.tenant_id, t.parent_id, t.ancestors,
|
||||
t.tenant_name, t.order_num, t.tenancy_type, t.tenancy_key, t.status,
|
||||
(select tenant_name from sys_tenant where tenant_id = t.parent_id) parent_name
|
||||
from sys_tenant t where t.tenant_id = ?`
|
||||
t.tenant_name, t.order_num, t.tenancy_type, t.tenancy_key, t.status,
|
||||
(select tenant_name from sys_tenant where tenant_id = t.parent_id and status = 1) parent_name
|
||||
from sys_tenant t where t.tenant_id = ? and t.status = 1 `
|
||||
results, err := datasource.RawDB("", querySql, []any{tenantId})
|
||||
if err != nil {
|
||||
logger.Errorf("query err => %v", err)
|
||||
|
||||
Reference in New Issue
Block a user