diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs index 7327b95e..f4bcf935 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/ExceptionService.cs @@ -19,7 +19,7 @@ class ExceptionService : BaseDatabase, IException return true; } - public (IEnumerable Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, string? sortName, string sortOrder) + public (IEnumerable Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, List sortList) { var sql = new Sql(); @@ -45,18 +45,13 @@ class ExceptionService : BaseDatabase, IException sql.Where("LogTime >= @0 and LogTime <= @1", filter.Star, filter.End); - if (sortOrder == "Unset") + if (sortList.Any()) { - sortOrder = "desc"; - } - - if (string.IsNullOrEmpty(sortName)) - { - sql.OrderBy("Logtime desc", "ErrorPage", "UserId"); + sql.OrderBy(string.Join(", ", sortList)); } else { - sql.OrderBy($"{sortName} {sortOrder}"); + sql.OrderBy("Logtime desc", "ErrorPage", "UserId"); } var data = Database.Page(pageIndex, pageItems, sql); diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs index 1d19f244..31681d37 100644 --- a/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/IException.cs @@ -6,5 +6,5 @@ public interface IException { bool Log(Error exception); - (IEnumerable Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, string? sortName, string sortOrder); + (IEnumerable Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, List sortList); } diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor.cs index 2c54e139..6d376936 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Exceptions.razor.cs @@ -7,7 +7,7 @@ namespace BootstrapAdmin.Web.Pages.Admin; public partial class Exceptions { - private List PageItemsSource { get; } = new List { 5, 20, 40, 80, 100, 200 }; + private List PageItemsSource { get; } = new List { 20, 40, 80, 100, 200 }; private ErrorSearchModel ErrorSearchModel { get; set; } = new ErrorSearchModel(); @@ -43,7 +43,16 @@ public partial class Exceptions End = ErrorSearchModel.LogTime.End, }; - var (Items, ItemsCount) = ExceptionService.GetAll(options.SearchText, filter, options.PageIndex, options.PageItems, options.SortName, options.SortOrder.ToString()); + var sortList = new List(); + if (options.SortOrder != SortOrder.Unset && !string.IsNullOrEmpty(options.SortName)) + { + sortList.Add($"{options.SortName} {options.SortOrder}"); + } + else if (options.SortList != null) + { + sortList.AddRange(options.SortList); + } + var (Items, ItemsCount) = ExceptionService.GetAll(options.SearchText, filter, options.PageIndex, options.PageItems, sortList); ret.TotalCount = ItemsCount; ret.Items = Items;