feat: 新增配置管理
This commit is contained in:
@@ -6,20 +6,20 @@ using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Yi.Framework.SettingManagement.Domain;
|
||||
|
||||
public interface ISettingRepository : IBasicRepository<SettingEntity, Guid>
|
||||
public interface ISettingRepository : IBasicRepository<SettingAggregateRoot, Guid>
|
||||
{
|
||||
Task<SettingEntity> FindAsync(
|
||||
Task<SettingAggregateRoot> FindAsync(
|
||||
string name,
|
||||
string providerName,
|
||||
string providerKey,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<List<SettingEntity>> GetListAsync(
|
||||
Task<List<SettingAggregateRoot>> GetListAsync(
|
||||
string providerName,
|
||||
string providerKey,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<List<SettingEntity>> GetListAsync(
|
||||
Task<List<SettingAggregateRoot>> GetListAsync(
|
||||
string[] names,
|
||||
string providerName,
|
||||
string providerKey,
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using JetBrains.Annotations;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Check = Volo.Abp.Check;
|
||||
|
||||
namespace Yi.Framework.SettingManagement.Domain;
|
||||
|
||||
public class SettingEntity : Entity<Guid>, IAggregateRoot<Guid>
|
||||
[SugarTable("Setting")]
|
||||
public class SettingAggregateRoot : Entity<Guid>, IAggregateRoot<Guid>
|
||||
{
|
||||
[NotNull]
|
||||
public virtual string Name { get; protected set; }
|
||||
@@ -18,12 +21,12 @@ public class SettingEntity : Entity<Guid>, IAggregateRoot<Guid>
|
||||
[CanBeNull]
|
||||
public virtual string ProviderKey { get; protected set; }
|
||||
|
||||
public SettingEntity()
|
||||
public SettingAggregateRoot()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SettingEntity(
|
||||
public SettingAggregateRoot(
|
||||
Guid id,
|
||||
[NotNull] string name,
|
||||
[NotNull] string value,
|
||||
@@ -6,7 +6,7 @@ using Volo.Abp.EventBus;
|
||||
|
||||
namespace Yi.Framework.SettingManagement.Domain;
|
||||
|
||||
public class SettingCacheItemInvalidator : ILocalEventHandler<EntityChangedEventData<SettingEntity>>, ITransientDependency
|
||||
public class SettingCacheItemInvalidator : ILocalEventHandler<EntityChangedEventData<SettingAggregateRoot>>, ITransientDependency
|
||||
{
|
||||
protected IDistributedCache<SettingCacheItem> Cache { get; }
|
||||
|
||||
@@ -15,7 +15,7 @@ public class SettingCacheItemInvalidator : ILocalEventHandler<EntityChangedEvent
|
||||
Cache = cache;
|
||||
}
|
||||
|
||||
public virtual async Task HandleEventAsync(EntityChangedEventData<SettingEntity> eventData)
|
||||
public virtual async Task HandleEventAsync(EntityChangedEventData<SettingAggregateRoot> eventData)
|
||||
{
|
||||
var cacheKey = CalculateCacheKey(
|
||||
eventData.Entity.Name,
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SettingManagementStore : ISettingManagementStore, ITransientDepende
|
||||
var setting = await SettingRepository.FindAsync(name, providerName, providerKey);
|
||||
if (setting == null)
|
||||
{
|
||||
setting = new SettingEntity(GuidGenerator.Create(), name, value, providerName, providerKey);
|
||||
setting = new SettingAggregateRoot(GuidGenerator.Create(), name, value, providerName, providerKey);
|
||||
await SettingRepository.InsertAsync(setting);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -11,4 +11,8 @@
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.Domain.Shared" Version="$(AbpVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.SqlSugarCore.Abstractions\Yi.Framework.SqlSugarCore.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user