mirror of https://github.com/abpframework/abp.git
16 changed files with 1928 additions and 21 deletions
File diff suppressed because it is too large
@ -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"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Volo.CmsKit |
||||
|
{ |
||||
|
public class CmsKitCommonRemoteServiceConsts |
||||
|
{ |
||||
|
public const string RemoteServiceName = "CmsKitCommon"; |
||||
|
} |
||||
|
} |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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> |
||||
@ -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…
Reference in new issue