Merge pull request #7404 from abpframework/cms-kit/page

Cms Kit - Getting Specific Content
pull/7420/head
İlkay İlknur 5 years ago committed by GitHub
commit d9f8c881af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.CmsKit.Admin.Contents;
@ -13,5 +14,6 @@ namespace Volo.CmsKit.Admin.Contents
ContentCreateDto,
ContentUpdateDto>
{
Task<ContentDto> GetAsync(string entityType, string entityId);
}
}

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Authorization;
using JetBrains.Annotations;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.CmsKit.Contents;
@ -31,13 +33,13 @@ namespace Volo.CmsKit.Admin.Contents
IContentRepository contentRepository) : base(repository)
{
ContentManager = contentManager;
ContentRepository = contentRepository;
GetListPolicyName = CmsKitAdminPermissions.Contents.Default;
GetPolicyName = CmsKitAdminPermissions.Contents.Default;
CreatePolicyName = CmsKitAdminPermissions.Contents.Create;
UpdatePolicyName = CmsKitAdminPermissions.Contents.Update;
DeletePolicyName = CmsKitAdminPermissions.Contents.Delete;
ContentRepository = contentRepository;
}
[Authorize(CmsKitAdminPermissions.Contents.Create)]
@ -54,5 +56,17 @@ namespace Volo.CmsKit.Admin.Contents
return MapToGetOutputDto(entity);
}
public async Task<ContentDto> GetAsync(
[NotNull] string entityType,
[NotNull] string entityId)
{
Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
var content = await ContentRepository.GetAsync(entityType, entityId, CurrentTenant?.Id);
return ObjectMapper.Map<Content, ContentDto>(content);
}
}
}

@ -59,5 +59,13 @@ namespace Volo.CmsKit.Admin.Contents
{
return ContentAdminAppService.UpdateAsync(id, input);
}
[HttpGet]
[Route("{entityType}/{entityId}")]
[Authorize(CmsKitAdminPermissions.Contents.Default)]
public Task<ContentDto> GetAsync(string entityType, string entityId)
{
return ContentAdminAppService.GetAsync(entityType, entityId);
}
}
}

@ -128,5 +128,15 @@ namespace Volo.CmsKit.Contents
await Should.NotThrowAsync(async () =>
await _service.DeleteAsync(_data.Content_2_Id));
}
[Fact]
public async Task ShouldGetByEntityAsync()
{
var entity = await _service.GetAsync(_data.Content_1_EntityType, _data.Content_1_EntityId);
entity.ShouldNotBeNull();
entity.EntityId.ShouldBe(_data.Content_1_EntityId);
entity.EntityType.ShouldBe(_data.Content_1_EntityType);
}
}
}

Loading…
Cancel
Save