update:根据权限筛选区域目录树

This commit is contained in:
2021-05-31 18:12:48 +08:00
parent 05ab0ec335
commit 5ab69ff61f
6 changed files with 58 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
using Ewide.Core.Service.Area;
using Ewide.Core.Service;
using Ewide.Core.Service.Area;
using Ewide.Core.Service.Area.Dto;
using Furion.DynamicApiController;
using Mapster;
@@ -18,10 +19,13 @@ namespace Ewide.Core.Controller
public class AreaCodeController : IDynamicApiController
{
private readonly IAreaCodeService _areaCodeService;
public AreaCodeController(IAreaCodeService areaCodeService)
private readonly ISysUserService _sysUserService;
private readonly IUserManager _userManager;
public AreaCodeController(IAreaCodeService areaCodeService, IUserManager userManager, ISysUserService sysUserService)
{
_areaCodeService = areaCodeService;
_userManager = userManager;
_sysUserService = sysUserService;
}
/// <summary>
/// 查询
@@ -81,7 +85,13 @@ namespace Ewide.Core.Controller
[HttpGet("/sysArea/tree")]
public async Task<List<AreaTreeNode>> GetAreaCodeTree([FromQuery]int? level)
{
return await _areaCodeService.GetAreaCodeTree(level);
List<string> areaCodeList = null;
if (!_userManager.SuperAdmin)
{
var orgIdList = await _sysUserService.GetUserDataScopeIdList(_userManager.UserId);
areaCodeList = await _areaCodeService.GetAreaCodeListByOrgId(orgIdList);
}
return await _areaCodeService.GetAreaCodeTree(level, areaCodeList);
}
}
}