feat:完成后端数据权限过滤

This commit is contained in:
陈淳
2023-05-22 12:57:27 +08:00
parent ad6bd8f39b
commit 327a7b2a48
14 changed files with 167 additions and 15 deletions

View File

@@ -20,6 +20,9 @@ namespace Yi.Framework.Infrastructure.CurrentUsers
public long Id => FindUserId();
public long DeptId => FindDeptId();
public string UserName => this.FindClaimValue(TokenTypeConst.UserName);
/// <summary>
@@ -59,7 +62,21 @@ namespace Yi.Framework.Infrastructure.CurrentUsers
return FindClaim(claimType)?.Value;
}
public long FindDeptId()
{
var deptIdOrNull = _principalAccessor.Principal?.Claims?.FirstOrDefault(c => c.Type == TokenTypeConst.DeptId);
if (deptIdOrNull == null || string.IsNullOrWhiteSpace(deptIdOrNull.Value))
{
return 0;
}
if (long.TryParse(deptIdOrNull.Value, out long deptId))
{
return deptId;
}
return 0;
}
public long FindUserId()
{
var userIdOrNull = _principalAccessor.Principal?.Claims?.FirstOrDefault(c => c.Type == TokenTypeConst.Id);