12 changed files with 187 additions and 40 deletions
0
aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain/DataDictionaries/Exceptions/DataDictionaryDomainException.cs → aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain.Shared/DataDictionaries/DataDictionaryDomainException.cs
0
aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain/DataDictionaries/Exceptions/DataDictionaryDomainException.cs → aspnet-core/modules/DataDictionaryManagement/src/CompanyName.ProjectName.DataDictionaryManagement.Domain.Shared/DataDictionaries/DataDictionaryDomainException.cs
@ -0,0 +1,40 @@ |
|||
using System; |
|||
|
|||
namespace CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Dto |
|||
{ |
|||
public class DataDictionaryDetailDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 所属字典Id
|
|||
/// </summary>
|
|||
public Guid DataDictionaryId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字典明细编码
|
|||
/// </summary>
|
|||
public string Code { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 展现列表时排序用
|
|||
/// </summary>
|
|||
public int Order { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 英文显示名
|
|||
/// </summary>
|
|||
public string DisplayText { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 描述
|
|||
/// </summary>
|
|||
public string Description { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 启/停用(默认启用)
|
|||
/// </summary>
|
|||
public bool IsEnabled { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Dto |
|||
{ |
|||
public class DataDictionaryDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 租户id
|
|||
/// </summary>
|
|||
public Guid? TenantId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字典编码
|
|||
/// </summary>
|
|||
public string Code { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 显示名
|
|||
/// </summary>
|
|||
public string DisplayText { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 描述
|
|||
/// </summary>
|
|||
public string Description { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字典明细集合
|
|||
/// </summary>
|
|||
public List<DataDictionaryDetailDto> Details { get; set; } |
|||
|
|||
public DataDictionaryDto() |
|||
{ |
|||
Details = new List<DataDictionaryDetailDto>(); |
|||
} |
|||
|
|||
private const string CacheKeyFormat = "i:{0},c:{1}"; |
|||
|
|||
public static string CalculateCacheKey(Guid? id, string code) |
|||
{ |
|||
return string.Format(CacheKeyFormat, |
|||
id?.ToString() ?? "null", |
|||
(code.IsNullOrWhiteSpace() ? "null" : code)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System.Threading.Tasks; |
|||
using CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Aggregates; |
|||
using CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Dto; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Entities.Events; |
|||
using Volo.Abp.EventBus; |
|||
|
|||
namespace CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Caches |
|||
{ |
|||
public class DataDictionaryCacheItemInvalidator : |
|||
ILocalEventHandler<EntityChangedEventData<DataDictionary>>, |
|||
ITransientDependency |
|||
{ |
|||
private readonly IDistributedCache<DataDictionaryDto> _cache; |
|||
|
|||
public DataDictionaryCacheItemInvalidator(IDistributedCache<DataDictionaryDto> cache) |
|||
{ |
|||
_cache = cache; |
|||
} |
|||
|
|||
public async Task HandleEventAsync(EntityChangedEventData<DataDictionary> eventData) |
|||
{ |
|||
await _cache.RemoveAsync( |
|||
DataDictionaryDto.CalculateCacheKey(eventData.Entity.Id, eventData.Entity.Code)); |
|||
await _cache.RemoveAsync( |
|||
DataDictionaryDto.CalculateCacheKey(eventData.Entity.Id, null)); |
|||
await _cache.RemoveAsync( |
|||
DataDictionaryDto.CalculateCacheKey(null, eventData.Entity.Code)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using AutoMapper; |
|||
using CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Aggregates; |
|||
using CompanyName.ProjectName.DataDictionaryManagement.DataDictionaries.Dto; |
|||
|
|||
namespace CompanyName.ProjectName.DataDictionaryManagement |
|||
{ |
|||
public class DataDictionaryDomainAutoMapperProfile : Profile |
|||
{ |
|||
public DataDictionaryDomainAutoMapperProfile() |
|||
{ |
|||
CreateMap<DataDictionary, DataDictionaryDto>(); |
|||
CreateMap<DataDictionaryDetail, DataDictionaryDetailDto>(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue