Compare commits

...

2 Commits

Author SHA1 Message Date
ccongli 6db4c6aab9 Merge branch 'dev-0829'
1 year ago
ccongli c6abe9096e 客户设备数据隔离业务v3
1 year ago

@ -31,6 +31,9 @@ namespace VOL.Core.Infrastructure
case "tree_roles": case "tree_roles":
originalSql = GetRolesSql(originalSql); originalSql = GetRolesSql(originalSql);
break; break;
case "device_name":
originalSql = GetDevicesSql(originalSql);
break;
default: default:
break; break;
} }
@ -65,5 +68,33 @@ namespace VOL.Core.Infrastructure
} }
return originalSql; 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; int useId = UserContext.Current.UserId;
var sysDepartment = await _service.GetUserDepartment(useId); 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 }); return JsonNormal(new { sysDepartment.DepartmentName, sysDepartment.DepartmentId });
} }
} }

Loading…
Cancel
Save