using EntrustSettle.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; namespace EntrustSettle.Common.DB; public class RepositorySetting { private static readonly Lazy> AllEntitys = new(() => { return typeof(BaseEntity).Assembly .GetTypes() .Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(BaseEntity))) .Where(it => it.FullName != null && it.FullName.StartsWith("EntrustSettle.Model.Models")); }); public static IEnumerable Entitys => AllEntitys.Value; /// /// 配置实体软删除过滤器
/// 统一过滤 软删除 无需自己写条件 ///
public static void SetDeletedEntityFilter(SqlSugarScopeProvider db) { db.QueryFilter.AddTableFilter(it => it.IsDeleted == false); } /// /// 配置租户 /// public static void SetTenantEntityFilter(SqlSugarScopeProvider db) { //if (App.User is not { ID: > 0, TenantId: > 0 }) //{ // return; //} ////多租户 单表 //db.QueryFilter.AddTableFilter(it => it.TenantId == App.User.TenantId || it.TenantId == -1); } }