From f6dcbeb21844096209b34e88dbbfe1abc2087d59 Mon Sep 17 00:00:00 2001 From: rszn <645583145@qq.com> Date: Wed, 5 Jun 2024 10:03:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=88=86=E9=A1=B5=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HybirdFrameworkCore/Entity/IPage.cs | 2 +- HybirdFrameworkCore/Entity/QueryPageModel.cs | 5 +-- HybirdFrameworkCore/Entity/Result.cs | 34 ++++++++------------ Repository/BaseRepository.cs | 20 ++++++++---- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/HybirdFrameworkCore/Entity/IPage.cs b/HybirdFrameworkCore/Entity/IPage.cs index b9a8d4a..69bcb57 100644 --- a/HybirdFrameworkCore/Entity/IPage.cs +++ b/HybirdFrameworkCore/Entity/IPage.cs @@ -13,7 +13,7 @@ public class IPage public IPage(int total, QueryPageModel page, List? rows) { Total = total; - PageNum = page.Page; + PageNum = page.PageNum; PageSize = page.PageSize; Rows = rows; } diff --git a/HybirdFrameworkCore/Entity/QueryPageModel.cs b/HybirdFrameworkCore/Entity/QueryPageModel.cs index b8bfd4a..72e63e6 100644 --- a/HybirdFrameworkCore/Entity/QueryPageModel.cs +++ b/HybirdFrameworkCore/Entity/QueryPageModel.cs @@ -5,9 +5,10 @@ public class QueryPageModel /// ///页码 /// - public int Page { get; set; } = 1; + public int PageNum { get; set; } = 1; + /// /// 页数 /// public int PageSize { get; set; } = 10; -} \ No newline at end of file +} diff --git a/HybirdFrameworkCore/Entity/Result.cs b/HybirdFrameworkCore/Entity/Result.cs index 3cd3831..ef7d03e 100644 --- a/HybirdFrameworkCore/Entity/Result.cs +++ b/HybirdFrameworkCore/Entity/Result.cs @@ -8,12 +8,14 @@ /// /// 状态码 /// - + public int Status { get; set; } = 200; + /// /// 操作是否成功 /// public bool IsSuccess { get; set; } = false; + /// /// 返回信息 /// @@ -29,12 +31,11 @@ /// /// 消息 /// - public static Result Success(string msg = "成功") + public static Result Success(T t = default) { - return Message(true, msg, default); + return Message(true, "成功", t); } - - + /// /// 返回成功 @@ -46,9 +47,8 @@ { return Message(true, msg, data); } - - - + + /// /// 返回失败 /// @@ -58,8 +58,8 @@ { return Message(false, msg, default); } - - + + /// /// 返回失败 /// @@ -70,7 +70,7 @@ { return Message(false, msg, data); } - + /// /// 返回消息 /// @@ -82,7 +82,7 @@ { return new Result() { Msg = msg, Data = data, IsSuccess = success }; } - + /// /// 返回消息 /// @@ -90,15 +90,9 @@ /// 消息 /// 数据 /// - public static Result Message(bool success, T data) + public static Result Message(bool success, T data) { - return new Result() { Msg="查询成功", Data = data, IsSuccess = success }; + return new Result() { Msg = "查询成功", Data = data, IsSuccess = success }; } - - - } - - - } diff --git a/Repository/BaseRepository.cs b/Repository/BaseRepository.cs index 770092e..97f2c93 100644 --- a/Repository/BaseRepository.cs +++ b/Repository/BaseRepository.cs @@ -29,6 +29,12 @@ public abstract class BaseRepository where T : class, new() .InSingle(pkValue); } + public ISugarQueryable Queryable(bool blUseNoLock = false) + { + return DbBaseClient + .Queryable().WithNoLockOrNot(blUseNoLock); + } + /// /// 根据主值查询单条数据 /// @@ -109,7 +115,7 @@ public abstract class BaseRepository where T : class, new() .Queryable() .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 where T : class, new() .Queryable() .Where(predicate) .WithNoLockOrNot(false) - .ToPageListAsync(page.Page, page.PageSize, totalCount); + .ToPageListAsync(page.PageNum, page.PageSize, totalCount); @@ -159,7 +165,7 @@ public abstract class BaseRepository where T : class, new() List pageList = DbBaseClient .Queryable() .WithNoLockOrNot(false) - .ToPageList(page.Page, page.PageSize, ref totalCount); + .ToPageList(page.PageNum, page.PageSize, ref totalCount); return new IPage(totalCount, page, pageList); } @@ -176,7 +182,7 @@ public abstract class BaseRepository where T : class, new() List pageList = await DbBaseClient .Queryable() .WithNoLockOrNot(false) - .ToPageListAsync(page.Page, page.PageSize, totalCount); + .ToPageListAsync(page.PageNum, page.PageSize, totalCount); return new IPage(totalCount, page, pageList); } @@ -725,7 +731,7 @@ public abstract class BaseRepository where T : class, new() .ToList(); } /// - /// + /// /// /// /// @@ -779,7 +785,7 @@ public abstract class BaseRepository where T : class, new() .Insertable(entity) .ExecuteReturnEntity(); } - + /// /// 写入或者更新实体数据 /// @@ -1704,4 +1710,4 @@ public abstract class BaseRepository where T : class, new() -} \ No newline at end of file +}