From fd600214be7085f998dfce811d0279789447e4a6 Mon Sep 17 00:00:00 2001 From: zhontai <361243234@qq.com> Date: Wed, 16 Nov 2022 11:23:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=9A=E5=91=98=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/platform/ZhonTai.Admin/Core/Consts/FilterNames.cs | 6 ++++++ src/platform/ZhonTai.Admin/Core/Db/Data/SyncData.cs | 3 ++- src/platform/ZhonTai.Admin/Core/Db/DbHelper.cs | 5 ++++- src/platform/ZhonTai.Admin/ZhonTai.Admin.xml | 10 ++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/platform/ZhonTai.Admin/Core/Consts/FilterNames.cs b/src/platform/ZhonTai.Admin/Core/Consts/FilterNames.cs index ac6c5068..d93ba98a 100644 --- a/src/platform/ZhonTai.Admin/Core/Consts/FilterNames.cs +++ b/src/platform/ZhonTai.Admin/Core/Consts/FilterNames.cs @@ -30,4 +30,10 @@ public static partial class FilterNames /// [Description("数据权限")] public const string Data = "Data"; + + /// + /// 会员 + /// + [Description("会员")] + public const string Member = "Member"; } \ No newline at end of file diff --git a/src/platform/ZhonTai.Admin/Core/Db/Data/SyncData.cs b/src/platform/ZhonTai.Admin/Core/Db/Data/SyncData.cs index 29ba6be9..c165d496 100644 --- a/src/platform/ZhonTai.Admin/Core/Db/Data/SyncData.cs +++ b/src/platform/ZhonTai.Admin/Core/Db/Data/SyncData.cs @@ -7,6 +7,7 @@ using FreeSql.DataAnnotations; using ZhonTai.Common.Helpers; using ZhonTai.Admin.Core.Configs; +using ZhonTai.Admin.Core.Consts; namespace ZhonTai.Admin.Core.Db.Data; @@ -56,7 +57,7 @@ protected virtual async Task InitDataAsync( try { - if (await db.Queryable().AnyAsync()) + if (await db.Queryable().DisableGlobalFilter(FilterNames.Tenant, FilterNames.Member).AnyAsync()) { Console.WriteLine($" table: {tableName} record already exists"); return; diff --git a/src/platform/ZhonTai.Admin/Core/Db/DbHelper.cs b/src/platform/ZhonTai.Admin/Core/Db/DbHelper.cs index ad6f59f0..c7317fdc 100644 --- a/src/platform/ZhonTai.Admin/Core/Db/DbHelper.cs +++ b/src/platform/ZhonTai.Admin/Core/Db/DbHelper.cs @@ -466,9 +466,12 @@ HostAppOptions hostAppOptions //租户过滤器 if (appConfig.Tenant) { - fsql.GlobalFilter.ApplyOnlyIf(FilterNames.Tenant, () => user?.Id > 0, a => a.TenantId == user.TenantId); + fsql.GlobalFilter.ApplyOnly(FilterNames.Tenant, a => a.TenantId == user.TenantId); } + //会员过滤器 + fsql.GlobalFilter.ApplyOnly(FilterNames.Member, a => a.MemberId == user.MemberId); + //数据权限过滤器 fsql.GlobalFilter.ApplyOnlyIf(FilterNames.Self, () => diff --git a/src/platform/ZhonTai.Admin/ZhonTai.Admin.xml b/src/platform/ZhonTai.Admin/ZhonTai.Admin.xml index f1c08e2c..f4e7b26a 100644 --- a/src/platform/ZhonTai.Admin/ZhonTai.Admin.xml +++ b/src/platform/ZhonTai.Admin/ZhonTai.Admin.xml @@ -801,6 +801,11 @@ 数据权限 + + + 会员 + + Api分组约定 @@ -1249,6 +1254,11 @@ 创建时间 + + + 修改时间 + + 是否删除