统一分页参数

zw
rszn 6 months ago
parent eeaf4c48da
commit c937290366

@ -13,7 +13,7 @@ public class IPage<T>
public IPage(int total, QueryPageModel page, List<T>? rows) public IPage(int total, QueryPageModel page, List<T>? rows)
{ {
Total = total; Total = total;
PageNum = page.Page; PageNum = page.PageNum;
PageSize = page.PageSize; PageSize = page.PageSize;
Rows = rows; Rows = rows;
} }

@ -5,9 +5,9 @@ public class QueryPageModel
/// <summary> /// <summary>
///页码 ///页码
/// </summary> /// </summary>
public int Page { get; set; } = 1; public int PageNum { get; set; } = 1;
/// <summary> /// <summary>
/// 页数 /// 页数
/// </summary> /// </summary>
public int PageSize { get; set; } = 10; public int PageSize { get; set; } = 10;
} }

@ -29,6 +29,12 @@ public abstract class BaseRepository<T> where T : class, new()
.InSingle(pkValue); .InSingle(pkValue);
} }
public ISugarQueryable<T> Queryable(bool blUseNoLock = false)
{
return DbBaseClient
.Queryable<T>().WithNoLockOrNot(blUseNoLock);
}
/// <summary> /// <summary>
/// 根据主值查询单条数据 /// 根据主值查询单条数据
/// </summary> /// </summary>
@ -109,7 +115,7 @@ public abstract class BaseRepository<T> where T : class, new()
.Queryable<T>() .Queryable<T>()
.Where(predicate) .Where(predicate)
.WithNoLockOrNot(false) .WithNoLockOrNot(false)
.ToPageList(page.Page, page.PageSize, ref totalCount); .ToPageList(page.PageNum, page.PageSize, ref totalCount);
@ -135,7 +141,7 @@ public abstract class BaseRepository<T> where T : class, new()
.Queryable<T>() .Queryable<T>()
.Where(predicate) .Where(predicate)
.WithNoLockOrNot(false) .WithNoLockOrNot(false)
.ToPageListAsync(page.Page, page.PageSize, totalCount); .ToPageListAsync(page.PageNum, page.PageSize, totalCount);
@ -159,7 +165,7 @@ public abstract class BaseRepository<T> where T : class, new()
List<T> pageList = DbBaseClient List<T> pageList = DbBaseClient
.Queryable<T>() .Queryable<T>()
.WithNoLockOrNot(false) .WithNoLockOrNot(false)
.ToPageList(page.Page, page.PageSize, ref totalCount); .ToPageList(page.PageNum, page.PageSize, ref totalCount);
return new IPage<T>(totalCount, page, pageList); return new IPage<T>(totalCount, page, pageList);
} }
@ -176,7 +182,7 @@ public abstract class BaseRepository<T> where T : class, new()
List<T> pageList = await DbBaseClient List<T> pageList = await DbBaseClient
.Queryable<T>() .Queryable<T>()
.WithNoLockOrNot(false) .WithNoLockOrNot(false)
.ToPageListAsync(page.Page, page.PageSize, totalCount); .ToPageListAsync(page.PageNum, page.PageSize, totalCount);
return new IPage<T>(totalCount, page, pageList); return new IPage<T>(totalCount, page, pageList);
} }
@ -725,7 +731,7 @@ public abstract class BaseRepository<T> where T : class, new()
.ToList(); .ToList();
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <typeparam name="T2"></typeparam> /// <typeparam name="T2"></typeparam>
@ -779,7 +785,7 @@ public abstract class BaseRepository<T> where T : class, new()
.Insertable(entity) .Insertable(entity)
.ExecuteReturnEntity(); .ExecuteReturnEntity();
} }
/// <summary> /// <summary>
/// 写入或者更新实体数据 /// 写入或者更新实体数据
/// </summary> /// </summary>
@ -1704,4 +1710,4 @@ public abstract class BaseRepository<T> where T : class, new()
} }

Loading…
Cancel
Save