page application services are seperated to admin and public

pull/6875/head
Ahmet 5 years ago
parent fbc5c7cdb9
commit 37bff78ced

@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class CheckUrlInputDto
{

@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class CreatePageInputDto
{

@ -1,8 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class CreatePageWithContentInputDto
{

@ -1,14 +1,11 @@
using System;
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public interface IPageAppService
public interface IPageAdminAppService
{
Task<PageDto> GetAsync(Guid id);
Task<PageDto> GetByUrlAsync([NotNull] string url);
Task<PageDto> CreatePageAsync(CreatePageInputDto input);

@ -1,7 +1,7 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class PageDto : EntityDto<Guid>
{

@ -2,7 +2,7 @@
using Volo.Abp.Application.Dtos;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class PageWithContentDto : EntityDto<Guid>
{

@ -1,8 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class UpdatePageContentInputDto
{

@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class UpdatePageInputDto
{

@ -1,4 +1,6 @@
using AutoMapper;
using Volo.CmsKit.Admin.Pages;
using Volo.CmsKit.Pages;
namespace Volo.CmsKit.Admin
{
@ -6,9 +8,7 @@ namespace Volo.CmsKit.Admin
{
public CmsKitAdminApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Page, PageDto>();
}
}
}

@ -3,15 +3,16 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Pages;
namespace Volo.CmsKit.Pages
namespace Volo.CmsKit.Admin.Pages
{
public class PageAppService : CmsKitAppServiceBase, IPageAppService
public class PageAdminAppService : CmsKitAdminAppServiceBase, IPageAdminAppService
{
protected readonly IPageRepository PageRepository;
protected readonly IContentRepository ContentRepository;
public PageAppService(IPageRepository pageRepository, IContentRepository contentRepository)
public PageAdminAppService(IPageRepository pageRepository, IContentRepository contentRepository)
{
PageRepository = pageRepository;
ContentRepository = contentRepository;
@ -24,13 +25,6 @@ namespace Volo.CmsKit.Pages
return ObjectMapper.Map<Page, PageDto>(page);
}
public virtual async Task<PageDto> GetByUrlAsync(string url)
{
var page = await PageRepository.GetByUrlAsync(url);
return ObjectMapper.Map<Page, PageDto>(page);
}
public virtual async Task<PageDto> CreatePageAsync(CreatePageInputDto input)
{
var page = await CreatePageAsync(input.Title, input.Url, input.Description);

@ -2,76 +2,69 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.CmsKit.Pages;
using Volo.CmsKit.Admin.Pages;
namespace Volo.CmsKit.Controllers.Pages
namespace Volo.CmsKit.Admin.Page
{
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit/pages")]
public class PageController : CmsKitControllerBase, IPageAppService
[Route("api/cms-kit-admin/pages")]
public class PageAdminController : CmsKitAdminController, IPageAdminAppService
{
protected readonly IPageAppService PageAppService;
protected readonly IPageAdminAppService PageAdminAppService;
public PageController(IPageAppService pageAppService)
public PageAdminController(IPageAdminAppService pageAdminAppService)
{
PageAppService = pageAppService;
PageAdminAppService = pageAdminAppService;
}
[HttpGet]
[Route("{id}")]
public virtual Task<PageDto> GetAsync(Guid id)
{
return PageAppService.GetAsync(id);
return PageAdminAppService.GetAsync(id);
}
[HttpGet]
[Route("url/{url}")]
public Task<PageDto> GetByUrlAsync(string url)
{
return PageAppService.GetByUrlAsync(url);
}
[HttpPost]
[Route("create")]
public virtual Task<PageDto> CreatePageAsync(CreatePageInputDto input)
{
return PageAppService.CreatePageAsync(input);
return PageAdminAppService.CreatePageAsync(input);
}
[HttpPost]
[Route("create-with-content")]
public virtual Task<PageDto> CreatePageWithContentAsync(CreatePageWithContentInputDto input)
{
return PageAppService.CreatePageWithContentAsync(input);
return PageAdminAppService.CreatePageWithContentAsync(input);
}
[HttpPut]
[Route("{id}")]
public virtual Task<PageDto> UpdatePageAsync(Guid id, UpdatePageInputDto input)
{
return PageAppService.UpdatePageAsync(id, input);
return PageAdminAppService.UpdatePageAsync(id, input);
}
[HttpPost]
[Route("does-url-exist")]
public virtual Task<bool> DoesUrlExistAsync(CheckUrlInputDto input)
{
return PageAppService.DoesUrlExistAsync(input);
return PageAdminAppService.DoesUrlExistAsync(input);
}
[HttpPut]
[Route("update-content/{id}")]
public virtual Task UpdatePageContentAsync(Guid id, UpdatePageContentInputDto input)
{
return PageAppService.UpdatePageContentAsync(id, input);
return PageAdminAppService.UpdatePageContentAsync(id, input);
}
[HttpDelete]
[Route("{id}")]
public virtual Task DeleteAsync(Guid id)
{
return PageAppService.DeleteAsync(id);
return PageAdminAppService.DeleteAsync(id);
}
}
}

@ -12,8 +12,6 @@ namespace Volo.CmsKit
CreateMap<Content, ContentDto>();
CreateMap<Tag, TagDto>();
CreateMap<Page, PageDto>();
}
}
}

@ -0,0 +1,10 @@
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace Volo.CmsKit.Public.Pages
{
public interface IPageAppService
{
Task<PageDto> GetByUrlAsync([NotNull] string url);
}
}

@ -0,0 +1,14 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Public.Pages
{
public class PageDto : EntityDto<Guid>
{
public string Title { get; set; }
public string Url { get; set; }
public string Description { get; set; }
}
}

@ -0,0 +1,22 @@
using System.Threading.Tasks;
using Volo.CmsKit.Pages;
namespace Volo.CmsKit.Public.Pages
{
public class PageAppService : CmsKitPublicAppServiceBase, IPageAppService
{
protected readonly IPageRepository PageRepository;
public PageAppService(IPageRepository pageRepository)
{
PageRepository = pageRepository;
}
public virtual async Task<PageDto> GetByUrlAsync(string url)
{
var page = await PageRepository.GetByUrlAsync(url);
return ObjectMapper.Map<Page, PageDto>(page);
}
}
}

@ -1,7 +1,9 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.CmsKit.Comments;
using Volo.CmsKit.Pages;
using Volo.CmsKit.Public.Comments;
using Volo.CmsKit.Public.Pages;
using Volo.CmsKit.Public.Ratings;
using Volo.CmsKit.Ratings;
using Volo.CmsKit.Users;
@ -22,6 +24,8 @@ namespace Volo.CmsKit.Public
.Ignore(x=> x.Author);
CreateMap<Rating, RatingDto>();
CreateMap<Page, PageDto>();
}
}
}

@ -0,0 +1,26 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
namespace Volo.CmsKit.Public.Pages
{
[RemoteService(Name = CmsKitPublicRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit-public/comments")]
public class PagesPublicController
{
protected readonly IPageAppService PageAppService;
public PagesPublicController(IPageAppService pageAppService)
{
PageAppService = pageAppService;
}
[HttpGet]
[Route("url/{url}")]
public Task<PageDto> GetByUrlAsync(string url)
{
return PageAppService.GetByUrlAsync(url);
}
}
}

@ -1,9 +1,8 @@
@page "{pageUrl}"
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.CmsKit.Localization
@using Volo.CmsKit.Web.Pages.CmsKit.Pages
@using Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Pages
@model IndexModel
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Pages.IndexModel
@inject IHtmlLocalizer<CmsKitResource> L
@await Component.InvokeAsync(typeof(DefaultPageViewComponent),

@ -1,8 +1,9 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.CmsKit.Pages;
using Volo.CmsKit.Public.Pages;
using Volo.CmsKit.Web.Pages;
namespace Volo.CmsKit.Web.Pages.CmsKit.Pages
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Pages
{
public class IndexModel : CommonPageModel
{

@ -2,7 +2,7 @@
@using Microsoft.AspNetCore.Mvc.RazorPages
@using Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Contents
@model Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Pages.PageViewModel
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages.PageViewModel
<abp-card>
<abp-card-header>

@ -2,9 +2,9 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.CmsKit.Pages;
using Volo.CmsKit.Public.Pages;
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Pages
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages
{
[ViewComponent(Name = "CmsDefaultPage")]
public class DefaultPageViewComponent : AbpViewComponent
Loading…
Cancel
Save