通用对象查询封装、权限封装

This commit is contained in:
橙子
2022-05-04 15:54:40 +08:00
parent b934ce2893
commit 3994f14010
9 changed files with 46 additions and 61 deletions

View File

@@ -3,6 +3,7 @@ using Microsoft.IdentityModel.JsonWebTokens;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Yi.Framework.WebCore.AttributeExtend
@@ -40,11 +41,21 @@ namespace Yi.Framework.WebCore.AttributeExtend
var perList = context.HttpContext.User.Claims.Where(u => u.Type == "permission").Select(u=> u.Value.ToString().ToLower()). ToList();
//判断权限是否存在Redis中,或者jwt中
//if (perList.Contains(permission.ToLower()))
//{
// result = true;
//}
result = true;
//进行正则表达式的匹配
Regex regex = new Regex($"{permission.ToLower()}");
foreach (var p in perList)
{
if (regex.IsMatch(p))
{
result = true;
break;
}
}
//用户的增删改查直接可以user:*即可
//这里暂时全部放行即可
result = true;
if (!result)