diff --git a/src/Oms.Application/DataPerm/DataScopeModels.cs b/src/Oms.Application/DataPerm/DataScopeModels.cs index cde9293..2e24d90 100644 --- a/src/Oms.Application/DataPerm/DataScopeModels.cs +++ b/src/Oms.Application/DataPerm/DataScopeModels.cs @@ -14,17 +14,17 @@ public sealed class DataScopeContext public string DataResourceCode { get; init; } = string.Empty; - public IReadOnlySet OrganizationIds { get; init; } = new HashSet(); + public HashSet OrganizationIds { get; init; } = []; public int DataScope { get; init; } = DataPermConstants.DataScopePersonal; - public IReadOnlyList ResolvedOwnerIds { get; init; } = []; + public List ResolvedOwnerIds { get; init; } = []; - public IReadOnlyDictionary? BizFilters { get; init; } + public Dictionary? BizFilters { get; init; } - public IReadOnlySet SecretLevels { get; init; } = new HashSet(DataPermConstants.DefaultSecretLevels); + public HashSet SecretLevels { get; init; } = [.. DataPermConstants.DefaultSecretLevels]; - public IReadOnlyList CustomFilters { get; init; } = []; + public List CustomFilters { get; init; } = []; } public sealed class CompiledFilter diff --git a/src/Oms.Application/DataPerm/EffectiveScopeBuilder.cs b/src/Oms.Application/DataPerm/EffectiveScopeBuilder.cs index a7d0fba..d0da508 100644 --- a/src/Oms.Application/DataPerm/EffectiveScopeBuilder.cs +++ b/src/Oms.Application/DataPerm/EffectiveScopeBuilder.cs @@ -22,7 +22,15 @@ public class DataPermContextCache(IDistributedCache cache) : IScopedDependency return null; } - return JsonSerializer.Deserialize(bytes, JsonOptions); + try + { + return JsonSerializer.Deserialize(bytes, JsonOptions); + } + catch (JsonException) + { + // 旧缓存或类型变更导致反序列化失败时重建 + return null; + } } public Task SetAsync(DataScopeContext context, CancellationToken cancellationToken = default) @@ -212,7 +220,7 @@ public class EffectiveScopeBuilder(DataPermRepository repository, DataPermContex }) .ToList(); - IReadOnlyList resolvedOwnerIds = []; + List resolvedOwnerIds = []; if (dataScope is DataPermConstants.DataScopeTeam or DataPermConstants.DataScopeDepartment) { if (user.OrganizationId is not { } ownerOrg || ownerOrg == Guid.Empty)