Browse Source

Added provider name and key parameters

pull/14514/head
malik masis 4 years ago
parent
commit
276df8acdd
  1. 2
      modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/IFeatureAppService.cs
  2. 7
      modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs
  3. 2
      modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/IFeatureValueRepository.cs
  4. 10
      modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs
  5. 8
      modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/ClientProxies/FeaturesClientProxy.Generated.cs
  6. 50
      modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/ClientProxies/featureManagement-generate-proxy.json
  7. 4
      modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs
  8. 10
      modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs
  9. 6
      modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/feature-management-modal.js
  10. 4
      modules/feature-management/src/Volo.Abp.FeatureManagement.Web/wwwroot/client-proxies/featureManagement-proxy.js
  11. 3
      modules/feature-management/test/Volo.Abp.FeatureManagement.Application.Tests/Volo/Abp/FeatureManagement/FeatureAppService_Tests.cs
  12. 5
      modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureValueRepository_Tests.cs

2
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/IFeatureAppService.cs

@ -10,5 +10,5 @@ public interface IFeatureAppService : IApplicationService
Task UpdateAsync([NotNull] string providerName, string providerKey, UpdateFeaturesDto input);
Task ResetToDefaultAsync();
Task ResetToDefaultAsync([NotNull] string providerName, string providerKey);
}

7
modules/feature-management/src/Volo.Abp.FeatureManagement.Application/Volo/Abp/FeatureManagement/FeatureAppService.cs

@ -6,7 +6,6 @@ using JetBrains.Annotations;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Options;
using Volo.Abp.Features;
using Volo.Abp.Localization;
namespace Volo.Abp.FeatureManagement;
@ -138,9 +137,9 @@ public class FeatureAppService : FeatureManagementAppServiceBase, IFeatureAppSer
await AuthorizationService.CheckAsync(policyName);
}
public virtual async Task ResetToDefaultAsync()
public virtual async Task ResetToDefaultAsync([NotNull] string providerName, string providerKey)
{
await FeatureValueRepository.DeleteAsync();
await FeatureValueRepository.DeleteAsync(providerName, providerKey);
}
}

2
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/IFeatureValueRepository.cs

@ -26,5 +26,7 @@ public interface IFeatureValueRepository : IBasicRepository<FeatureValue, Guid>
CancellationToken cancellationToken = default);
Task DeleteAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default);
}

10
modules/feature-management/src/Volo.Abp.FeatureManagement.EntityFrameworkCore/Volo/Abp/FeatureManagement/EntityFrameworkCore/EfCoreFeatureValueRepository.cs

@ -51,9 +51,15 @@ public class EfCoreFeatureValueRepository : EfCoreRepository<IFeatureManagementD
).ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task DeleteAsync(CancellationToken cancellationToken = default)
public async Task DeleteAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
var entities = await (await GetDbSetAsync()).ToListAsync(GetCancellationToken(cancellationToken));
var entities = await (await GetDbSetAsync())
.Where(
s => s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync(GetCancellationToken(cancellationToken));
(await GetDbSetAsync()).RemoveRange(entities);
await (await GetDbContextAsync()).SaveChangesAsync(cancellationToken);
}

8
modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/ClientProxies/FeaturesClientProxy.Generated.cs

@ -34,8 +34,12 @@ public partial class FeaturesClientProxy : ClientProxyBase<IFeatureAppService>,
});
}
public virtual async Task ResetToDefaultAsync()
public virtual async Task ResetToDefaultAsync(string providerName, string providerKey)
{
await RequestAsync(nameof(ResetToDefaultAsync));
await RequestAsync(nameof(ResetToDefaultAsync), new ClientProxyRequestTypeValue
{
{ typeof(string), providerName },
{ typeof(string), providerKey }
});
}
}

50
modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi.Client/ClientProxies/featureManagement-generate-proxy.json

@ -150,14 +150,56 @@
"allowAnonymous": null,
"implementFrom": "Volo.Abp.FeatureManagement.IFeatureAppService"
},
"ResetToDefaultAsync": {
"uniqueName": "ResetToDefaultAsync",
"ResetToDefaultAsyncByProviderNameAndProviderKey": {
"uniqueName": "ResetToDefaultAsyncByProviderNameAndProviderKey",
"name": "ResetToDefaultAsync",
"httpMethod": null,
"url": "api/feature-management/features",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"parametersOnMethod": [
{
"name": "providerName",
"typeAsString": "System.String, System.Private.CoreLib",
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
},
{
"name": "providerKey",
"typeAsString": "System.String, System.Private.CoreLib",
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "providerName",
"name": "providerName",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": ""
},
{
"nameOnMethod": "providerKey",
"name": "providerKey",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": ""
}
],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"

4
modules/feature-management/src/Volo.Abp.FeatureManagement.HttpApi/Volo/Abp/FeatureManagement/FeaturesController.cs

@ -28,8 +28,8 @@ public class FeaturesController : AbpControllerBase, IFeatureAppService
return FeatureAppService.UpdateAsync(providerName, providerKey, input);
}
public Task ResetToDefaultAsync()
public Task ResetToDefaultAsync(string providerName, string providerKey)
{
return FeatureAppService.ResetToDefaultAsync();
return FeatureAppService.ResetToDefaultAsync(providerName, providerKey);
}
}

10
modules/feature-management/src/Volo.Abp.FeatureManagement.MongoDB/Volo/Abp/FeatureManagement/MongoDB/MongoFeatureValueRepository.cs

@ -52,10 +52,14 @@ public class MongoFeatureValueRepository :
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual async Task DeleteAsync(CancellationToken cancellationToken = default)
public virtual async Task DeleteAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
//TODO check it again
var entities = await AsyncExecuter.ToListAsync((await GetQueryableAsync()).Select(p => p.Id));
var entities = await (await GetMongoQueryableAsync(cancellationToken))
.Where(s => s.ProviderName == providerName && s.ProviderKey == providerKey)
.ToListAsync(GetCancellationToken(cancellationToken));
await DeleteManyAsync(entities, true, GetCancellationToken(cancellationToken));
}
}

6
modules/feature-management/src/Volo.Abp.FeatureManagement.Web/Pages/FeatureManagement/feature-management-modal.js

@ -11,7 +11,11 @@ var abp = abp || {};
abp.message.confirm(l('AreYouSureToResetToDefault'))
.then(function (confirmed) {
if (confirmed) {
volo.abp.featureManagement.features.resetToDefault().then(function () {
debugger
let providerName = $('#ProviderName').val();
let prodiverKey = $('#ProviderKey').val();
volo.abp.featureManagement.features.resetToDefault(providerName, prodiverKey).then(function () {
abp.notify.success(l('ResetedToDefault'));
});
}

4
modules/feature-management/src/Volo.Abp.FeatureManagement.Web/wwwroot/client-proxies/featureManagement-proxy.js

@ -27,9 +27,9 @@
}, ajaxParams));
};
volo.abp.featureManagement.features.resetToDefault = function(ajaxParams) {
volo.abp.featureManagement.features.resetToDefault = function(providerName, providerKey, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/feature-management/features',
url: abp.appPath + 'api/feature-management/features' + abp.utils.buildQueryString([{ name: 'providerName', value: providerName }, { name: 'providerKey', value: providerKey }]) + '',
type: 'POST',
dataType: null
}, ajaxParams));

3
modules/feature-management/test/Volo.Abp.FeatureManagement.Application.Tests/Volo/Abp/FeatureManagement/FeatureAppService_Tests.cs

@ -72,7 +72,8 @@ public class FeatureAppService_Tests : FeatureManagementApplicationTestBase
public async Task ResetToDefaultAsync()
{
Login(_testData.User1Id);
var exception = await Record.ExceptionAsync(async () => await _featureAppService.ResetToDefaultAsync());
var exception = await Record.ExceptionAsync(async () =>
await _featureAppService.ResetToDefaultAsync("test", "test"));
Assert.Null(exception);
}

5
modules/feature-management/test/Volo.Abp.FeatureManagement.TestBase/Volo/Abp/FeatureManagement/FeatureValueRepository_Tests.cs

@ -76,8 +76,9 @@ public abstract class FeatureValueRepository_Tests<TStartupModule> : FeatureMana
[Fact]
public async Task DeleteAsync()
{
var exception = await Record.ExceptionAsync(async() => await Repository.DeleteAsync());
var exception = await Record.ExceptionAsync(async () =>
await Repository.DeleteAsync(TestFeatureDefinitionProvider.SocialLogins, "true"));
Assert.Null(exception);
}
}

Loading…
Cancel
Save