Browse Source

added default page view component

pull/6822/head
Ahmet 6 years ago
parent
commit
c1561f4e73
  1. 1647
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201225120048_Added_Page.Designer.cs
  2. 46
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201225120048_Added_Page.cs
  3. 71
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  4. 7
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonRemoteServiceConsts.cs
  5. 1
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CheckUrlInputDto.cs
  6. 3
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CreatePageInputDto.cs
  7. 4
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CreatePageWithContentInputDto.cs
  8. 4
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/IPageAppService.cs
  9. 1
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/UpdatePageContentInputDto.cs
  10. 3
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/UpdatePageInputDto.cs
  11. 9
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Pages/PageAppService.cs
  12. 13
      modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Contents/ContentController.cs
  13. 70
      modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Pages/PageController.cs
  14. 9
      modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Tags/TagController.cs
  15. 21
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Pages/Default.cshtml
  16. 40
      modules/cms-kit/src/Volo.CmsKit.Common.Web/Pages/CmsKit/Shared/Components/Pages/DefaultPageViewComponent.cs

1647
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201225120048_Added_Page.Designer.cs

File diff suppressed because it is too large

46
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201225120048_Added_Page.cs

@ -0,0 +1,46 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Added_Page : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CmsPages",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Title = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Url = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "nvarchar(515)", maxLength: 515, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CmsPages", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_CmsPages_TenantId_Url",
table: "CmsPages",
columns: new[] { "TenantId", "Url" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CmsPages");
}
}
}

71
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs

@ -1168,6 +1168,77 @@ namespace Volo.CmsKit.Migrations
b.ToTable("CmsContents");
});
modelBuilder.Entity("Volo.CmsKit.Pages.Page", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("Description")
.HasMaxLength(515)
.HasColumnType("nvarchar(515)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("Url")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "Url");
b.ToTable("CmsPages");
});
modelBuilder.Entity("Volo.CmsKit.Ratings.Rating", b =>
{
b.Property<Guid>("Id")

7
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/CmsKitCommonRemoteServiceConsts.cs

@ -0,0 +1,7 @@
namespace Volo.CmsKit
{
public class CmsKitCommonRemoteServiceConsts
{
public const string RemoteServiceName = "CmsKitCommon";
}
}

1
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/CheckUrlInputDto.cs

@ -6,7 +6,6 @@ namespace Volo.CmsKit.Pages
public class CheckUrlInputDto
{
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxUrlLength))]
public string Url { get; set; }
}
}

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

@ -6,14 +6,11 @@ namespace Volo.CmsKit.Pages
public class CreatePageInputDto
{
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))]
public string Title { get; set; }
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxUrlLength))]
public string Url { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxDescriptionLength))]
public string Description { get; set; }
}
}

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

@ -7,18 +7,14 @@ namespace Volo.CmsKit.Pages
public class CreatePageWithContentInputDto
{
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))]
public string Title { get; set; }
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxUrlLength))]
public string Url { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxDescriptionLength))]
public string Description { get; set; }
[Required]
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxValueLength))]
public string Content { get; set; }
}
}

4
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/IPageAppService.cs

@ -5,6 +5,8 @@ namespace Volo.CmsKit.Pages
{
public interface IPageAppService
{
Task<PageDto> GetAsync(Guid id);
Task<PageDto> CreatePageAsync(CreatePageInputDto input);
Task<PageDto> CreatePageWithContentAsync(CreatePageWithContentInputDto input);
@ -15,6 +17,6 @@ namespace Volo.CmsKit.Pages
Task UpdatePageContentAsync(Guid id, UpdatePageContentInputDto input);
Task DeletePageAsync(Guid id);
Task DeleteAsync(Guid id);
}
}

1
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Pages/UpdatePageContentInputDto.cs

@ -7,7 +7,6 @@ namespace Volo.CmsKit.Pages
public class UpdatePageContentInputDto
{
[Required]
[DynamicMaxLength(typeof(ContentConsts), nameof(ContentConsts.MaxValueLength))]
public string Content { get; set; }
}
}

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

