更新基类控制器
This commit is contained in:
18
Yi.Framework.Net6/Yi.Framework.Model/Query/QueryCondition.cs
Normal file
18
Yi.Framework.Net6/Yi.Framework.Model/Query/QueryCondition.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Model.Query
|
||||
{
|
||||
public class QueryCondition
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public int Size { get; set; }
|
||||
public int Count { get; set; }
|
||||
public List<QueryParameter> Parameters { get; set; } = new List<QueryParameter>();
|
||||
public List<string> OrderBys { get; set; } = new List<string>();
|
||||
|
||||
}
|
||||
}
|
||||
16
Yi.Framework.Net6/Yi.Framework.Model/Query/QueryParameter.cs
Normal file
16
Yi.Framework.Net6/Yi.Framework.Model/Query/QueryParameter.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Model.Query
|
||||
{
|
||||
public class QueryParameter
|
||||
{
|
||||
public string FieldName { get; set; }
|
||||
public string FieldValue { get; set; }
|
||||
public ConditionalType ConditionalType { get; set; } = ConditionalType.Like;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Model.Query
|
||||
{
|
||||
public static class QueryParametersExtensions
|
||||
{
|
||||
|
||||
//public static QueryParameters SetParameters(this QueryParameters queryParameters, Dictionary<string, string> dic, bool IsTenant = true)
|
||||
//{
|
||||
// //var httpcontext = ServiceLocator.Instance.GetService<IHttpContextAccessor>().HttpContext;
|
||||
// queryParameters.OrderBys = new List<string> { "CreateTime" };
|
||||
// foreach (var p in dic)
|
||||
// {
|
||||
// QueryParameter qp = null;
|
||||
// if (p.Key == "IsDeleted" || p.Key == "Id")
|
||||
// {
|
||||
// qp = new QueryParameter() { FieldName = p.Key, FieldValue = p.Value, ConditionalType = ConditionalType.Equal };
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// qp = new QueryParameter() { FieldName = p.Key, FieldValue = p.Value };
|
||||
|
||||
// }
|
||||
// queryParameters.Parameters.Add(qp);
|
||||
// }
|
||||
// if (IsTenant)
|
||||
// {
|
||||
// //if (httpcontext.Request.Headers["TenantLevel"].ToString() == "0")
|
||||
// //{
|
||||
// // queryParameters.Parameters.Add(new QueryParameter() { ConditionalType = ConditionalType.Equal, FieldName = "TenantId", FieldValue = httpcontext.Request.Headers["TenantId"].ToString() });
|
||||
// //}
|
||||
// }
|
||||
|
||||
// return queryParameters;
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Model.Search
|
||||
{
|
||||
public class PageResult<T>
|
||||
{
|
||||
public static readonly long serialVersionUID = 4612105649493688532L;
|
||||
public long total; // 总记录数
|
||||
public int totalPages; //总页数
|
||||
public List<T> rows; // 每页显示的数据集合
|
||||
|
||||
public PageResult(long total, List<T> rows)
|
||||
{
|
||||
this.total = total;
|
||||
this.rows = rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Model.Search
|
||||
{
|
||||
public class SearchRequest
|
||||
{
|
||||
public static readonly int DEFAULT_PAGE = 1;
|
||||
public static readonly int DEFAULT_SIZE = 20;
|
||||
public string key { get; set; }
|
||||
public int page { get; set; }
|
||||
//排序字段
|
||||
public string sortBy { get; set; }
|
||||
//是否降序
|
||||
public bool descending { get; set; }
|
||||
//过滤字段
|
||||
public Dictionary<string, string> filter = new Dictionary<string, string>();
|
||||
|
||||
public int getPage()
|
||||
{
|
||||
if (page == 0)
|
||||
{
|
||||
return DEFAULT_PAGE;
|
||||
}
|
||||
// 获取页码时做一些校验,不能小于1
|
||||
return Math.Max(DEFAULT_PAGE, page);
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return DEFAULT_SIZE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user