You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.5 KiB
C#
83 lines
2.5 KiB
C#
using DS.Module.Core.Extensions;
|
|
using Org.BouncyCastle.Asn1.Ocsp;
|
|
using SqlSugar;
|
|
using System.ComponentModel;
|
|
|
|
namespace DS.Module.Core;
|
|
|
|
/// <summary>
|
|
/// 查询请求实体
|
|
/// </summary>
|
|
public class PageRequest
|
|
{
|
|
/// <summary>
|
|
/// 查询条件
|
|
/// </summary>
|
|
public string QueryCondition { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 其他查询条件
|
|
/// </summary>
|
|
public string? OtherQueryCondition { get; set; }
|
|
|
|
/// <summary>
|
|
/// 分页排序条件
|
|
/// </summary>
|
|
public PageCondition? PageCondition { get; set; }
|
|
|
|
/// <summary>
|
|
/// 获取当前实例的查询条件
|
|
/// </summary>
|
|
/// <param name="client">SqlSugar对象</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="ArgumentNullException">当<paramref name="client"/>为null时引发</exception>
|
|
public List<IConditionalModel> GetConditionalModels(ISqlSugarClient client)
|
|
{
|
|
if (QueryCondition.IsNullOrEmpty())
|
|
return [];
|
|
|
|
ArgumentNullException.ThrowIfNull(client, nameof(client));
|
|
return client.ConfigQuery.Context.Utilities.JsonToConditionalModels(QueryCondition);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前实例的其他查询条件
|
|
/// </summary>
|
|
/// <param name="client">SqlSugar对象</param>
|
|
/// <returns></returns>
|
|
/// <exception cref="ArgumentNullException">当<paramref name="client"/>为null时引发</exception>
|
|
public List<IConditionalModel> GetOtherConditionalModels(ISqlSugarClient client)
|
|
{
|
|
if (OtherQueryCondition.IsNullOrEmpty())
|
|
return [];
|
|
|
|
ArgumentNullException.ThrowIfNull(client, nameof(client));
|
|
return client.ConfigQuery.Context.Utilities.JsonToConditionalModels(OtherQueryCondition);
|
|
}
|
|
|
|
public void SetDefaultOrderField(string FieldName, ListSortDirection SortDirection=ListSortDirection.Descending)
|
|
{
|
|
if (PageCondition.SortConditions == null || PageCondition.SortConditions.Count() == 0)
|
|
{
|
|
PageCondition.SortConditions = new SortCondition[]{new SortCondition
|
|
{
|
|
SortField = FieldName,
|
|
ListSortDirection = SortDirection
|
|
} };
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询请求实体的泛型版本
|
|
/// </summary>
|
|
/// <typeparam name="T">查他查询条件的类型</typeparam>
|
|
public class PageRequest<T> : PageRequest
|
|
{
|
|
/// <summary>
|
|
/// 其他查询条件
|
|
/// </summary>
|
|
public new T? OtherQueryCondition { get; set; }
|
|
|
|
}
|