diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Services/DictService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Services/DictService.cs index f578b6d6..a801c1e4 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Services/DictService.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.EFCore/Services/DictService.cs @@ -6,6 +6,11 @@ namespace BootstrapAdmin.DataAccess.EFCore.Services; class DictService : IDict { + public List GetAll() + { + throw new NotImplementedException(); + } + public Dictionary GetApps() { throw new NotImplementedException(); diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs index 3735acbe..af7bf383 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs @@ -11,18 +11,13 @@ class DictService : BaseDatabase, IDict { private string AppId { get; set; } - /// - /// - /// - /// - /// public DictService(IDatabase db, IConfiguration configuration) { Database = db; AppId = configuration.GetValue("AppId", "BA"); } - private List GetAll() => Database.Fetch(); + public List GetAll() => Database.Fetch(); public Dictionary GetApps() { diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs index 62d62365..496b973a 100644 --- a/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs @@ -1,10 +1,18 @@ -namespace BootstrapAdmin.Web.Core; +using BootstrapAdmin.DataAccess.Models; + +namespace BootstrapAdmin.Web.Core; /// /// Dict 字典表接口 /// public interface IDict { + /// + /// 获得 所有数据方法 + /// + /// + List GetAll(); + /// /// 获得 配置所有的 App 集合 /// diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor index ecf167d9..8daa438a 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor @@ -1,11 +1,11 @@ @page "/Admin/Dicts" - + - + @if (context is DictsSearchModel searchModel) diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor.cs index 3ef64fa1..740fe7fa 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Dicts.razor.cs @@ -1,4 +1,5 @@ using BootstrapAdmin.DataAccess.Models; +using BootstrapAdmin.Web.Core; using BootstrapAdmin.Web.Models; namespace BootstrapAdmin.Web.Pages.Admin @@ -8,21 +9,54 @@ namespace BootstrapAdmin.Web.Pages.Admin /// public partial class Dicts { - private IEnumerable? EditDefines { get; set; } + private ITableSearchModel DictsSearchModel { get; set; } = new DictsSearchModel(); - private IEnumerable? LookUp { get; set; } + [Inject] + [NotNull] + private IDict? DictService { get; set; } - private ITableSearchModel? DictsSearchModel { get; set; } = new DictsSearchModel(); - - /// - /// - /// - protected override void OnInitialized() + private Task> OnQueryAsync(QueryPageOptions options) { - base.OnInitialized(); + var ret = new QueryData() + { + IsSorted = true, + IsFiltered = true, + IsSearch = true + }; - EditDefines = typeof(EnumDictDefine).ToSelectList(); - LookUp = EditDefines; + var items = DictService.GetAll(); + + // 处理模糊查询 + if (!string.IsNullOrEmpty(options.SearchText)) + { + items = items.Where(i => i.Category.Contains(options.SearchText) || i.Name.Contains(options.SearchText)).ToList(); + } + + // 处理高级查询 + if (options.CustomerSearchs.Any()) + { + items = items.Where(options.CustomerSearchs.GetFilterFunc()).ToList(); + } + + // 处理过滤 + if (options.Filters.Any()) + { + items = items.Where(options.Filters.GetFilterFunc()).ToList(); + } + + // 处理排序 + if (!string.IsNullOrEmpty(options.SortName)) + { + items = items.Sort(options.SortName, options.SortOrder).ToList(); + } + else + { + items = items.OrderBy(i => i.Define).ThenBy(i => i.Category).ThenBy(i => i.Name).ToList(); + } + + ret.TotalCount = items.Count; + ret.Items = items; + return Task.FromResult(ret); } } }