refactor: 更改 IDict 方法为 ExistsAppId
This commit is contained in:
parent
e7b8a9ef51
commit
8ec06d9199
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,5 +371,5 @@ public interface IDict
|
|||
/// 获得前台应用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string? GetAppNameByAppName(string name);
|
||||
bool ExistsAppId(string appId);
|
||||
}
|
||||
|
|
|
@ -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}已存在";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue