Browse Source

Refactor Content

pull/6821/head
enisn 6 years ago
parent
commit
81a0f166f4
  1. 8
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/GetContentInput.cs
  2. 4
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/IContentAppService.cs
  3. 8
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentAppService.cs
  4. 25
      modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Contents/ContentController.cs
  5. 8
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs

8
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/GetContentInput.cs

@ -0,0 +1,8 @@
namespace Volo.CmsKit.Common.Application.Contracts.Volo.CmsKit.Contents
{
public class GetContentInput
{
public string EntityType { get; set; }
public string EntityId { get; set; }
}
}

4
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/IContentAppService.cs

@ -1,10 +1,10 @@
using System.Threading.Tasks;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Common.Application.Contracts.Volo.CmsKit.Contents;
namespace Volo.CmsKit.Contents
{
public interface IContentAppService
{
Task<ContentDto> GetAsync(string entityType, string entityId);
Task<ContentDto> GetAsync(GetContentInput input);
}
}

8
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentAppService.cs

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Common.Application.Contracts.Volo.CmsKit.Contents;
namespace Volo.CmsKit.Contents
{
@ -15,9 +16,12 @@ namespace Volo.CmsKit.Contents
_contentRepository = contentRepository;
}
public async Task<ContentDto> GetAsync(string entityType, string entityId)
public async Task<ContentDto> GetAsync(GetContentInput input)
{
var entity = await _contentRepository.FindAsync(entityType, entityId); // Tenant???
var entity = await _contentRepository.FindAsync(
input.EntityType,
input.EntityId,
CurrentTenant.Id);
return ObjectMapper.Map<Content, ContentDto>(entity);
}

25
modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Contents/ContentController.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Common.Application.Contracts.Volo.CmsKit.Contents;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Controllers.Contents
{
public class ContentController : CmsKitControllerBase, IContentAppService
{
protected readonly IContentAppService _contentAppService;
public ContentController(IContentAppService contentAppService)
{
_contentAppService = contentAppService;
}
public virtual Task<ContentDto> GetAsync(GetContentInput input)
{
return _contentAppService.GetAsync(input);
}
}
}

8
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs

@ -7,6 +7,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
using Volo.CmsKit.Common.Application.Contracts.Volo.CmsKit.Contents;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Web.Contents;
@ -30,7 +31,12 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
string entityType,
string entityId)
{
var content = await contentAppService.GetAsync(entityType, entityId);
var content = await contentAppService.GetAsync(new GetContentInput
{
EntityId = entityId,
EntityType = entityType
});
var viewModel = new ContentViewModel
{
EntityId = entityId,

Loading…
Cancel
Save