From 422ece5c6508c027163da9d04cfca4a778888eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=81=B0=E7=81=B0?= Date: Wed, 7 Dec 2022 01:38:10 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=95=86=E5=93=81=E4=B8=8B=E6=9E=B6=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=9C=AA=E6=B8=85=E7=90=86=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=95=86=E5=93=81=E8=BF=98?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E8=B7=B3=E8=BD=AC=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E3=80=82=20=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=95=86=E5=93=81=E4=B8=8B=E6=9E=B6=E6=88=96=E8=80=85?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=90=8E=EF=BC=8C=E6=88=91=E7=9A=84=E8=B6=B3?= =?UTF-8?q?=E8=BF=B9=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=87=86?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Good/ICoreCmsGoodsBrowsingRepository.cs | 9 +++++++++ .../Good/ICoreCmsGoodsBrowsingServices.cs | 9 +++++++++ .../Good/CoreCmsGoodsBrowsingRepository.cs | 16 ++++++++++++++++ .../Good/CoreCmsGoodsBrowsingServices.cs | 10 ++++++++++ .../Controllers/UserController.cs | 2 +- 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs b/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs index 88a3afdf..d0741c88 100644 --- a/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs +++ b/CoreCms.Net.IRepository/Good/ICoreCmsGoodsBrowsingRepository.cs @@ -22,6 +22,15 @@ namespace CoreCms.Net.IRepository /// public interface ICoreCmsGoodsBrowsingRepository : IBaseRepository { + + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + + Task GetUserCountAsync(int userId); + /// /// 重写根据条件查询分页数据 /// diff --git a/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs b/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs index 1e36b76c..b700cc97 100644 --- a/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs +++ b/CoreCms.Net.IServices/Good/ICoreCmsGoodsBrowsingServices.cs @@ -22,6 +22,15 @@ namespace CoreCms.Net.IServices /// public interface ICoreCmsGoodsBrowsingServices : IBaseServices { + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + + Task GetUserCountAsync(int userId); + + /// /// 重写根据条件查询分页数据 /// diff --git a/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs b/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs index d43ff397..455ce44a 100644 --- a/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs +++ b/CoreCms.Net.Repository/Good/CoreCmsGoodsBrowsingRepository.cs @@ -28,6 +28,21 @@ namespace CoreCms.Net.Repository { } + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + + public async Task GetUserCountAsync(int userId) + { + var count = await DbClient.Queryable((gb, goods) => + new JoinQueryInfos(JoinType.Left, gb.goodsId == goods.id)) + .Where((gb, goods) => goods.isDel == false && goods.isMarketable == true && gb.userId == userId).With(SqlWith.NoLock).CountAsync(); + return count; + } + + /// /// 重写根据条件查询分页数据 /// @@ -46,6 +61,7 @@ namespace CoreCms.Net.Repository RefAsync totalCount = 0; var page = await DbClient.Queryable((gb, goods) => new JoinQueryInfos(JoinType.Left, gb.goodsId == goods.id)) + .Where((gb, goods) => goods.isDel == false && goods.isMarketable == true) .Select((gb, goods) => new CoreCmsGoodsBrowsing { id = gb.id, diff --git a/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs b/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs index 6a1cc164..d676f052 100644 --- a/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs +++ b/CoreCms.Net.Services/Good/CoreCmsGoodsBrowsingServices.cs @@ -36,6 +36,16 @@ namespace CoreCms.Net.Services _unitOfWork = unitOfWork; } + /// + /// 根据用户序列获取用户的足迹数量 + /// + /// + /// + public async Task GetUserCountAsync(int userId) + { + return await _dal.GetUserCountAsync(userId); + } + /// /// 重写根据条件查询分页数据 /// diff --git a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs index 0d765689..629a819c 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs @@ -839,7 +839,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers //订单数量 var orderCount = await _orderServices.OrderCount(0, user.id); //足迹 - var footPrintCount = await _goodsBrowsingServices.GetCountAsync(p => p.userId == user.id); + var footPrintCount = await _goodsBrowsingServices.GetUserCountAsync(user.id); //收藏 var collectionCount = await _goodsCollectionServices.GetCountAsync(p => p.userId == user.id);