From 7407955bc5d01641dda7c2c76ebb6409f8b8b83f Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 21 Mar 2024 21:14:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=88=86=E7=B1=BB=E6=A0=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=90=A5=E4=B8=9A=E7=82=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DishesCategoriesController.cs | 7 +++--- .../Dishes/Services/IDishesCategoryService.cs | 2 +- .../Implements/DishesCategoryService.cs | 3 ++- .../Services/Implements/DishesService.cs | 22 ++++++++++++++++--- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs b/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs index 12e48ba9..fd642e4c 100644 --- a/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs +++ b/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs @@ -25,16 +25,17 @@ public class DishesCategoriesController : ControllerBase /// /// 获取分类树 /// + /// /// [HttpGet("tree")] - public async Task> TreeAsync() + public async Task> TreeAsync(Guid businessPlaceCode) { - return await _dishesCategoryService.TreeAsync(); + return await _dishesCategoryService.TreeAsync(businessPlaceCode); } /// - /// + /// 获取分类树(无权限) /// /// /// diff --git a/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs b/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs index 637c93ed..09d738d8 100644 --- a/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs @@ -5,7 +5,7 @@ namespace Dlhis.Basic.Dishes.Services; public interface IDishesCategoryService : IScopeDependency { - Task> TreeAsync(); + Task> TreeAsync(Guid businessPlaceCode); Task> TreeAllAsync(Guid businessPlaceCode); diff --git a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs index 528c33d6..9a36e161 100644 --- a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs @@ -20,9 +20,10 @@ public class DishesCategoryService : IDishesCategoryService _businessPlacePermissionsService = businessPlacePermissionsService; } - public async Task> TreeAsync() + public async Task> TreeAsync(Guid businessPlaceCode) { var mybCodes = await GetMyBusinessPlaceCodesAsync(); + mybCodes = mybCodes.Where(x => x == businessPlaceCode).ToList(); var categories = await _dbContext.Queryable() .LeftJoin((x, bplace) => x.BusinessPlaceCode == bplace.Code) diff --git a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs index d3fbf30c..7810608e 100644 --- a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs @@ -1,4 +1,5 @@ -using Dlhis.Basic.Dishes.Request; +using Dlhis.Basic.BusinessPlace.Services; +using Dlhis.Basic.Dishes.Request; using Dlhis.Basic.Dishes.Response; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Canteen.Entities; @@ -16,21 +17,24 @@ public class DishesService : IDishesService { private readonly IDbContext _dbContext; private readonly ICurrentUser _currentUser; + private readonly IBusinessPlacePermissionsService _businessPlacePermissionsService; - public DishesService(IDbContext dbContext, ICurrentUser currentUser) + public DishesService(IDbContext dbContext, ICurrentUser currentUser, IBusinessPlacePermissionsService businessPlacePermissionsService) { _dbContext = dbContext; _currentUser = currentUser; + _businessPlacePermissionsService = businessPlacePermissionsService; } public async Task> GetDishesPageAsync(DishesPageRequest request) { - //todo 营业点权限 + var myCodes = await GetMyBusinessPlaceCodesAsync(); return await _dbContext.Queryable() .LeftJoin((x, category) => x.CategoryCode == category.Code) .WhereIF(request.Search.IsPresent(), x => x.CustomCode == request.Search || x.Name.Contains(request.Search)) .WhereIF(request.BusinessPlaceCodes.IsPresent(), x => request.BusinessPlaceCodes.Contains(x.BusinessPlaceCode)) + .Where(x => myCodes.Contains(x.BusinessPlaceCode)) .OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc) .Select((x, category) => new DishesResponse { @@ -109,5 +113,17 @@ public class DishesService : IDishesService .Select() .SingleAsync(); } + + + + + /// + /// 获取我的营业点 + /// + /// + private async Task> GetMyBusinessPlaceCodesAsync() + { + return (await _businessPlacePermissionsService.GetMyAsync()).Select(x => x.Code).ToList(); + } }