mirror of https://github.com/abpframework/abp.git
19 changed files with 249 additions and 13 deletions
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
public class EntityTagSetDto |
|||
{ |
|||
public string EntityId { get; set; } |
|||
public string EntityType { get; set; } |
|||
public List<string> Tags { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.GlobalFeatures; |
|||
using Volo.CmsKit.GlobalFeatures; |
|||
using Volo.CmsKit.Permissions; |
|||
|
|||
namespace Volo.CmsKit.Admin.Tags |
|||
{ |
|||
[RequiresGlobalFeature(typeof(TagsFeature))] |
|||
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("cms-kit")] |
|||
[Route("api/cms-kit-admin/entity-tags")] |
|||
public class EntityTagAdminController : CmsKitAdminController, IEntityTagAdminAppService |
|||
{ |
|||
protected IEntityTagAdminAppService EntityTagAdminAppService { get; } |
|||
|
|||
public EntityTagAdminController(IEntityTagAdminAppService entityTagAdminAppService) |
|||
{ |
|||
EntityTagAdminAppService = entityTagAdminAppService; |
|||
} |
|||
|
|||
[HttpPost] |
|||
public Task AddTagToEntityAsync(EntityTagCreateDto input) |
|||
{ |
|||
return EntityTagAdminAppService.AddTagToEntityAsync(input); |
|||
} |
|||
|
|||
[HttpDelete] |
|||
public Task RemoveTagFromEntityAsync(EntityTagRemoveDto input) |
|||
{ |
|||
return EntityTagAdminAppService.RemoveTagFromEntityAsync(input); |
|||
} |
|||
|
|||
[HttpPut] |
|||
public Task SetEntityTagsAsync(EntityTagSetDto input) |
|||
{ |
|||
return EntityTagAdminAppService.SetEntityTagsAsync(input); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:60873/", |
|||
"sslPort": 44300 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.CmsKit.Public.Web": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "https://localhost:5001;http://localhost:5000" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.CmsKit.Tags; |
|||
|
|||
namespace Volo.CmsKit.EntityFrameworkCore.Tags |
|||
{ |
|||
public class EntityTagRepository_Test : EntityTagRepository_Test<CmsKitEntityFrameworkCoreTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.CmsKit.Tags; |
|||
using Xunit; |
|||
|
|||
namespace Volo.CmsKit.MongoDB.Tags |
|||
{ |
|||
[Collection(MongoTestCollection.Name)] |
|||
public class EntityTagRepository_Test : EntityTagRepository_Test<CmsKitMongoDbTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
using Shouldly; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Modularity; |
|||
using Xunit; |
|||
|
|||
namespace Volo.CmsKit.Tags |
|||
{ |
|||
public abstract class EntityTagRepository_Test<TStartupModule> : CmsKitTestBase<TStartupModule> |
|||
where TStartupModule : IAbpModule |
|||
{ |
|||
private CmsKitTestData _cmsKitTestData; |
|||
private IEntityTagRepository _entityTagRepository; |
|||
private ITagRepository _tagRepository; |
|||
|
|||
public EntityTagRepository_Test() |
|||
{ |
|||
_cmsKitTestData = GetRequiredService<CmsKitTestData>(); |
|||
_entityTagRepository = GetRequiredService<IEntityTagRepository>(); |
|||
_tagRepository = GetRequiredService<ITagRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DeleteManyAsync_ShouldWorkProperly_WithExistingIds() |
|||
{ |
|||
var relatedTags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); |
|||
|
|||
await _entityTagRepository.DeleteManyAsync(relatedTags.Select(s => s.Id).ToArray()); |
|||
|
|||
relatedTags = await _tagRepository.GetAllRelatedTagsAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_EntityId); |
|||
|
|||
relatedTags.ShouldBeEmpty(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue