客户设备数据隔离业务v3

dev-0829
ccongli 1 year ago
parent 93ad1b3665
commit c6abe9096e

@ -31,6 +31,9 @@ namespace VOL.Core.Infrastructure
case "tree_roles":
originalSql = GetRolesSql(originalSql);
break;
case "device_name":
originalSql = GetDevicesSql(originalSql);
break;
default:
break;
}
@ -65,5 +68,33 @@ namespace VOL.Core.Infrastructure
}
return originalSql;
}
/// <summary>
/// 获取解决的数据源,只能看到自己与下级所有角色
/// </summary>
/// <param name="context"></param>
/// <param name="originalSql"></param>
/// <returns></returns>
public static string GetDevicesSql(string originalSql)
{
if (UserContext.Current.IsSuperAdmin)
{
return originalSql;
}
int UserId = UserContext.Current.UserId;
if (DBType.Name == DbCurrentType.PgSql.ToString())
{
originalSql = $"SELECT \"id\" as key,\"name\" as value from data_config where \"CreateID\" = {UserId}";
}
else
{
originalSql = $@"SELECT id AS 'key',name as 'value' FROM data_config WHERE CreateID={UserId}";
}
return originalSql;
}
}
}

@ -136,7 +136,11 @@ namespace VOL.System.Controllers
{
int useId = UserContext.Current.UserId;
var sysDepartment = await _service.GetUserDepartment(useId);
if (sysDepartment == null) {
string DepartmentName = "未知企业,请联系管理员认证!";
string DepartmentId = "404";
return JsonNormal(new { DepartmentName, DepartmentId });
}
return JsonNormal(new { sysDepartment.DepartmentName, sysDepartment.DepartmentId });
}
}

Loading…
Cancel
Save