From 13beca328de9f0bbf73c18a4d2302db2012103c0 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 16 Aug 2024 15:58:11 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=9F=A5=E8=AF=A2=E6=A1=A3=E6=A1=88?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E6=89=80=E5=9C=A8=E7=9A=84=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/GainfoGroupsController.cs | 13 ++++++++++- .../Services/IGainfoGroupService.cs | 2 ++ .../Services/Implements/GainfoGroupService.cs | 23 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs index ddcf6acc..1df53980 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfoGroupsController.cs @@ -56,6 +56,17 @@ public class GainfoGroupsController : ControllerBase return await _gainfoGroupService.GetGainfosByGroupAsync(code); } + /// + /// 根据userCode获取分配的分组 + /// + /// + /// + [HttpGet("groups")] + public async Task> GetGainfoGroupsByUserCodeAsync(string userCode) + { + return await _gainfoGroupService.GetGainfoGroupsByUserCodeAsync(userCode); + } + /// /// 分配人员 /// @@ -69,4 +80,4 @@ public class GainfoGroupsController : ControllerBase { await _gainfoGroupService.AssignGainfosAsync(request); } -} +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoGroupService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoGroupService.cs index d9b2801e..258089ec 100644 --- a/Src/Dlhis.Basic/Organization/Services/IGainfoGroupService.cs +++ b/Src/Dlhis.Basic/Organization/Services/IGainfoGroupService.cs @@ -12,4 +12,6 @@ public interface IGainfoGroupService : IScopeDependency Task> GetGainfosByGroupAsync(Guid code); Task AssignGainfosAsync(GainfoAssignRequest request); + + Task> GetGainfoGroupsByUserCodeAsync(string userCode); } diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs index d6429595..f9f0e50b 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs @@ -101,6 +101,29 @@ public class GainfoGroupService : IGainfoGroupService }, null); } + + public async Task> GetGainfoGroupsByUserCodeAsync(string userCode) + { + var gainfo = await _dbContext.Queryable().Where(x => x.Code == userCode).SingleAsync(); + var userNo = gainfo?.No; + + return await _dbContext.Queryable() + .LeftJoin((x, r) => x.Code == r.GroupCode) + .Where((x, r) => r.UserNo == userNo) + .Select(x => new GainfoGroupTreeResponse + { + Id = x.Id, + PCode = x.PCode, + Code = x.Code, + Name = x.Name, + Remark = x.Remark, + Editable = x.Editable, + IsDefault = x.IsDefault, + TenantId = x.TenantId + }) + .ToListAsync(); + } + //******************************************************* help methods *********************************************************** ///