From 03b73515b50902f91c1b582d9aa91b716247355c Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 20 Mar 2024 10:59:08 +0800 Subject: [PATCH] =?UTF-8?q?fix=20tree=E8=BF=94=E5=9B=9E=E8=90=A5=E4=B8=9A?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dishes/Response/DishesCategoryResponse.cs | 5 +++++ .../Services/Implements/DishesCategoryService.cs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Basic/Dishes/Response/DishesCategoryResponse.cs b/Src/Dlhis.Basic/Dishes/Response/DishesCategoryResponse.cs index fdaca520..024d2606 100644 --- a/Src/Dlhis.Basic/Dishes/Response/DishesCategoryResponse.cs +++ b/Src/Dlhis.Basic/Dishes/Response/DishesCategoryResponse.cs @@ -2,6 +2,11 @@ public class DishesCategoryTreeResponse { + /// + /// 营业点code + /// + public Guid BusinessPlaceCode { get; set; } + public Guid? PCode { get; set; } public Guid Code { get; set; } diff --git a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs index 8fda1dc2..18f1f8e9 100644 --- a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesCategoryService.cs @@ -1,5 +1,6 @@ using Dlhis.Basic.Dishes.Request; using Dlhis.Basic.Dishes.Response; +using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Canteen.Entities; using Kurisu.AspNetCore.Utils.Extensions; using Kurisu.SqlSugar.Services; @@ -18,7 +19,17 @@ public class DishesCategoryService : IDishesCategoryService public async Task> TreeAsync() { - var categories = await _dbContext.Queryable().Select().ToListAsync(); + var categories = await _dbContext.Queryable() + .LeftJoin((x, bplace) => x.BusinessPlaceCode == bplace.Code) + .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 =>