chore: 更改 PetaPoco 工程名称服务下沉

This commit is contained in:
Argo-Tianyi 2021-12-11 10:42:54 +08:00
parent f4ba67baf9
commit 80c7f9aa8c
16 changed files with 206 additions and 115 deletions

View File

@ -4,7 +4,7 @@
"projects": [
"src\\blazor\\admin\\BootstrapAdmin.DataAccess.EFCore\\BootstrapAdmin.DataAccess.EFCore.csproj",
"src\\blazor\\admin\\BootstrapAdmin.DataAccess.Models\\BootstrapAdmin.DataAccess.Models.csproj",
"src\\blazor\\admin\\BootstrapAdmin.DataAccess\\BootstrapAdmin.DataAccess.csproj",
"src\\blazor\\admin\\BootstrapAdmin.DataAccess.PetaPoco\\BootstrapAdmin.DataAccess.PetaPoco.csproj",
"src\\blazor\\admin\\BootstrapAdmin.Web.Interface\\BootstrapAdmin.Web.Interface.csproj",
"src\\blazor\\admin\\BootstrapAdmin.Web\\BootstrapAdmin.Web.csproj",
"src\\mvc\\admin\\Bootstrap.Admin\\Bootstrap.Admin.csproj",

View File

@ -145,13 +145,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client", "client", "{55A245
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.Web", "src\blazor\admin\BootstrapAdmin.Web\BootstrapAdmin.Web.csproj", "{EF5EF5A4-616A-4BA7-9E1E-1407E8EC0395}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.DataAccess", "src\blazor\admin\BootstrapAdmin.DataAccess\BootstrapAdmin.DataAccess.csproj", "{1C04A3C2-DF68-4716-BA69-259CEC6E2311}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.DataAccess.EFCore", "src\blazor\admin\BootstrapAdmin.DataAccess.EFCore\BootstrapAdmin.DataAccess.EFCore.csproj", "{D8ED2DF7-F7E1-4DE7-B097-D0BEE51D58E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BootstrapAdmin.DataAccess.EFCore", "src\blazor\admin\BootstrapAdmin.DataAccess.EFCore\BootstrapAdmin.DataAccess.EFCore.csproj", "{D8ED2DF7-F7E1-4DE7-B097-D0BEE51D58E9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.DataAccess.Models", "src\blazor\admin\BootstrapAdmin.DataAccess.Models\BootstrapAdmin.DataAccess.Models.csproj", "{7E3861AB-F797-4A9F-B7CE-0E35751FFCD9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BootstrapAdmin.DataAccess.Models", "src\blazor\admin\BootstrapAdmin.DataAccess.Models\BootstrapAdmin.DataAccess.Models.csproj", "{7E3861AB-F797-4A9F-B7CE-0E35751FFCD9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.Web.Interface", "src\blazor\admin\BootstrapAdmin.Web.Interface\BootstrapAdmin.Web.Interface.csproj", "{C57CE871-FBC9-44B7-996B-E8D3449EDAD4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BootstrapAdmin.Web.Interface", "src\blazor\admin\BootstrapAdmin.Web.Interface\BootstrapAdmin.Web.Interface.csproj", "{C57CE871-FBC9-44B7-996B-E8D3449EDAD4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.DataAccess.PetaPoco", "src\blazor\admin\BootstrapAdmin.DataAccess.PetaPoco\BootstrapAdmin.DataAccess.PetaPoco.csproj", "{20D03C52-0F8B-47B6-BCA8-CF0812F82722}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -199,10 +199,6 @@ Global
{EF5EF5A4-616A-4BA7-9E1E-1407E8EC0395}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF5EF5A4-616A-4BA7-9E1E-1407E8EC0395}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF5EF5A4-616A-4BA7-9E1E-1407E8EC0395}.Release|Any CPU.Build.0 = Release|Any CPU
{1C04A3C2-DF68-4716-BA69-259CEC6E2311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C04A3C2-DF68-4716-BA69-259CEC6E2311}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C04A3C2-DF68-4716-BA69-259CEC6E2311}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C04A3C2-DF68-4716-BA69-259CEC6E2311}.Release|Any CPU.Build.0 = Release|Any CPU
{D8ED2DF7-F7E1-4DE7-B097-D0BEE51D58E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8ED2DF7-F7E1-4DE7-B097-D0BEE51D58E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8ED2DF7-F7E1-4DE7-B097-D0BEE51D58E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -215,6 +211,10 @@ Global
{C57CE871-FBC9-44B7-996B-E8D3449EDAD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C57CE871-FBC9-44B7-996B-E8D3449EDAD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C57CE871-FBC9-44B7-996B-E8D3449EDAD4}.Release|Any CPU.Build.0 = Release|Any CPU
{20D03C52-0F8B-47B6-BCA8-CF0812F82722}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20D03C52-0F8B-47B6-BCA8-CF0812F82722}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20D03C52-0F8B-47B6-BCA8-CF0812F82722}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20D03C52-0F8B-47B6-BCA8-CF0812F82722}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -247,10 +247,10 @@ Global
{45ADEF9B-C8BD-4224-9E12-F6716E85A22C} = {DAE3826B-AAAB-468A-9A06-2F56EF5C0767}
{55A2459A-6BDE-4493-B2C0-5BE1673E99EE} = {DAE3826B-AAAB-468A-9A06-2F56EF5C0767}
{EF5EF5A4-616A-4BA7-9E1E-1407E8EC0395} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C}
{1C04A3C2-DF68-4716-BA69-259CEC6E2311} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C}
{D8ED2DF7-F7E1-4DE7-B097-D0BEE51D58E9} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C}
{7E3861AB-F797-4A9F-B7CE-0E35751FFCD9} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C}
{C57CE871-FBC9-44B7-996B-E8D3449EDAD4} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C}
{20D03C52-0F8B-47B6-BCA8-CF0812F82722} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {221EAE38-5F75-4391-9A48-E462A9F3B8FC}

