update:路由权限判断放到userManager中

This commit is contained in:
2021-06-28 17:12:14 +08:00
parent 6178ac5059
commit b6822e3364
4 changed files with 13 additions and 3 deletions

View File

@@ -21,5 +21,6 @@ namespace Ewide.Core
Task<List<string>> GetUserRoleIdList();
Task<List<SysRole>> GetUserRoleList(string userId);
Task<List<SysRole>> GetUserRoleList();
Task<List<string>> GetLoginPermissionList();
}
}

View File

@@ -6,6 +6,7 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using Ewide.Core.Service;
namespace Ewide.Core
{
@@ -20,6 +21,7 @@ namespace Ewide.Core
private readonly IRepository<SysEmp> _sysEmpRep; // 员工表
private readonly IRepository<SysOrg> _sysOrgRep;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISysMenuService _sysMenuService;
public string UserId
{
@@ -52,7 +54,8 @@ namespace Ewide.Core
IRepository<SysUserRole> sysUserRoleRep,
IRepository<SysEmp> sysEmpRep,
IRepository<SysOrg> sysOrgRep,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
ISysMenuService sysMenuService)
{
_sysUserRep = sysUserRep;
_sysRoleRep = sysRoleRep;
@@ -60,6 +63,7 @@ namespace Ewide.Core
_sysEmpRep = sysEmpRep;
_sysOrgRep = sysOrgRep;
_httpContextAccessor = httpContextAccessor;
_sysMenuService = sysMenuService;
}
/// <summary>
@@ -163,5 +167,10 @@ namespace Ewide.Core
{
return await GetUserRoleList(UserId);
}
public Task<List<string>> GetLoginPermissionList()
{
return _sysMenuService.GetLoginPermissionList(UserId);
}
}
}

View File

@@ -69,7 +69,7 @@ namespace Ewide.Web.Core
if (defalutRoute.Contains(routeName)) return true;
// 获取用户权限集合按钮或API接口
var permissionList = await App.GetService<ISysMenuService>().GetLoginPermissionList(userManager.UserId);
var permissionList = await userManager.GetLoginPermissionList();
// 检查授权
return permissionList.Contains(routeName);