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 *********************************************************** ///