View File

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="6.1.1-beta01" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
</ItemGroup>

View File

@ -1,6 +1,7 @@
using BootstrapAdmin.DataAccess.EFCore;
using BootstrapAdmin.DataAccess.EFCore.Services;
using BootstrapAdmin.DataAccess.Interface;
using BootstrapBlazor.Components;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
@ -27,8 +28,11 @@ namespace Microsoft.Extensions.DependencyInjection
option.UseSqlite(connString);
});
services.TryAddSingleton<INavigations, NavigationsService>();
services.TryAddSingleton<IDicts, DictsService>();
// 增加数据服务
services.AddSingleton(typeof(IDataService<>), typeof(DefaultDataService<>));
services.AddSingleton<INavigations, NavigationsService>();
services.AddSingleton<IDicts, DictsService>();
return services;
}
}

View File

@ -0,0 +1,78 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Components;
using Microsoft.EntityFrameworkCore;
namespace BootstrapAdmin.DataAccess.EFCore.Services
{
/// <summary>
/// PetaPoco ORM 的 IDataService 接口实现
/// </summary>
class DefaultDataService<TModel> : DataServiceBase<TModel> where TModel : class, new()
{
private IDbContextFactory<BootstrapAdminContext> DbFactory { get; set; }
/// <summary>
/// 构造函数
/// </summary>
public DefaultDataService(IDbContextFactory<BootstrapAdminContext> factory) => DbFactory = factory;
/// <summary>
/// 删除方法
/// </summary>
/// <param name="models"></param>
/// <returns></returns>
public override Task<bool> DeleteAsync(IEnumerable<TModel> models)
{
// 通过模型获取主键列数据
// 支持批量删除
using var context = DbFactory.CreateDbContext();
return Task.FromResult(true);
}
/// <summary>
/// 保存方法
/// </summary>
/// <param name="model"></param>
/// <param name="changedType"></param>
/// <returns></returns>
public override async Task<bool> SaveAsync(TModel model, ItemChangedType changedType)
{
using var context = DbFactory.CreateDbContext();
return true;
}
/// <summary>
/// 查询方法
/// </summary>
/// <param name="option"></param>
/// <returns></returns>
public override async Task<QueryData<TModel>> QueryAsync(QueryPageOptions option)
{
var ret = new QueryData<TModel>()
{
IsSorted = true,
IsFiltered = true,
IsSearch = true
};
//var filters = option.Filters.Concat(option.Searchs).Concat(option.CustomerSearchs);
//if (option.IsPage)
//{
// var items = await _db.PageAsync<TModel>(option.PageIndex, option.PageItems, filters, option.SortName, option.SortOrder);
// ret.TotalCount = Convert.ToInt32(items.TotalItems);
// ret.Items = items.Items;
//}
//else
//{
// var items = await _db.FetchAsync<TModel>(filters, option.SortName, option.SortOrder);
// ret.TotalCount = items.Count;
// ret.Items = items;
//}
return ret;
}
}
}

View File

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="6.1.1-beta01" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />

View File

@ -0,0 +1,89 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>BootstrapAdmin.DataAccess.PetaPoco</name>
</assembly>
<members>
<member name="T:BootstrapAdmin.Web.Extensions.DatabaseExtensions">
<summary>
</summary>
</member>
<member name="M:BootstrapAdmin.Web.Extensions.DatabaseExtensions.FetchAsync``1(PetaPoco.IDatabase,System.Collections.Generic.IEnumerable{BootstrapBlazor.Components.IFilterAction},System.String,BootstrapBlazor.Components.SortOrder)">
<summary>
</summary>
<typeparam name="TModel"></typeparam>
<returns></returns>
</member>
<member name="M:BootstrapAdmin.Web.Extensions.DatabaseExtensions.PageAsync``1(PetaPoco.IDatabase,System.Int64,System.Int64,System.Collections.Generic.IEnumerable{BootstrapBlazor.Components.IFilterAction},System.String,BootstrapBlazor.Components.SortOrder)">
<summary>
</summary>
<typeparam name="TModel"></typeparam>
<returns></returns>
</member>
<member name="T:BootstrapAdmin.DataAccess.PetaPoco.Services.NavigationsService">
<summary>
</summary>
</member>
<member name="M:BootstrapAdmin.DataAccess.PetaPoco.Services.NavigationsService.#ctor(PetaPoco.IDatabase)">
<summary>
</summary>
<param name="db"></param>
</member>
<member name="M:BootstrapAdmin.DataAccess.PetaPoco.Services.NavigationsService.RetrieveAllMenus(System.String)">
<summary>
获得指定用户名可访问的所有菜单集合
</summary>
<param name="userName">当前用户名</param>
<returns>未层次化的菜单集合</returns>
</member>
<member name="T:Microsoft.Extensions.DependencyInjection.ServicesExtensions">
<summary>
</summary>
</member>
<member name="M:Microsoft.Extensions.DependencyInjection.ServicesExtensions.AddPetaPocoDataAccessServices(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
<summary>
</summary>
<param name="services"></param>
<returns></returns>
</member>
<member name="T:BootstrapBlazor.DataAcces.PetaPoco.Services.DefaultDataService`1">
<summary>
PetaPoco ORM 的 IDataService 接口实现
</summary>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.Services.DefaultDataService`1.#ctor(PetaPoco.IDatabase)">
<summary>
构造函数
</summary>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.Services.DefaultDataService`1.DeleteAsync(System.Collections.Generic.IEnumerable{`0})">
<summary>
删除方法
</summary>
<param name="models"></param>
<returns></returns>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.Services.DefaultDataService`1.SaveAsync(`0,BootstrapBlazor.Components.ItemChangedType)">
<summary>
保存方法
</summary>
<param name="model"></param>
<param name="changedType"></param>
<returns></returns>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.Services.DefaultDataService`1.QueryAsync(BootstrapBlazor.Components.QueryPageOptions)">
<summary>
查询方法
</summary>
<param name="option"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Components;
using PetaPoco;
using System.Linq.Expressions;
using System.Reflection;

View File

@ -1,5 +1,7 @@
using BootstrapAdmin.DataAccess.Interface;
using BootstrapAdmin.DataAccess.Services;
using BootstrapAdmin.DataAccess.PetaPoco.Services;
using BootstrapBlazor.Components;
using BootstrapBlazor.DataAcces.PetaPoco.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using PetaPoco;
@ -27,8 +29,11 @@ namespace Microsoft.Extensions.DependencyInjection
return new Database<SQLiteDatabaseProvider>(connString);
});
services.TryAddSingleton<INavigations, NavigationsService>();
services.TryAddSingleton<IDicts, DictsService>();
// 增加数据服务
services.AddSingleton(typeof(IDataService<>), typeof(DefaultDataService<>));
services.AddSingleton<INavigations, NavigationsService>();
services.AddSingleton<IDicts, DictsService>();
return services;
}
}

View File

