feat:添加数据权限搭建,准备完成数据权限过滤
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Furion;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Yi.Framework.Infrastructure.Sqlsugar.Uow;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Sqlsugar
|
||||
{
|
||||
@@ -7,13 +9,42 @@ namespace Yi.Framework.Infrastructure.Sqlsugar
|
||||
/// </summary>
|
||||
public static class SqlsugarExtensions
|
||||
{
|
||||
//使用上下文对象
|
||||
/// <summary>
|
||||
/// 使用默认上下文
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public static void AddDbSqlsugarContextServer(this IServiceCollection services)
|
||||
{
|
||||
services.AddDbSqlsugarOption();
|
||||
|
||||
|
||||
services.AddSingleton(x => x.GetRequiredService<SqlSugarDbContext>().SqlSugarClient);
|
||||
services.AddSingleton<SqlSugarDbContext>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义上下文
|
||||
/// </summary>
|
||||
/// <typeparam name="DbContext"></typeparam>
|
||||
/// <param name="services"></param>
|
||||
public static void AddDbSqlsugarContextServer<DbContext>(this IServiceCollection services) where DbContext : SqlSugarDbContext
|
||||
{
|
||||
services.AddDbSqlsugarOption();
|
||||
|
||||
|
||||
services.AddSingleton(x => x.GetRequiredService<DbContext>().SqlSugarClient);
|
||||
services.AddSingleton<DbContext>();
|
||||
|
||||
}
|
||||
|
||||
public static void AddDbSqlsugarOption(this IServiceCollection services)
|
||||
{
|
||||
services.Configure<DbConnOptions>(App.Configuration.GetSection("DbConnOptions"));
|
||||
|
||||
services.AddUnitOfWork<SqlsugarUnitOfWork>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user