From c6abe9096e57893396465a57f2b8fac253b00383 Mon Sep 17 00:00:00 2001
From: ccongli <1441652193@qq.com>
Date: Wed, 27 Sep 2023 17:45:30 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E8=AE=BE=E5=A4=87=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E9=9A=94=E7=A6=BB=E4=B8=9A=E5=8A=A1v3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Infrastructure/DictionaryHandler.cs | 31 +++++++++++++++++++
.../Partial/Sys_DepartmentController.cs | 6 +++-
2 files changed, 36 insertions(+), 1 deletion(-)
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 });
}
}