@ -2,17 +2,17 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapAdmin.Web.Extensions;
using BootstrapBlazor.Components;
using PetaPoco;
using PetaPoco.Extensions;
using PetaPoco.Providers;
using BootstrapAdmin.Web.Extensions;
namespace BootstrapBlazor.DataAcces.PetaPoco
namespace BootstrapBlazor.DataAcces.PetaPoco.Services
{
/// <summary>
/// PetaPoco ORM 的 IDataService 接口实现
/// </summary>
internal class DefaultDataService<TModel> : DataServiceBase<TModel> where TModel : class, new()
class DefaultDataService<TModel> : DataServiceBase<TModel> where TModel : class, new()
{
private readonly IDatabase _db;

View File

@ -1,6 +1,6 @@
using BootstrapAdmin.DataAccess.Interface;
namespace BootstrapAdmin.DataAccess.Services
namespace BootstrapAdmin.DataAccess.PetaPoco.Services
{
class DictsService : IDicts
{

View File

@ -2,7 +2,7 @@
using BootstrapAdmin.DataAccess.Models;
using PetaPoco;
namespace BootstrapAdmin.DataAccess.Services
namespace BootstrapAdmin.DataAccess.PetaPoco.Services
{
/// <summary>
///

View File

@ -1,38 +0,0 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>BootstrapAdmin.DataAccess</name>
</assembly>
<members>
<member name="T:Microsoft.Extensions.DependencyInjection.ServicesExtensions">
<summary>
</summary>
</member>
<member name="M:Microsoft.Extensions.DependencyInjection.ServicesExtensions.AddPetaPocoDataAccessServices(Microsoft.Extensions.DependencyInjection.IServiceCollection)">
<summary>
</summary>
<param name="services"></param>
<returns></returns>
</member>
<member name="T:BootstrapAdmin.DataAccess.Services.NavigationsService">
<summary>
</summary>
</member>
<member name="M:BootstrapAdmin.DataAccess.Services.NavigationsService.#ctor(PetaPoco.IDatabase)">
<summary>
</summary>
<param name="db"></param>
</member>
<member name="M:BootstrapAdmin.DataAccess.Services.NavigationsService.RetrieveAllMenus(System.String)">
<summary>
获得指定用户名可访问的所有菜单集合
</summary>
<param name="userName">当前用户名</param>
<returns>未层次化的菜单集合</returns>
</member>
</members>
</doc>

View File

@ -5,7 +5,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BootstrapAdmin.DataAccess\BootstrapAdmin.DataAccess.csproj" />
<ProjectReference Include="..\BootstrapAdmin.DataAccess.EFCore\BootstrapAdmin.DataAccess.EFCore.csproj" />
<ProjectReference Include="..\BootstrapAdmin.DataAccess.PetaPoco\BootstrapAdmin.DataAccess.PetaPoco.csproj" />
</ItemGroup>
<ItemGroup>

View File

@ -64,25 +64,6 @@
</summary>
</member>
<member name="T:BootstrapAdmin.Web.Extensions.DatabaseExtensions">
<summary>
</summary>
</member>
<member name="M:BootstrapAdmin.Web.Extensions.DatabaseExtensions.FetchAsync``1(PetaPoco.IDatabase,System.Collections.Generic.IEnumerable{BootstrapBlazor.Components.IFilterAction},System.String,BootstrapBlazor.Components.SortOrder)">
<summary>
</summary>
<typeparam name="TModel"></typeparam>
<returns></returns>
</member>
<member name="M:BootstrapAdmin.Web.Extensions.DatabaseExtensions.PageAsync``1(PetaPoco.IDatabase,System.Int64,System.Int64,System.Collections.Generic.IEnumerable{BootstrapBlazor.Components.IFilterAction},System.String,BootstrapBlazor.Components.SortOrder)">
<summary>
</summary>
<typeparam name="TModel"></typeparam>
<returns></returns>
</member>
<member name="T:BootstrapAdmin.Web.Extensions.MenuExtensions">
<summary>
@ -212,37 +193,5 @@
</summary>
<param name="services"></param>
</member>
<member name="T:BootstrapBlazor.DataAcces.PetaPoco.DefaultDataService`1">
<summary>
PetaPoco ORM 的 IDataService 接口实现
</summary>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.DefaultDataService`1.#ctor(PetaPoco.IDatabase)">
<summary>
构造函数
</summary>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.DefaultDataService`1.DeleteAsync(System.Collections.Generic.IEnumerable{`0})">
<summary>
删除方法
</summary>
<param name="models"></param>
<returns></returns>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.DefaultDataService`1.SaveAsync(`0,BootstrapBlazor.Components.ItemChangedType)">
<summary>
保存方法
</summary>
<param name="model"></param>
<param name="changedType"></param>
<returns></returns>
</member>
<member name="M:BootstrapBlazor.DataAcces.PetaPoco.DefaultDataService`1.QueryAsync(BootstrapBlazor.Components.QueryPageOptions)">
<summary>
查询方法
</summary>
<param name="option"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@ -62,15 +62,15 @@ namespace Microsoft.Extensions.DependencyInjection
// 增加 BootstrapBlazor 组件
services.AddBootstrapBlazor();
// 增加数据服务
services.AddSingleton(typeof(IDataService<>), typeof(DefaultDataService<>));
// 增加 BootstrapApp 上下文服务
services.AddSingleton<BootstrapAppContext>();
// 增加数据服务
// 增加 PetaPoco 数据服务
services.AddPetaPocoDataAccessServices();
// 增加 EFCore 数据服务
services.AddEFCoreDataAccessServices();
return services;
}
}