😎代码优化
This commit is contained in:
parent
b735a52647
commit
2b917963b9
@ -69,11 +69,11 @@ public class DictAttribute : ValidationAttribute, ITransient
|
||||
}
|
||||
|
||||
// 先尝试从 ValidationContext 的依赖注入容器中拿服务,拿不到或类型不匹配时,再从全局的 App 容器中获取
|
||||
if (validationContext.GetService(typeof(SysDictTypeService)) is not SysDictTypeService sysDictDataService)
|
||||
sysDictDataService = App.GetRequiredService<SysDictTypeService>();
|
||||
if (validationContext.GetService(typeof(SysDictDataService)) is not SysDictDataService sysDictDataService)
|
||||
sysDictDataService = App.GetRequiredService<SysDictDataService>();
|
||||
|
||||
// 获取字典值列表
|
||||
var dictDataList = sysDictDataService.GetDataList(new GetDataDictTypeInput { Code = DictTypeCode }).GetAwaiter().GetResult();
|
||||
var dictDataList = sysDictDataService.GetDataList(DictTypeCode).GetAwaiter().GetResult();
|
||||
|
||||
// 使用 HashSet 来提高查找效率
|
||||
var dictHash = new HashSet<string>(dictDataList.Select(u => u.Code));
|
||||
|
||||
@ -7,9 +7,9 @@
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
/// <summary>
|
||||
/// 系统参数配置表
|
||||
/// 系统配置参数表
|
||||
/// </summary>
|
||||
[SugarTable(null, "系统参数配置表")]
|
||||
[SugarTable(null, "系统配置参数表")]
|
||||
[SysTable]
|
||||
[SugarIndex("index_{table}_N", nameof(Name), OrderByType.Asc)]
|
||||
[SugarIndex("index_{table}_C", nameof(Code), OrderByType.Asc, IsUnique = true)]
|
||||
@ -30,9 +30,9 @@ public partial class SysConfig : EntityBase
|
||||
public string? Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 属性值
|
||||
/// 参数值
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "属性值", Length = 512)]
|
||||
[SugarColumn(ColumnDescription = "参数值", Length = 512)]
|
||||
[MaxLength(512)]
|
||||
public string? Value { get; set; }
|
||||
|
||||
|
||||
@ -364,11 +364,9 @@ public class SysDatabaseService : IDynamicApiController, ITransient
|
||||
if (pkInfo != null)
|
||||
{
|
||||
var seedDataTypes = App.EffectiveTypes
|
||||
.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(
|
||||
i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>)) && i.GenericTypeArguments[0] == entityTypes[0]
|
||||
)
|
||||
)
|
||||
.ToList();
|
||||
.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces()
|
||||
.Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>)) && i.GenericTypeArguments[0] == entityTypes[0])
|
||||
).ToList();
|
||||
// 可能会重名的种子数据不作为过滤项
|
||||
string doNotFilterFullName1 = $"{input.Position}.SeedData.{input.SeedDataName}";
|
||||
string doNotFilterFullName2 = $"{input.Position}.{input.SeedDataName}"; // Core中的命名空间没有SeedData
|
||||
|
||||
@ -58,7 +58,6 @@ public class SysDictTypeService : IDynamicApiController, ITransient
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[UnitOfWork]
|
||||
[DisplayName("获取字典类型-值列表")]
|
||||
public async Task<List<SysDictData>> GetDataList([FromQuery] GetDataDictTypeInput input)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user