feat:添加数据权限搭建,准备完成数据权限过滤

This commit is contained in:
橙子
2023-05-21 21:43:11 +08:00
parent 95a91a10b3
commit ad6bd8f39b
15 changed files with 206 additions and 83 deletions

View File

@@ -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>();
}
}
}