From 2ca8f2db49e0a80caa4ec6c2142a144a18b37535 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 21 Mar 2024 16:22:47 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DishesCategoriesController.cs | 14 ++++++++++ .../Controller/DishesMenusController.cs | 1 + .../Dishes/Services/IDishesCategoryService.cs | 4 +++ .../Implements/DishesCategoryService.cs | 26 +++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs b/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs index 7370ebe9..12e48ba9 100644 --- a/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs +++ b/Src/Dlhis.Basic/Dishes/Controller/DishesCategoriesController.cs @@ -1,6 +1,7 @@ using Dlhis.Basic.Dishes.Request; using Dlhis.Basic.Dishes.Response; using Dlhis.Basic.Dishes.Services; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -31,6 +32,19 @@ public class DishesCategoriesController : ControllerBase return await _dishesCategoryService.TreeAsync(); } + + /// + /// + /// + /// + /// + [HttpGet("tree-all")] + [IgnoreTenant] + public async Task> TreeAllAsync(Guid businessPlaceCode) + { + return await _dishesCategoryService.TreeAllAsync(businessPlaceCode); + } + /// /// 保存分类 /// diff --git a/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs b/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs index de956b28..867d0e4e 100644 --- a/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs +++ b/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs @@ -60,6 +60,7 @@ public class DishesMenusController : ControllerBase /// /// [HttpGet("dishes-selections")] + [IgnoreTenant] public async Task> GetDishesUnderCurrentMenuAsync(Guid businessPlaceCode, DateTime date, ShiftEnumType? shiftType, diff --git a/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs b/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs index 2164e5e0..637c93ed 100644 --- a/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs @@ -7,5 +7,9 @@ public interface IDishesCategoryService : IScopeDependency { Task> TreeAsync(); + + Task> TreeAllAsync(Guid businessPlaceCode); + + Task SaveAsync(DishesCategorySaveRequest request); } diff --git a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs index 58e2b6b2..528c33d6 100644 --- a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs @@ -46,6 +46,32 @@ public class DishesCategoryService : IDishesCategoryService return tops; } + public async Task> TreeAllAsync(Guid businessPlaceCode) + { + var categories = await _dbContext.Queryable() + .LeftJoin((x, bplace) => x.BusinessPlaceCode == bplace.Code) + .Where(x => x.BusinessPlaceCode == businessPlaceCode) + .Select((x, bplace) => new DishesCategoryTreeResponse + { + BusinessPlaceCode = bplace.Code, + Code = x.Code, + Name = x.Name, + PCode = x.PCode, + }) + .ToListAsync(); + + var tops = categories.Where(x => !x.PCode.HasValue).ToList(); + + tops.ForEach(x => + { + RecursionGetNext(x, categories); + }); + + return tops; + } + + + public async Task SaveAsync(DishesCategorySaveRequest request) { await CheckBusinessPlacePermissionAsync(request.BusinessPlaceCode);