统一分页参数

master
rszn 6 months ago
parent 2275bad82b
commit f6dcbeb218

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

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

@ -8,12 +8,14 @@
/// <summary>
/// 状态码
/// </summary>
public int Status { get; set; } = 200;
/// <summary>
/// 操作是否成功
/// </summary>
public bool IsSuccess { get; set; } = false;
/// <summary>
/// 返回信息
/// </summary>
@ -29,12 +31,11 @@
/// </summary>
/// <param name="msg">消息</param>
/// <returns></returns>
public static Result<T> Success(string msg = "成功")
public static Result<T> Success(T t = default)
{
return Message(true, msg, default);
return Message(true, "成功", t);
}
/// <summary>
/// 返回成功
@ -46,9 +47,8 @@
{
return Message(true, msg, data);
}
/// <summary>
/// 返回失败
/// </summary>
@ -58,8 +58,8 @@
{
return Message(false, msg, default);
}
/// <summary>
/// 返回失败
/// </summary>
@ -70,7 +70,7 @@
{
return Message(false, msg, data);
}
/// <summary>
/// 返回消息
/// </summary>
@ -82,7 +82,7 @@
{
return new Result<T>() { Msg = msg, Data = data, IsSuccess = success };
}
/// <summary>
/// 返回消息
/// </summary>
@ -90,15 +90,9 @@
/// <param name="msg">消息</param>
/// <param name="data">数据</param>
/// <returns></returns>
public static Result<T> Message(bool success, T data)
public static Result<T> Message(bool success, T data)
{
return new Result<T>() { Msg="查询成功", Data = data, IsSuccess = success };
return new Result<T>() { Msg = "查询成功", Data = data, IsSuccess = success };
}
}
}

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

Loading…
Cancel
Save