maliming
4 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
9 changed files with
83 additions and
2 deletions
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/IFeatureDefinitionRecordRepository.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureDefinitionRecordRepository.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/AbpFeatureManagementMongoDbModule.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContext.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/FeatureManagementMongoDbContextExtensions.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/IFeatureManagementMongoDbContext.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureDefinitionRecordRepository.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureGroupDefinitionRecordRepository.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs
|
|
|
@ -1,9 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
|
|
|
|
namespace Volo.Abp.FeatureManagement; |
|
|
|
|
|
|
|
public interface IFeatureDefinitionRecordRepository : IBasicRepository<FeatureDefinitionRecord, Guid> |
|
|
|
{ |
|
|
|
|
|
|
|
Task<FeatureDefinitionRecord> FindByNameAsync( |
|
|
|
string name, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,4 +1,8 @@ |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
|
|
|
|
|
@ -13,4 +17,11 @@ public class EfCoreFeatureDefinitionRecordRepository : |
|
|
|
: base(dbContextProvider) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<FeatureDefinitionRecord> FindByNameAsync(string name, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await (await GetDbSetAsync()) |
|
|
|
.OrderBy(x => x.Id) |
|
|
|
.FirstOrDefaultAsync(r => r.Name == name, cancellationToken); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -16,6 +16,8 @@ public class AbpFeatureManagementMongoDbModule : AbpModule |
|
|
|
{ |
|
|
|
options.AddDefaultRepositories<IFeatureManagementMongoDbContext>(); |
|
|
|
|
|
|
|
options.AddRepository<FeatureGroupDefinitionRecord, MongoFeatureGroupDefinitionRecordRepository>(); |
|
|
|
options.AddRepository<FeatureDefinitionRecord, MongoFeatureDefinitionRecordRepository>(); |
|
|
|
options.AddRepository<FeatureValue, MongoFeatureValueRepository>(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@ -9,6 +9,8 @@ namespace Volo.Abp.FeatureManagement.MongoDB; |
|
|
|
[ConnectionStringName(AbpFeatureManagementDbProperties.ConnectionStringName)] |
|
|
|
public class FeatureManagementMongoDbContext : AbpMongoDbContext, IFeatureManagementMongoDbContext |
|
|
|
{ |
|
|
|
public IMongoCollection<FeatureGroupDefinitionRecord> FeatureGroups => Collection<FeatureGroupDefinitionRecord>(); |
|
|
|
public IMongoCollection<FeatureDefinitionRecord> Features => Collection<FeatureDefinitionRecord>(); |
|
|
|
public IMongoCollection<FeatureValue> FeatureValues => Collection<FeatureValue>(); |
|
|
|
|
|
|
|
protected override void CreateModel(IMongoModelBuilder modelBuilder) |
|
|
|
|
|
|
|
@ -9,6 +9,16 @@ public static class FeatureManagementMongoDbContextExtensions |
|
|
|
{ |
|
|
|
Check.NotNull(builder, nameof(builder)); |
|
|
|
|
|
|
|
builder.Entity<FeatureGroupDefinitionRecord>(b => |
|
|
|
{ |
|
|
|
b.CollectionName = AbpFeatureManagementDbProperties.DbTablePrefix + "FeatureGroups"; |
|
|
|
}); |
|
|
|
|
|
|
|
builder.Entity<FeatureDefinitionRecord>(b => |
|
|
|
{ |
|
|
|
b.CollectionName = AbpFeatureManagementDbProperties.DbTablePrefix + "Features"; |
|
|
|
}); |
|
|
|
|
|
|
|
builder.Entity<FeatureValue>(b => |
|
|
|
{ |
|
|
|
b.CollectionName = AbpFeatureManagementDbProperties.DbTablePrefix + "FeatureValues"; |
|
|
|
|
|
|
|
@ -9,5 +9,9 @@ namespace Volo.Abp.FeatureManagement.MongoDB; |
|
|
|
[ConnectionStringName(AbpFeatureManagementDbProperties.ConnectionStringName)] |
|
|
|
public interface IFeatureManagementMongoDbContext : IAbpMongoDbContext |
|
|
|
{ |
|
|
|
IMongoCollection<FeatureGroupDefinitionRecord> FeatureGroups { get; } |
|
|
|
|
|
|
|
IMongoCollection<FeatureDefinitionRecord> Features { get; } |
|
|
|
|
|
|
|
IMongoCollection<FeatureValue> FeatureValues { get; } |
|
|
|
} |
|
|
|
|
|
|
|
@ -0,0 +1,30 @@ |
|
|
|
using System; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
using Volo.Abp.Domain.Repositories.MongoDB; |
|
|
|
using Volo.Abp.MongoDB; |
|
|
|
|
|
|
|
namespace Volo.Abp.FeatureManagement.MongoDB; |
|
|
|
|
|
|
|
public class MongoFeatureDefinitionRecordRepository : |
|
|
|
MongoDbRepository<IFeatureManagementMongoDbContext, FeatureDefinitionRecord, Guid>, |
|
|
|
IFeatureDefinitionRecordRepository |
|
|
|
{ |
|
|
|
public MongoFeatureDefinitionRecordRepository( |
|
|
|
IMongoDbContextProvider<IFeatureManagementMongoDbContext> dbContextProvider) |
|
|
|
: base(dbContextProvider) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<FeatureDefinitionRecord> FindByNameAsync(string name, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
cancellationToken = GetCancellationToken(cancellationToken); |
|
|
|
return await (await GetMongoQueryableAsync(cancellationToken)) |
|
|
|
.OrderBy(x => x.Id) |
|
|
|
.FirstOrDefaultAsync( |
|
|
|
s => s.Name == name, |
|
|
|
cancellationToken |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -0,0 +1,16 @@ |
|
|
|
using System; |
|
|
|
using Volo.Abp.Domain.Repositories.MongoDB; |
|
|
|
using Volo.Abp.MongoDB; |
|
|
|
|
|
|
|
namespace Volo.Abp.FeatureManagement.MongoDB; |
|
|
|
|
|
|
|
public class MongoFeatureGroupDefinitionRecordRepository : |
|
|
|
MongoDbRepository<IFeatureManagementMongoDbContext, FeatureGroupDefinitionRecord, Guid>, |
|
|
|
IFeatureGroupDefinitionRecordRepository |
|
|
|
{ |
|
|
|
public MongoFeatureGroupDefinitionRecordRepository( |
|
|
|
IMongoDbContextProvider<IFeatureManagementMongoDbContext> dbContextProvider) |
|
|
|
: base(dbContextProvider) |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
@ -9,7 +9,9 @@ using Volo.Abp.MongoDB; |
|
|
|
|
|
|
|
namespace Volo.Abp.FeatureManagement.MongoDB; |
|
|
|
|
|
|
|
public class MongoFeatureValueRepository : MongoDbRepository<IFeatureManagementMongoDbContext, FeatureValue, Guid>, IFeatureValueRepository |
|
|
|
public class MongoFeatureValueRepository : |
|
|
|
MongoDbRepository<IFeatureManagementMongoDbContext, FeatureValue, Guid>, |
|
|
|
IFeatureValueRepository |
|
|
|
{ |
|
|
|
public MongoFeatureValueRepository(IMongoDbContextProvider<IFeatureManagementMongoDbContext> dbContextProvider) |
|
|
|
: base(dbContextProvider) |
|
|
|
|