mirror of https://github.com/abpframework/abp.git
18 changed files with 114 additions and 342 deletions
@ -1,23 +0,0 @@ |
|||||
using System; |
|
||||
using System.ComponentModel.DataAnnotations; |
|
||||
using Volo.Abp.Validation; |
|
||||
using Volo.CmsKit.Contents; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class ContentCreateDto |
|
||||
{ |
|
||||
[Required] |
|
||||
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxEntityTypeLength))] |
|
||||
public string EntityType { get; set; } |
|
||||
|
|
||||
[Required] |
|
||||
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxEntityIdLength))] |
|
||||
public string EntityId { get; set; } |
|
||||
|
|
||||
[Required] |
|
||||
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxValueLength))] |
|
||||
public string Value { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,15 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class ContentDto : EntityDto<Guid> |
|
||||
{ |
|
||||
public string EntityType { get; set; } |
|
||||
|
|
||||
public string EntityId { get; set; } |
|
||||
|
|
||||
public string Value { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,13 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class ContentGetListDto : EntityDto<Guid> |
|
||||
{ |
|
||||
public string EntityType { get; set; } |
|
||||
|
|
||||
public string EntityId { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,10 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class ContentGetListInput : PagedAndSortedResultRequestDto |
|
||||
{ |
|
||||
} |
|
||||
} |
|
||||
@ -1,15 +0,0 @@ |
|||||
using System; |
|
||||
using System.ComponentModel.DataAnnotations; |
|
||||
using Volo.Abp.Validation; |
|
||||
using Volo.CmsKit.Contents; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class ContentUpdateDto |
|
||||
{ |
|
||||
[Required] |
|
||||
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxValueLength))] |
|
||||
public string Value { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,19 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.Application.Services; |
|
||||
using Volo.CmsKit.Admin.Contents; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents |
|
||||
{ |
|
||||
public interface IContentAdminAppService |
|
||||
: ICrudAppService< |
|
||||
ContentDto, |
|
||||
ContentGetListDto, |
|
||||
Guid, |
|
||||
ContentGetListInput, |
|
||||
ContentCreateDto, |
|
||||
ContentUpdateDto> |
|
||||
{ |
|
||||
Task<ContentDto> GetAsync(string entityType, string entityId); |
|
||||
} |
|
||||
} |
|
||||
@ -1,71 +0,0 @@ |
|||||
using Microsoft.AspNetCore.Authorization; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
using Volo.Abp.GlobalFeatures; |
|
||||
using Volo.CmsKit.Admin.Contents; |
|
||||
using Volo.CmsKit.GlobalFeatures; |
|
||||
using Volo.CmsKit.Permissions; |
|
||||
|
|
||||
namespace Volo.CmsKit.Admin.Contents |
|
||||
{ |
|
||||
[Authorize(CmsKitAdminPermissions.Contents.Default)] |
|
||||
[RequiresGlobalFeature(typeof(ContentsFeature))] |
|
||||
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] |
|
||||
[Area("cms-kit")] |
|
||||
[Route("api/cms-kit-admin/contents")] |
|
||||
public class ContentAdminController : CmsKitAdminController, IContentAdminAppService |
|
||||
{ |
|
||||
protected IContentAdminAppService ContentAdminAppService { get; } |
|
||||
|
|
||||
public ContentAdminController(IContentAdminAppService contentAdminAppService) |
|
||||
{ |
|
||||
ContentAdminAppService = contentAdminAppService; |
|
||||
} |
|
||||
|
|
||||
[HttpPost] |
|
||||
[Authorize(CmsKitAdminPermissions.Contents.Create)] |
|
||||
public Task<ContentDto> CreateAsync(ContentCreateDto input) |
|
||||
{ |
|
||||
return ContentAdminAppService.CreateAsync(input); |
|
||||
} |
|
||||
|
|
||||
[HttpDelete("{id}")] |
|
||||
[Authorize(CmsKitAdminPermissions.Contents.Delete)] |
|
||||
public Task DeleteAsync(Guid id) |
|
||||
{ |
|
||||
return ContentAdminAppService.DeleteAsync(id); |
|
||||
} |
|
||||
|
|
||||
[HttpGet("{id}")] |
|
||||
[Authorize(CmsKitAdminPermissions.Contents.Default)] |
|
||||
public Task<ContentDto> GetAsync(Guid id) |
|
||||
{ |
|
||||
return ContentAdminAppService.GetAsync(id); |
|
||||
} |
|
||||
|
|
||||
[HttpGet] |
|
||||
[Authorize(CmsKitAdminPermissions.Contents.Default)] |
|
||||
public Task<PagedResultDto<ContentGetListDto>> GetListAsync(ContentGetListInput input) |
|
||||
{ |
|
||||
return ContentAdminAppService.GetListAsync(input); |
|
||||
} |
|
||||
|
|
||||
[HttpPut] |
|
||||
[Authorize(CmsKitAdminPermissions.Contents.Update)] |
|
||||
public Task<ContentDto> UpdateAsync(Guid id, ContentUpdateDto input) |
|
||||
{ |
|
||||
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); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,11 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
|
|
||||
namespace Volo.CmsKit.Public.Contents |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class ContentDto : EntityDto<Guid> |
|
||||
{ |
|
||||
public string Value { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,12 +0,0 @@ |
|||||
using System; |
|
||||
|
|
||||
namespace Volo.CmsKit.Public.Contents |
|
||||
{ |
|
||||
[Serializable] |
|
||||
public class GetContentInput |
|
||||
{ |
|
||||
public string EntityType { get; set; } |
|
||||
|
|
||||
public string EntityId { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,10 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Volo.CmsKit.Contents; |
|
||||
|
|
||||
namespace Volo.CmsKit.Public.Contents |
|
||||
{ |
|
||||
public interface IContentPublicAppService |
|
||||
{ |
|
||||
Task<ContentDto> GetAsync(GetContentInput input); |
|
||||
} |
|
||||
} |
|
||||
@ -1,29 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.GlobalFeatures; |
|
||||
using Volo.CmsKit.Contents; |
|
||||
using Volo.CmsKit.GlobalFeatures; |
|
||||
|
|
||||
namespace Volo.CmsKit.Public.Contents |
|
||||
{ |
|
||||
[RequiresGlobalFeature(typeof(ContentsFeature))] |
|
||||
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] |
|
||||
[Area("cms-kit")] |
|
||||
[Route("api/cms-kit-public/contents")] |
|
||||
public class ContentController : CmsKitControllerBase, IContentPublicAppService |
|
||||
{ |
|
||||
protected IContentPublicAppService ContentAppService { get; } |
|
||||
|
|
||||
public ContentController(IContentPublicAppService contentAppService) |
|
||||
{ |
|
||||
ContentAppService = contentAppService; |
|
||||
} |
|
||||
|
|
||||
[HttpGet] |
|
||||
public virtual Task<ContentDto> GetAsync(GetContentInput input) |
|
||||
{ |
|
||||
return ContentAppService.GetAsync(input); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,59 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Volo.Abp.AspNetCore.Mvc; |
|
||||
using Volo.Abp.Domain.Entities; |
|
||||
using Volo.CmsKit.Public.Contents; |
|
||||
using Volo.CmsKit.Web.Contents; |
|
||||
|
|
||||
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents |
|
||||
{ |
|
||||
[ViewComponent(Name = "CmsContent")] |
|
||||
public class ContentViewComponent : AbpViewComponent |
|
||||
{ |
|
||||
private readonly IContentRenderer contentRenderer; |
|
||||
private readonly IContentPublicAppService contentAppService; |
|
||||
|
|
||||
public ContentViewComponent( |
|
||||
IContentRenderer contentRenderer, |
|
||||
IContentPublicAppService contentAppService) |
|
||||
{ |
|
||||
this.contentRenderer = contentRenderer; |
|
||||
this.contentAppService = contentAppService; |
|
||||
} |
|
||||
|
|
||||
public virtual async Task<IViewComponentResult> InvokeAsync( |
|
||||
string entityType, |
|
||||
string entityId) |
|
||||
{ |
|
||||
var content = string.Empty; |
|
||||
|
|
||||
try |
|
||||
{ |
|
||||
var contentDto = await contentAppService.GetAsync(new GetContentInput |
|
||||
{ |
|
||||
EntityId = entityId, |
|
||||
EntityType = entityType |
|
||||
}); |
|
||||
|
|
||||
content = contentDto.Value; |
|
||||
} |
|
||||
catch (EntityNotFoundException e) |
|
||||
{ |
|
||||
// ContentDto can be null, we will render empty content.
|
|
||||
} |
|
||||
|
|
||||
var viewModel = new ContentViewModel |
|
||||
{ |
|
||||
Value = await contentRenderer.RenderAsync(content) |
|
||||
}; |
|
||||
|
|
||||
return View("~/Pages/CmsKit/Shared/Components/Contents/Default.cshtml", viewModel); |
|
||||
} |
|
||||
|
|
||||
public class ContentViewModel |
|
||||
{ |
|
||||
public string Value { get; set; } |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,3 +0,0 @@ |
|||||
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents.ContentViewComponent.ContentViewModel |
|
||||
|
|
||||
@Html.Raw(Model.Value) |
|
||||
Loading…
Reference in new issue