feat: 新增配置管理
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.SettingManagement.Localization;
|
||||
|
||||
namespace Yi.Framework.SettingManagement.Application;
|
||||
|
||||
public abstract class SettingManagementAppServiceBase : ApplicationService
|
||||
{
|
||||
protected SettingManagementAppServiceBase()
|
||||
{
|
||||
LocalizationResource = typeof(AbpSettingManagementResource);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\..\common.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.Application.Contracts" Version="$(AbpVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Ddd.Application\Yi.Framework.Ddd.Application.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.SettingManagement.Domain\Yi.Framework.SettingManagement.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,15 @@
|
||||
using Volo.Abp.Application;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.Timing;
|
||||
|
||||
namespace Yi.Framework.SettingManagement.Application;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpDddApplicationModule),
|
||||
typeof(AbpSettingManagementApplicationContractsModule),
|
||||
typeof(AbpTimingModule)
|
||||
)]
|
||||
public class YiFrameworkSettingManagementApplicationModule : AbpModule
|
||||
{
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -4,14 +4,14 @@ using Yi.Framework.SqlSugarCore.Repositories;
|
||||
|
||||
namespace Volo.Abp.SettingManagement.EntityFrameworkCore;
|
||||
|
||||
public class SqlSugarCoreSettingRepository : SqlSugarRepository<SettingEntity, Guid>,
|
||||
public class SqlSugarCoreSettingRepository : SqlSugarRepository<SettingAggregateRoot, Guid>,
|
||||
ISettingRepository
|
||||
{
|
||||
public SqlSugarCoreSettingRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider) : base(sugarDbContextProvider)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task<SettingEntity> FindAsync(
|
||||
public virtual async Task<SettingAggregateRoot> FindAsync(
|
||||
string name,
|
||||
string providerName,
|
||||
string providerKey,
|
||||
@@ -23,7 +23,7 @@ public class SqlSugarCoreSettingRepository : SqlSugarRepository<SettingEntity, G
|
||||
.FirstAsync();
|
||||
}
|
||||
|
||||
public virtual async Task<List<SettingEntity>> GetListAsync(
|
||||
public virtual async Task<List<SettingAggregateRoot>> GetListAsync(
|
||||
string providerName,
|
||||
string providerKey,
|
||||
CancellationToken cancellationToken = default)
|
||||
@@ -34,7 +34,7 @@ public class SqlSugarCoreSettingRepository : SqlSugarRepository<SettingEntity, G
|
||||
).ToListAsync();
|
||||
}
|
||||
|
||||
public virtual async Task<List<SettingEntity>> GetListAsync(
|
||||
public virtual async Task<List<SettingAggregateRoot>> GetListAsync(
|
||||
string[] names,
|
||||
string providerName,
|
||||
string providerKey,
|
||||
|
||||
Reference in New Issue
Block a user