fix 控制特殊处理

This commit is contained in:
2024-11-28 22:43:38 +08:00
parent 87e27a669e
commit 88f0a9ac9c

View File

@@ -10,13 +10,22 @@ public class AssignPermissionLimitAttribute : Attribute, IAsyncActionFilter
{
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
var redisCache = context.HttpContext.RequestServices.GetRequiredService<RedisCache>();
//10966 55184
var currentUser = context.HttpContext.RequestServices.GetRequiredService<ICurrentUser>();
var userId = currentUser.GetIntSubjectId();
if (userId is 10966 or 55184)
{
await next();
}
else
{
var redisCache = context.HttpContext.RequestServices.GetRequiredService<RedisCache>();
var currentTenantId = currentUser.GetStringTenantId();
var currentTenantId = currentUser.GetStringTenantId();
await using var handler = await redisCache.LockAsync($"permission:generate:{currentTenantId}");
handler.Acquired.ThrowIfFalse("请勿频繁分配");
await next();
await using var handler = await redisCache.LockAsync($"permission:generate:{currentTenantId}");
handler.Acquired.ThrowIfFalse("请勿频繁分配");
await next();
}
}
}