@ -6,14 +6,11 @@ namespace Volo.CmsKit.Pages
public class UpdatePageInputDto
{
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxTitleLength))]
public string Title { get; set; }
[Required]
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxUrlLength))]
public string Url { get; set; }
[DynamicMaxLength(typeof(PageConsts), nameof(PageConsts.MaxDescriptionLength))]
public string Description { get; set; }
}
}

9
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Pages/PageAppService.cs

@ -17,6 +17,13 @@ namespace Volo.CmsKit.Pages
ContentRepository = contentRepository;
}
public virtual async Task<PageDto> GetAsync(Guid id)
{
var page = await PageRepository.GetAsync(id);
return ObjectMapper.Map<Page, PageDto>(page);
}
public virtual async Task<PageDto> CreatePageAsync(CreatePageInputDto input)
{
var page = await CreatePageAsync(input.Title, input.Url, input.Description);
@ -76,7 +83,7 @@ namespace Volo.CmsKit.Pages
await ContentRepository.UpdateAsync(pageContent);
}
public virtual async Task DeletePageAsync(Guid id)
public virtual async Task DeleteAsync(Guid id)
{
await ContentRepository.DeleteAsync(nameof(Page), id.ToString(), CurrentTenant?.Id, CancellationToken.None);
await PageRepository.DeleteAsync(id, cancellationToken: CancellationToken.None);

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

@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.Controllers.Contents
{
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit/contents")]
public class ContentController : CmsKitControllerBase, IContentAppService
{
protected readonly IContentAppService _contentAppService;
@ -16,6 +18,7 @@ namespace Volo.CmsKit.Controllers.Contents
_contentAppService = contentAppService;
}
[HttpGet]
public virtual Task<ContentDto> GetAsync(GetContentInput input)
{
return _contentAppService.GetAsync(input);

70
modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Pages/PageController.cs

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

9
modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Controllers/Tags/TagController.cs

@ -1,10 +1,14 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.CmsKit.Controllers;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.CmsKit.Tags;
namespace Volo.CmsKit.Common.HttpApi.Volo.CmsKit.Controllers.Tags
namespace Volo.CmsKit.Controllers.Tags
{
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit/tags")]
public class TagController : CmsKitControllerBase, ITagAppService
{
protected readonly ITagAppService TagAppService;
@ -14,6 +18,7 @@ namespace Volo.CmsKit.Common.HttpApi.Volo.CmsKit.Controllers.Tags
TagAppService = tagAppService;
}
[HttpGet]
public Task<List<TagDto>> GetAllRelatedTagsAsync(GetRelatedTagsInput input)
{
return TagAppService.GetAllRelatedTagsAsync(input);

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

@ -0,0 +1,21 @@
@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
<abp-card>
<abp-card-header>
<h3>
@Model.Title
</h3>
</abp-card-header>
<abp-card-body>
<p>
@Model.Description
</p>
@await Component.InvokeAsync(typeof(ContentViewComponent), new { entityType = nameof(Page), entityId = Model.Id.ToString() })
</abp-card-body>
</abp-card>

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

@ -0,0 +1,40 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.CmsKit.Pages;
namespace Volo.CmsKit.Web.Pages.CmsKit.Shared.Components.Pages
{
[ViewComponent(Name = "CmsDefaultPage")]
public class DefaultPageViewComponent : AbpViewComponent
{
protected readonly IPageAppService PageAppService;
public DefaultPageViewComponent(IPageAppService pageAppService)
{
PageAppService = pageAppService;
}
public virtual async Task<IViewComponentResult> InvokeAsync(Guid pageId, string title, string description)
{
var model = new PageViewModel
{
Id = pageId,
Title = title,
Description = description
};
return View("~/Pages/CmsKit/Shared/Components/Pages/Default.cshtml", model);
}
}
public class PageViewModel
{
public Guid Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
}
Loading…
Cancel
Save