diff --git a/vol-net6/VOL.Core/Infrastructure/DictionaryHandler.cs b/vol-net6/VOL.Core/Infrastructure/DictionaryHandler.cs
index 7ba7f56..03dbf0b 100644
--- a/vol-net6/VOL.Core/Infrastructure/DictionaryHandler.cs
+++ b/vol-net6/VOL.Core/Infrastructure/DictionaryHandler.cs
@@ -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;
}
+
+
+ ///
+ /// 获取解决的数据源,只能看到自己与下级所有角色
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
}
}
diff --git a/vol-net6/VOL.WebApi/Controllers/System/Partial/Sys_DepartmentController.cs b/vol-net6/VOL.WebApi/Controllers/System/Partial/Sys_DepartmentController.cs
index 7848355..9245f8c 100644
--- a/vol-net6/VOL.WebApi/Controllers/System/Partial/Sys_DepartmentController.cs
+++ b/vol-net6/VOL.WebApi/Controllers/System/Partial/Sys_DepartmentController.cs
@@ -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 });
}
}