Dun.Jason пре 1 година
родитељ
комит
9b44573f22

+ 25 - 1
src/Hotline.Api/Controllers/OrgController.cs

@@ -6,6 +6,7 @@ using MapsterMapper;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using System.Threading.Channels;
+using XF.Domain.Authentications;
 using XF.Domain.Exceptions;
 using XF.Utility.EnumExtensions;
 
@@ -20,17 +21,21 @@ namespace Hotline.Api.Controllers
         private readonly ISystemDomainService _systemDomainService;
         private readonly ISystemAreaDomainService _areaDomainService;
         private readonly IMapper _mapper;
+        private readonly ISessionContext _sessionContext;
+
 
         public OrgController(
             ISystemOrganizeRepository systemOrganizeRepository,
             ISystemDomainService systemDomainService,
             ISystemAreaDomainService areaDomainService,
-            IMapper mapper)
+            IMapper mapper,
+            ISessionContext sessionContext)
         {
             _systemOrganizeRepository = systemOrganizeRepository;
             _systemDomainService = systemDomainService;
             _areaDomainService = areaDomainService;
             _mapper = mapper;
+            _sessionContext = sessionContext;
         }
 
         /// <summary>
@@ -160,6 +165,25 @@ namespace Hotline.Api.Controllers
             return await _systemOrganizeRepository.GetCanUseOrg();
         }
 
+
+        /// <summary>
+        /// 获取可用组织架构树形(用户管理)
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet("getcanuseorgforuser")]
+        public async Task<IReadOnlyList<SystemOrganize>> GetCanUseOrgForUser()
+        {
+            if (_sessionContext.OrgIsCenter)
+            {
+                return await _systemOrganizeRepository.GetCanUseOrg();
+            }
+            else
+            {
+                return await _systemOrganizeRepository.GetCanUseOrgByUser();
+            }
+        }
+
+
         /// <summary>
         /// 新增页面基础数据
         /// </summary>

+ 1 - 0
src/Hotline.Api/Controllers/UserController.cs

@@ -157,6 +157,7 @@ public class UserController : BaseController
              .Includes(d => d.Roles)
              .Includes(d => d.Organization)
              .Where(d => d.Account.AccountType == EAccountType.Personal && d.Id != SysAccountSeedData.Id)
+             .WhereIF(_sessionContext.OrgIsCenter==false,d=>d.OrgId.StartsWith(_sessionContext.RequiredOrgId))
              .WhereIF(!string.IsNullOrEmpty(dto.Keyword),
                  d => d.Name.Contains(dto.Keyword!) || d.PhoneNo.Contains(dto.Keyword!) || d.Account.UserName.Contains(dto.Keyword))
              .WhereIF(!string.IsNullOrEmpty(dto.OrgCode), d => d.OrgId == dto.OrgCode)

+ 8 - 0
src/Hotline.Repository.SqlSugar/System/SystemOrganizeRepository.cs

@@ -29,6 +29,14 @@ namespace Hotline.Repository.SqlSugar.System
             return list;
         }
 
+        public async Task<IReadOnlyList<SystemOrganize>> GetCanUseOrgByOrgCode(string orgCode)
+        {
+            var list = await Db.Queryable<SystemOrganize>()
+                .Where(x => x.IsEnable && x.Id.StartsWith(orgCode))
+                .ToTreeAsync(x => x.Children, it => it.ParentId, null);
+            return list;
+        }
+
         //public async Task<string> GetNewOrgCode(string parentId)
         //{
         //    //查是否存在下级

+ 2 - 2
src/Hotline/Orders/OrderVisitDetail.cs

@@ -41,9 +41,9 @@ namespace Hotline.Orders
         ///// <summary>
         ///// 未处理内容
         ///// </summary>
-        //public string VolveConent { get; set; }
+        //public string? VolveConent { get; set; }
 
-        public string RecordUrl { get; set; }
+        //public string? RecordUrl { get; set; }
 
 
         /// <summary>

+ 2 - 0
src/Hotline/Settings/ISystemOrganizeRepository.cs

@@ -9,6 +9,8 @@ namespace Hotline.Settings
 
         Task<IReadOnlyList<SystemOrganize>> GetCanUseOrg();
 
+        Task<IReadOnlyList<SystemOrganize>> GetCanUseOrgByUser();
+
         //Task<string> GetNewOrgCode(string? parentId);
     }
 }