using NPin.Framework.SqlSugarCore; using NPin.Framework.Upms.Domain.Authorization; using NPin.Framework.Upms.Domain.Shared.Consts; using SqlSugar; using Volo.Abp.DependencyInjection; namespace NPin.Framework.Upms.SqlSugarCore; public class NPinUpmsDbContext : SqlSugarDbContext { public NPinUpmsDbContext(IAbpLazyServiceProvider lazyServiceProvider) : base(lazyServiceProvider) { } protected override void CustomDataFilter(ISqlSugarClient sqlSugarClient) { if (DataFilter.IsEnabled()) { DataPermissionFilter(sqlSugarClient); } base.CustomDataFilter(sqlSugarClient); } /// /// 数据权限过滤 /// /// protected void DataPermissionFilter(ISqlSugarClient sqlSugarClient) { // 当前无登录用户,无需过滤 if (CurrentUser.Id == null) return; // 管理员角色 不进行过滤 if (CurrentUser.UserName.Equals(UserConst.Admin) || CurrentUser.Roles.Any(r => r.Equals(UserConst.AdminRoleCode))) { return; } // var expUser = Expressionable.Create<>(); // var expRole = Expressionable.Create<>(); // 无岗位 or 无角色 只能看自己 // sqlSugarClient.QueryFilter.AddTableFilter() } }