From 53e35fd7895315a718cd6f9d546ee0803e865089 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Thu, 9 May 2019 13:16:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(#IWCX5):=20=E6=BC=94=E7=A4=BA=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E7=A6=81=E6=AD=A2=E4=BF=AE=E6=94=B9=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=B9=B3=E5=8F=B0=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment comment #IWCX5 #Issue close https://gitee.com/LongbowEnterprise/dashboard/issues?id=IWCX5 --- Bootstrap.DataAccess/Helper/DictHelper.cs | 24 +++++++---------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/Bootstrap.DataAccess/Helper/DictHelper.cs b/Bootstrap.DataAccess/Helper/DictHelper.cs index 28f37c96..c77f82a8 100644 --- a/Bootstrap.DataAccess/Helper/DictHelper.cs +++ b/Bootstrap.DataAccess/Helper/DictHelper.cs @@ -1,4 +1,4 @@ -using Bootstrap.Security; +using Bootstrap.Security; using Longbow.Cache; using Longbow.Data; using Longbow.Web; @@ -32,6 +32,8 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbContextManager.Create().RetrieveDicts()); + private static IEnumerable RetrieveProtectedDicts() => RetrieveDicts().Where(d => d.Define == 0 || d.Category == "测试平台"); + /// /// 删除字典中的数据 /// @@ -41,8 +43,8 @@ namespace Bootstrap.DataAccess { if (RetrieveSystemModel()) { - // 允许删除自定义数据字典 - var systemDicts = RetrieveDicts().Where(d => d.Define == 0); + // 禁止删除系统数据与测试平台数据 + var systemDicts = RetrieveProtectedDicts(); value = value.Where(v => !systemDicts.Any(d => d.Id == v)); if (!value.Any()) return true; } @@ -58,20 +60,8 @@ namespace Bootstrap.DataAccess /// public static bool Save(BootstrapDict p) { - if (RetrieveSystemModel()) - { - if (string.IsNullOrEmpty(p.Id)) - { - if (p.Define == 0) p.Define = 1; - } - else - { - if (RetrieveDicts().Where(m => m.Define == 0).Any(m => m.Id == p.Id)) - { - return true; - } - } - } + if (RetrieveSystemModel() && RetrieveProtectedDicts().Any(m => m.Id == p.Id)) return true; + var ret = DbContextManager.Create().Save(p); if (ret) CacheCleanUtility.ClearCache(dictIds: new List()); return ret;