feat: 程序异常增加默认排序规则
This commit is contained in:
parent
a7fe25c67d
commit
f5f0a7b735
|
@ -19,7 +19,7 @@ class ExceptionService : BaseDatabase, IException
|
|||
return true;
|
||||
}
|
||||
|
||||
public (IEnumerable<Error> Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, string? sortName, string sortOrder)
|
||||
public (IEnumerable<Error> Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, List<string> 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<Error>(pageIndex, pageItems, sql);
|
||||
|
|
|
@ -6,5 +6,5 @@ public interface IException
|
|||
{
|
||||
bool Log(Error exception);
|
||||
|
||||
(IEnumerable<Error> Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, string? sortName, string sortOrder);
|
||||
(IEnumerable<Error> Items, int ItemsCount) GetAll(string? searchText, ExceptionFilter filter, int pageIndex, int pageItems, List<string> sortList);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace BootstrapAdmin.Web.Pages.Admin;
|
|||
|
||||
public partial class Exceptions
|
||||
{
|
||||
private List<int> PageItemsSource { get; } = new List<int> { 5, 20, 40, 80, 100, 200 };
|
||||
private List<int> PageItemsSource { get; } = new List<int> { 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<string>();
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue