Browse Source

Merge pull request #6875 from abpframework/cotur/cms-kit

Content, Page Services are organized and added tests
pull/6901/head
İlkay İlknur 5 years ago
committed by GitHub
parent
commit
82c849086c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml
  2. 10
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentDto.cs
  3. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CheckUrlInputDto.cs
  4. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs
  5. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageWithContentInputDto.cs
  6. 7
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/IPageAdminAppService.cs
  7. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs
  8. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageWithContentDto.cs
  9. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageContentInputDto.cs
  10. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs
  11. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs
  12. 14
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs
  13. 37
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Page/PageAdminController.cs
  14. 4
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationAutoMapperProfile.cs
  15. 7
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Contents/Default.cshtml
  16. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs
  17. 0
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/ContentDto.cs
  18. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/GetContentInput.cs
  19. 3
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentAppService.cs
  20. 10
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPageAppService.cs
  21. 14
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs
  22. 9
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentAppService.cs
  23. 22
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PageAppService.cs
  24. 8
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs
  25. 5
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs
  26. 26
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs
  27. 5
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml
  28. 5
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml.cs
  29. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs
  30. 3
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/Default.cshtml
  31. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml
  32. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs
  33. 183
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs
  34. 32
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs
  35. 9
      modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Pages/PageRepository_Test.cs
  36. 11
      modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Pages/PageRepository_Test.cs
  37. 24
      modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs
  38. 28
      modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs
  39. 62
      modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs

2
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Pages/Index.cshtml

@ -5,9 +5,9 @@
@using Volo.CmsKit.GlobalFeatures
@using Volo.CmsKit.Pages
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection
@using Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Contents
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Tags
@model IndexModel
@inject IStringLocalizer<AbpUiResource> Localizer

10
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Contents/ContentDto.cs

@ -0,0 +1,10 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Admin.Contents
{
public class ContentDto : EntityDto<Guid>
{
public string Value { get; set; }
}
}

3
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CheckUrlInputDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CheckUrlInputDto.cs

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

3
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CreatePageInputDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageInputDto.cs

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

4
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CreatePageWithContentInputDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/CreatePageWithContentInputDto.cs

@ -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
{

7
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/IPageAppService.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/IPageAdminAppService.cs

@ -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);

2
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/PageDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageDto.cs

@ -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>
{

4
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/PageWithContentDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/PageWithContentDto.cs

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

4
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/UpdatePageContentInputDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageContentInputDto.cs

@ -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
{

3
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/UpdatePageInputDto.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Pages/UpdatePageInputDto.cs

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

6
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs

@ -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>();
}
}
}

14
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Pages/PageAppService.cs → modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Pages/PageAdminAppService.cs

@ -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);

37
modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Pages/PageController.cs → modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Page/PageAdminController.cs

@ -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);
}
}
}

4
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/CmsKitCommonApplicationAutoMapperProfile.cs

@ -9,11 +9,7 @@ namespace Volo.CmsKit
{
public CmsKitCommonApplicationAutoMapperProfile()
{
CreateMap<Content, ContentDto>();
CreateMap<Tag, TagDto>();
CreateMap<Page, PageDto>();
}
}
}

7
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Contents/Default.cshtml

@ -1,7 +0,0 @@
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.CmsKit.Localization
@model Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Contents.ContentViewComponent.ContentViewModel
<div>
@Html.Raw(Model.Rendered)
</div>

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs

@ -21,7 +21,7 @@ namespace Volo.CmsKit.Pages
}
public Page(Guid id, [NotNull] string title, [NotNull] string url, [CanBeNull] string description, Guid? tenantId = null) : base(id)
public Page(Guid id, [NotNull] string title, [NotNull] string url, [CanBeNull] string description = null, Guid? tenantId = null) : base(id)
{
Title = Check.NotNullOrWhiteSpace(title, nameof(title), PageConsts.MaxTitleLength);
Url = Check.NotNullOrWhiteSpace(url, nameof(url), PageConsts.MaxUrlLength);

0
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/ContentDto.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/ContentDto.cs

2
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/GetContentInput.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/GetContentInput.cs

@ -1,4 +1,4 @@
namespace Volo.CmsKit.Contents
namespace Volo.CmsKit.Public.Contents
{
public class GetContentInput
{

3
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Contents/IContentAppService.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentAppService.cs

@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Contents
namespace Volo.CmsKit.Public.Contents
{
public interface IContentAppService
{

10
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/IPageAppService.cs

@ -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);
}
}

14
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Pages/PageDto.cs

@ -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; }
}
}

9
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Contents/ContentAppService.cs → modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentAppService.cs

@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Contents
namespace Volo.CmsKit.Public.Contents
{
public class ContentAppService : CmsKitAppServiceBase, IContentAppService
{

22
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Pages/PageAppService.cs

@ -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);
}
}
}

8
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs

@ -1,7 +1,11 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.CmsKit.Comments;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Pages;
using Volo.CmsKit.Public.Comments;
using Volo.CmsKit.Public.Contents;
using Volo.CmsKit.Public.Pages;
using Volo.CmsKit.Public.Ratings;
using Volo.CmsKit.Ratings;
using Volo.CmsKit.Users;
@ -22,6 +26,10 @@ namespace Volo.CmsKit.Public
.Ignore(x=> x.Author);
CreateMap<Rating, RatingDto>();
CreateMap<Content, ContentDto>();
CreateMap<Page, PageDto>();
}
}
}

5
modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Contents/ContentController.cs → modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs

@ -2,13 +2,14 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Controllers;
namespace Volo.CmsKit.Controllers.Contents
namespace Volo.CmsKit.Public.Contents
{
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit/contents")]
[Route("api/cms-kit-public/contents")]
public class ContentController : CmsKitControllerBase, IContentAppService
{
protected readonly IContentAppService _contentAppService;

26
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Pages/PagesPublicController.cs

@ -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);
}
}
}

5
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Pages/Index.cshtml → modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml

@ -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),

5
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Pages/Index.cshtml.cs → modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Pages/Index.cshtml.cs

@ -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
{

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

@ -2,10 +2,10 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Public.Contents;
using Volo.CmsKit.Web.Contents;
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Contents
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
{
[ViewComponent(Name = "CmsContent")]
public class ContentViewComponent : AbpViewComponent

3
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/Default.cshtml

@ -0,0 +1,3 @@
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents.ContentViewComponent.ContentViewModel
@Html.Raw(Model.Rendered)

4
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml → modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml

@ -1,8 +1,8 @@
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@using Microsoft.AspNetCore.Mvc.RazorPages
@using Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Contents
@model Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Pages.PageViewModel
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Pages.PageViewModel
<abp-card>
<abp-card-header>

4
modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs → modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs

@ -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

183
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PageAdminAppService_Tests.cs

@ -0,0 +1,183 @@
using System;
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Uow;
using Volo.CmsKit.Admin.Pages;
using Volo.CmsKit.Contents;
using Xunit;
namespace Volo.CmsKit.Pages
{
public class PageAdminAppService_Tests : CmsKitApplicationTestBase
{
private readonly CmsKitTestData _data;
private readonly IPageAdminAppService _pageAdminAppService;
private readonly IPageRepository _pageRepository;
private readonly IContentRepository _contentRepository;
public PageAdminAppService_Tests()
{
_data = GetRequiredService<CmsKitTestData>();
_pageAdminAppService = GetRequiredService<IPageAdminAppService>();
_pageRepository = GetRequiredService<IPageRepository>();
_contentRepository = GetRequiredService<IContentRepository>();
}
[Fact]
public async Task ShouldGetAsync()
{
var page = await _pageAdminAppService.GetAsync(_data.Page_1_Id);
page.Description.ShouldBe(_data.Page_1_Description);
}
[Fact]
public async Task ShouldCreateAsync()
{
var dto = new CreatePageInputDto
{
Title = "test",
Url = "test-url"
};
await Should.NotThrowAsync(async () => await _pageAdminAppService.CreatePageAsync(dto));
var page = await _pageRepository.GetByUrlAsync(dto.Url);
page.Title.ShouldBe(dto.Title);
}
[Fact]
public async Task ShouldNotCreateAsync()
{
var dto = new CreatePageInputDto
{
Title = "test",
Url = _data.Page_1_Url
};
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.CreatePageAsync(dto));
}
[Fact]
public async Task ShouldCreateWithContentAsync()
{
var dto = new CreatePageWithContentInputDto
{
Title = "test",
Url = "test-url",
Content = "my-test-content"
};
await Should.NotThrowAsync(async () => await _pageAdminAppService.CreatePageWithContentAsync(dto));
var page = await _pageRepository.GetByUrlAsync(dto.Url);
var content = await _contentRepository.GetAsync(nameof(Page), page.Id.ToString());
content.Value.ShouldBe(dto.Content);
}
[Fact]
public async Task ShouldNotCreateWithContentAsync()
{
var dto = new CreatePageWithContentInputDto
{
Title = "test",
Url = _data.Page_1_Url,
Content = "my-test-content"
};
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.CreatePageWithContentAsync(dto));
}
[Fact]
public async Task ShouldUpdatePageAsync()
{
var dto = new UpdatePageInputDto
{
Title = _data.Page_1_Title + "++",
Description = "new description",
Url = _data.Page_1_Url+ "test"
};
await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdatePageAsync(_data.Page_1_Id, dto));
var updatedPage = await _pageRepository.GetAsync(_data.Page_1_Id);
updatedPage.Title.ShouldNotBe(_data.Page_1_Title);
updatedPage.Title.ShouldBe(dto.Title);
updatedPage.Url.ShouldNotBe(_data.Page_1_Url);
updatedPage.Url.ShouldBe(dto.Url);
updatedPage.Description.ShouldNotBe(_data.Page_1_Description);
updatedPage.Description.ShouldBe(dto.Description);
}
[Fact]
public async Task ShouldNotUpdatePageAsync()
{
var dto = new UpdatePageInputDto
{
Title = _data.Page_1_Title + "++",
Description = "new description",
Url = _data.Page_2_Url
};
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.UpdatePageAsync(_data.Page_1_Id, dto));
}
[Fact]
public async Task ShouldBeExistAsync()
{
var dto = new CheckUrlInputDto
{
Url = _data.Page_1_Url
};
var doesExist = await _pageAdminAppService.DoesUrlExistAsync(dto);
doesExist.ShouldBeTrue();
}
[Fact]
public async Task ShouldNotBeExistAsync()
{
var dto = new CheckUrlInputDto
{
Url = _data.Page_1_Url+ "+"
};
var doesExist = await _pageAdminAppService.DoesUrlExistAsync(dto);
doesExist.ShouldBeFalse();
}
[Fact]
public async Task ShouldUpdateContentAsync()
{
var dto = new UpdatePageContentInputDto
{
Content = "my-new-content"
};
await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdatePageContentAsync(_data.Page_1_Id, dto));
var content = await _contentRepository.GetAsync(nameof(Page), _data.Page_1_Id.ToString());
content.Value.ShouldBe(dto.Content);
}
[Fact]
public async Task ShouldDeleteAsync()
{
await _pageAdminAppService.DeleteAsync(_data.Page_1_Id);
await Should.ThrowAsync<Exception>(async () => await _pageRepository.GetAsync(_data.Page_1_Id));
await Should.ThrowAsync<Exception>(async () => await _contentRepository.GetAsync(nameof(Page), _data.Page_1_Id.ToString()));
}
}
}

32
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Pages/PagePublicAppService_Tests.cs

@ -0,0 +1,32 @@
using System;
using System.Threading.Tasks;
using Shouldly;
using Volo.CmsKit.Public.Pages;
using Xunit;
namespace Volo.CmsKit.Pages
{
public class PagePublicAppService_Tests : CmsKitApplicationTestBase
{
private readonly CmsKitTestData _data;
private readonly IPageAppService _pageAppService;
public PagePublicAppService_Tests()
{
_data = GetRequiredService<CmsKitTestData>();
_pageAppService = GetRequiredService<IPageAppService>();
}
[Fact]
public async Task ShouldGetByUrlAsync()
{
await Should.NotThrowAsync(async () => await _pageAppService.GetByUrlAsync(_data.Page_1_Url));
}
[Fact]
public async Task ShouldNotGetByUrlAsync()
{
await Should.ThrowAsync<Exception>(async () => await _pageAppService.GetByUrlAsync("not-exist-url"));
}
}
}

9
modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Pages/PageRepository_Test.cs

@ -0,0 +1,9 @@
using Volo.CmsKit.Pages;
namespace Volo.CmsKit.EntityFrameworkCore.Pages
{
public class PageRepository_Test : PageRepository_Test<CmsKitEntityFrameworkCoreTestModule>
{
}
}

11
modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Pages/PageRepository_Test.cs

@ -0,0 +1,11 @@
using Volo.CmsKit.Pages;
using Xunit;
namespace Volo.CmsKit.MongoDB.Pages
{
[Collection(MongoTestCollection.Name)]
public class PageRepository_Test : PageRepository_Test<CmsKitMongoDbTestModule>
{
}
}

24
modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs

@ -7,6 +7,7 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.Users;
using Volo.CmsKit.Comments;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Pages;
using Volo.CmsKit.Ratings;
using Volo.CmsKit.Reactions;
using Volo.CmsKit.Tags;
@ -26,7 +27,7 @@ namespace Volo.CmsKit
private readonly IContentRepository _contentRepository;
private readonly IEntityTagRepository _entityTagRepository;
private readonly ITagManager _tagManager;
private readonly IPageRepository _pageRepository;
public CmsKitDataSeedContributor(
IGuidGenerator guidGenerator,
ICmsUserRepository cmsUserRepository,
@ -37,7 +38,8 @@ namespace Volo.CmsKit
ICurrentTenant currentTenant,
IContentRepository contentRepository,
ITagManager tagManager,
IEntityTagRepository entityTagRepository)
IEntityTagRepository entityTagRepository,
IPageRepository pageRepository)
{
_guidGenerator = guidGenerator;
_cmsUserRepository = cmsUserRepository;
@ -49,6 +51,7 @@ namespace Volo.CmsKit
_contentRepository = contentRepository;
_tagManager = tagManager;
_entityTagRepository = entityTagRepository;
_pageRepository = pageRepository;
}
public async Task SeedAsync(DataSeedContext context)
@ -66,6 +69,8 @@ namespace Volo.CmsKit
await SeedContentsAsync();
await SeedTagsAsync();
await SeedPagesAsync();
}
}
@ -230,5 +235,20 @@ namespace Volo.CmsKit
await _entityTagRepository.InsertAsync(new EntityTag(tagEntity.Id, _cmsKitTestData.Content_2_Id));
}
}
private async Task SeedPagesAsync()
{
var page1 = new Page(_cmsKitTestData.Page_1_Id, _cmsKitTestData.Page_1_Title, _cmsKitTestData.Page_1_Url, _cmsKitTestData.Page_1_Description);
var page1Content = new Content(_guidGenerator.Create(), nameof(Page), page1.Id.ToString(), _cmsKitTestData.Page_1_Content);
await _pageRepository.InsertAsync(page1);
await _contentRepository.InsertAsync(page1Content);
var page2 = new Page(_cmsKitTestData.Page_2_Id, _cmsKitTestData.Page_2_Title, _cmsKitTestData.Page_2_Url, _cmsKitTestData.Page_2_Description);
var page2Content = new Content(_guidGenerator.Create(), nameof(Page), page2.Id.ToString(), _cmsKitTestData.Page_2_Content);
await _pageRepository.InsertAsync(page2);
await _contentRepository.InsertAsync(page2Content);
}
}
}

28
modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs

@ -20,20 +20,40 @@ namespace Volo.CmsKit
public string EntityId2 { get; } = "2";
public string Content_1_EntityType = "Lyrics";
public string Content_1_EntityType { get; } = "Lyrics";
public string Content_1 { get; } = "First things first\nI'ma say all the words inside my head\nI'm fired up and tired of the way that things have been, oh-ooh\nThe way that things have been, oh-ooh";
public string Content_1_Id = "1";
public string Content_1_Id { get; } = "1";
public string[] Content_1_Tags => new string[] {"Imagine Dragons", "Music"};
public string Content_2_EntityType = "LyricsAlso";
public string Content_2_EntityType { get; } = "LyricsAlso";
public string Content_2 { get; } = "Second thing second\nDon't you tell me what you think that I could be\nI'm the one at the sail, I'm the master of my sea, oh-ooh\nThe master of my sea, oh-ooh";
public string Content_2_Id = "2";
public string Content_2_Id { get; } = "2";
public string[] Content_2_Tags => new string[] {"Imagine Dragons", "Music", "Most Loved Part"};
public string Page_1_Title { get; } = "Imagine Dragons - Believer Lyrics";
public string Page_1_Url { get; } = "imagine-dragons-believer-lyrics";
public string Page_1_Description { get; } = "You can get the lyrics of the music.";
public Guid Page_1_Id { get; } = Guid.NewGuid();
public string Page_1_Content => Content_1;
public string Page_2_Title { get; } = "Imagine Dragons - Believer Lyrics (Page 2)";
public string Page_2_Url { get; } = "imagine-dragons-believer-lyrics-2";
public string Page_2_Description { get; } = "You can get the lyrics of the music.";
public Guid Page_2_Id { get; } = Guid.NewGuid();
public string Page_2_Content => Content_2;
}
}

62
modules/cms-kit/test/Volo.CmsKit.TestBase/Pages/PageRepository_Test.cs

@ -0,0 +1,62 @@
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Modularity;
using Xunit;
namespace Volo.CmsKit.Pages
{
public abstract class PageRepository_Test<TStartupModule> : CmsKitTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly CmsKitTestData _cmsKitTestData;
private readonly IPageRepository _pageRepository;
protected PageRepository_Test()
{
_cmsKitTestData = GetRequiredService<CmsKitTestData>();
_pageRepository = GetRequiredService<IPageRepository>();
}
[Fact]
public async Task ShouldGetByUrlAsync()
{
var page = await _pageRepository.GetByUrlAsync(_cmsKitTestData.Page_1_Url);
page.ShouldNotBeNull();
page.Description.ShouldBe(_cmsKitTestData.Page_1_Description);
}
[Fact]
public async Task ShouldFindByUrlAsync()
{
var page = await _pageRepository.FindByUrlAsync(_cmsKitTestData.Page_1_Url);
page.ShouldNotBeNull();
page.Description.ShouldBe(_cmsKitTestData.Page_1_Description);
}
[Fact]
public async Task ShouldNotFindByUrlAsync()
{
var page = await _pageRepository.FindByUrlAsync("not-exist-lyrics");
page.ShouldBeNull();
}
[Fact]
public async Task ShouldBeExistAsync()
{
var page = await _pageRepository.DoesExistAsync(_cmsKitTestData.Page_1_Url);
page.ShouldBeTrue();
}
[Fact]
public async Task ShouldNotBeExistAsync()
{
var page = await _pageRepository.DoesExistAsync("not-exist-lyrics");
page.ShouldBeFalse();
}
}
}
Loading…
Cancel
Save