refactor: 更改 IDict 方法为 ExistsAppId

This commit is contained in:
Argo-Tianyi 2022-01-14 23:30:18 +08:00
parent e7b8a9ef51
commit 8ec06d9199
3 changed files with 5 additions and 5 deletions

View File

@ -411,9 +411,9 @@ class DictService : IDict
return dicts.Where(s => s.Category == "应用首页" && s.Name == name).FirstOrDefault()?.Code ?? "";
}
public string? GetAppNameByAppName(string name)
public bool ExistsAppId(string appId)
{
var dicts = GetAll();
return dicts.Where(s => s.Category == "应用程序" && s.Code == name).FirstOrDefault()?.Name;
return dicts.Exists(s => s.Category == "应用程序" && s.Code == appId);
}
}

View File

@ -371,5 +371,5 @@ public interface IDict
/// 获得前台应用
/// </summary>
/// <returns></returns>
string? GetAppNameByAppName(string name);
bool ExistsAppId(string appId);
}

View File

@ -29,8 +29,8 @@ public class AppIdValidator : IValidator
/// <param name="results"></param>
public void Validate(object? propertyValue, ValidationContext context, List<ValidationResult> results)
{
var AppName = DictService.GetAppNameByAppName(propertyValue?.ToString()!);
if (!string.IsNullOrEmpty(AppName))
var check = DictService.ExistsAppId(propertyValue?.ToString()!);
if (check)
{
ErrorMessage = $"{context.DisplayName}已存在";
}