Merge pull request '🍒 fix: 修复按钮权限问题; 修复枚举校验异常问题; 代码优化' (#439) from jasondom/Admin.NET.Pro:v2 into v2
Reviewed-on: https://code.adminnet.top/Admin.NET/Admin.NET.Pro/pulls/439
This commit is contained in:
commit
7879c315cb
@ -54,8 +54,7 @@ public class DictAttribute : ValidationAttribute, ITransient
|
|||||||
private async Task<ValidationResult> IsValidAsync(object? value, ValidationContext validationContext, CancellationToken cancellation)
|
private async Task<ValidationResult> IsValidAsync(object? value, ValidationContext validationContext, CancellationToken cancellation)
|
||||||
{
|
{
|
||||||
// 1. 空值检查
|
// 1. 空值检查
|
||||||
if (IsEmpty(value))
|
if (IsEmpty(value)) return ValidationResult.Success;
|
||||||
return ValidationResult.Success;
|
|
||||||
|
|
||||||
// 2. 获取属性类型
|
// 2. 获取属性类型
|
||||||
var property = validationContext.ObjectType.GetProperty(validationContext.MemberName!);
|
var property = validationContext.ObjectType.GetProperty(validationContext.MemberName!);
|
||||||
@ -81,7 +80,7 @@ public class DictAttribute : ValidationAttribute, ITransient
|
|||||||
// 6. 单选校验
|
// 6. 单选校验
|
||||||
if (!Multiple)
|
if (!Multiple)
|
||||||
{
|
{
|
||||||
var valStr = value?.ToString();
|
var valStr = value!.GetType().IsEnum ? value.ToInt().ToString() : value.ToString();
|
||||||
if (string.IsNullOrEmpty(valStr) || !dictHashSet.Contains(valStr))
|
if (string.IsNullOrEmpty(valStr) || !dictHashSet.Contains(valStr))
|
||||||
{
|
{
|
||||||
return new ValidationResult($"提示:{ErrorMessage}|字典【{DictTypeCode}】不包含【{value}】!");
|
return new ValidationResult($"提示:{ErrorMessage}|字典【{DictTypeCode}】不包含【{value}】!");
|
||||||
@ -108,7 +107,7 @@ public class DictAttribute : ValidationAttribute, ITransient
|
|||||||
{
|
{
|
||||||
foreach (var item in listValue)
|
foreach (var item in listValue)
|
||||||
{
|
{
|
||||||
var itemStr = item?.ToString();
|
var itemStr = item.GetType().IsEnum ? item.ToInt().ToString() : item.ToString();
|
||||||
if (string.IsNullOrEmpty(itemStr) || !dictHashSet.Contains(itemStr))
|
if (string.IsNullOrEmpty(itemStr) || !dictHashSet.Contains(itemStr))
|
||||||
{
|
{
|
||||||
return new ValidationResult($"提示:{ErrorMessage}|字典【{DictTypeCode}】不包含【{item}】!");
|
return new ValidationResult($"提示:{ErrorMessage}|字典【{DictTypeCode}】不包含【{item}】!");
|
||||||
|
|||||||
@ -42,6 +42,7 @@ public class ElasticSearchLoggingWriter : IDatabaseLoggingWriter, IDisposable
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// 获取当前操作者
|
// 获取当前操作者
|
||||||
|
var userManager = LazyHelper.GetService<UserManager>();
|
||||||
string account = "", realName = "", userId = "", tenantId = "";
|
string account = "", realName = "", userId = "", tenantId = "";
|
||||||
if (loggingMonitor.authorizationClaims != null)
|
if (loggingMonitor.authorizationClaims != null)
|
||||||
{
|
{
|
||||||
@ -50,7 +51,7 @@ public class ElasticSearchLoggingWriter : IDatabaseLoggingWriter, IDisposable
|
|||||||
{
|
{
|
||||||
if (item.type != ClaimConst.UserId) continue;
|
if (item.type != ClaimConst.UserId) continue;
|
||||||
userId = item.value;
|
userId = item.value;
|
||||||
userSession = LazyHelper.GetService<UserManager>().GetSessionOrRefresh(userId);
|
userSession = userManager.GetSessionOrRefresh(userId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tenantId = userSession?.TenantId.ToString();
|
tenantId = userSession?.TenantId.ToString();
|
||||||
|
|||||||
@ -416,6 +416,8 @@ public class SysRoleService : IDynamicApiController, ITransient
|
|||||||
else apiList.Add(item.Route);
|
else apiList.Add(item.Route);
|
||||||
item = queue.Count > 0 ? queue.Dequeue() : null;
|
item = queue.Count > 0 ? queue.Dequeue() : null;
|
||||||
}
|
}
|
||||||
|
var allButtonList = await GetButtonList();
|
||||||
|
apiList.AddRange(allButtonList);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user