mirror of https://github.com/abpframework/abp.git
46 changed files with 835 additions and 16474 deletions
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,23 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class BlogFeatureEnabledColumnRename : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.RenameColumn( |
|||
name: "Enabled", |
|||
table: "CmsBlogFeatures", |
|||
newName: "IsEnabled"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.RenameColumn( |
|||
name: "IsEnabled", |
|||
table: "CmsBlogFeatures", |
|||
newName: "Enabled"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,24 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Page_Remove_Description : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Description", |
|||
table: "CmsPages"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Description", |
|||
table: "CmsPages", |
|||
type: "nvarchar(512)", |
|||
maxLength: 512, |
|||
nullable: true); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,109 +0,0 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class BlogPost_Author : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_CreatorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_DeleterId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_LastModifierId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_CreatorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_DeleterId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_LastModifierId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.AddColumn<Guid>( |
|||
name: "AuthorId", |
|||
table: "CmsBlogPosts", |
|||
type: "uniqueidentifier", |
|||
nullable: false, |
|||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_AuthorId", |
|||
table: "CmsBlogPosts", |
|||
column: "AuthorId"); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_AuthorId", |
|||
table: "CmsBlogPosts", |
|||
column: "AuthorId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_AuthorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_AuthorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "AuthorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_CreatorId", |
|||
table: "CmsBlogPosts", |
|||
column: "CreatorId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_DeleterId", |
|||
table: "CmsBlogPosts", |
|||
column: "DeleterId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_LastModifierId", |
|||
table: "CmsBlogPosts", |
|||
column: "LastModifierId"); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_CreatorId", |
|||
table: "CmsBlogPosts", |
|||
column: "CreatorId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Restrict); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_DeleterId", |
|||
table: "CmsBlogPosts", |
|||
column: "DeleterId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Restrict); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_LastModifierId", |
|||
table: "CmsBlogPosts", |
|||
column: "LastModifierId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Restrict); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,25 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Added_EntityType_to_Media : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "EntityType", |
|||
table: "CmsMediaDescriptors", |
|||
type: "nvarchar(64)", |
|||
maxLength: 64, |
|||
nullable: false, |
|||
defaultValue: ""); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "EntityType", |
|||
table: "CmsMediaDescriptors"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,24 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Added_Content_To_BlogPost : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Content", |
|||
table: "CmsBlogPosts", |
|||
type: "nvarchar(max)", |
|||
maxLength: 2147483647, |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Content", |
|||
table: "CmsBlogPosts"); |
|||
} |
|||
} |
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Added_Content_To_Page : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Content", |
|||
table: "CmsPages", |
|||
type: "nvarchar(max)", |
|||
maxLength: 2147483647, |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Content", |
|||
table: "CmsPages"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,56 +0,0 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class BlogPost_CoverImage : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "CmsContents"); |
|||
|
|||
migrationBuilder.AddColumn<Guid>( |
|||
name: "CoverImageMediaId", |
|||
table: "CmsBlogPosts", |
|||
type: "uniqueidentifier", |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "CoverImageMediaId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "CmsContents", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
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), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
EntityId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), |
|||
EntityType = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
Value = table.Column<string>(type: "nvarchar(max)", maxLength: 2147483647, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_CmsContents", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsContents_TenantId_EntityType_EntityId", |
|||
table: "CmsContents", |
|||
columns: new[] { "TenantId", "EntityType", "EntityId" }); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,33 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Page_StyleScript : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Script", |
|||
table: "CmsPages", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
|
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Style", |
|||
table: "CmsPages", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Script", |
|||
table: "CmsPages"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "Style", |
|||
table: "CmsPages"); |
|||
} |
|||
} |
|||
} |
|||
@ -1,15 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
public interface IMenuAdminAppService : ICrudAppService<MenuDto, Guid, PagedAndSortedResultRequestDto, MenuCreateInput> |
|||
public interface IMenuAdminAppService |
|||
{ |
|||
Task<MenuWithDetailsDto> GetAsync(Guid id); |
|||
|
|||
Task<MenuDto> CreateAsync(MenuCreateInput input); |
|||
|
|||
Task<MenuDto> UpdateAsync(Guid menuId, MenuUpdateInput input); |
|||
|
|||
Task DeleteAsync(Guid menuId); |
|||
|
|||
Task<MenuItemDto> CreateMenuItemAsync(Guid menuId, MenuItemCreateInput input); |
|||
|
|||
Task<MenuItemDto> UpdateMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemUpdateInput input); |
|||
|
|||
Task DeleteMenuItemAsync(Guid menuId, Guid menuItemId); |
|||
|
|||
Task MoveMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemMoveInput input); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
public class MenuItemMoveInput |
|||
{ |
|||
public Guid NewParentId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
public class MenuItemUpdateInput |
|||
{ |
|||
[Required] |
|||
public string DisplayName { get; set; } |
|||
|
|||
public bool IsActive { get; set; } |
|||
|
|||
[Required] |
|||
public string Url { get; set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
public int Order { get; set; } |
|||
|
|||
public string Target { get; set; } |
|||
|
|||
public string ElementId { get; set; } |
|||
|
|||
public string CssClass { get; set; } |
|||
|
|||
public string RequiredPermissionName { get; set; } |
|||
|
|||
public Guid? PageId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
public class MenuUpdateInput |
|||
{ |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
public class MenuWithDetailsDto : FullAuditedEntityDto<Guid> |
|||
{ |
|||
public string Name { get; set; } |
|||
public List<MenuItemDto> Items { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.GlobalFeatures; |
|||
using Volo.CmsKit.GlobalFeatures; |
|||
using Volo.CmsKit.Permissions; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[RequiresGlobalFeature(typeof(MenuFeature))] |
|||
[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("cms-kit")] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Default)] |
|||
[Route("api/cms-kit-admin/menus")] |
|||
public class MenuAdminController : CmsKitAdminController, IMenuAdminAppService |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
|
|||
public MenuAdminController(IMenuAdminAppService menuAdminAppService) |
|||
{ |
|||
MenuAdminAppService = menuAdminAppService; |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Create)] |
|||
public Task<MenuDto> CreateAsync(MenuCreateInput input) |
|||
{ |
|||
return MenuAdminAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.MenuItems.Create)] |
|||
public Task<MenuItemDto> CreateMenuItemAsync(Guid menuId, MenuItemCreateInput input) |
|||
{ |
|||
return MenuAdminAppService.CreateMenuItemAsync(menuId, input); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Delete)] |
|||
public Task DeleteAsync(Guid menuId) |
|||
{ |
|||
return MenuAdminAppService.DeleteAsync(menuId); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.MenuItems.Delete)] |
|||
public Task DeleteMenuItemAsync(Guid menuId, Guid menuItemId) |
|||
{ |
|||
return MenuAdminAppService.DeleteMenuItemAsync(menuId, menuItemId); |
|||
} |
|||
|
|||
public Task<MenuWithDetailsDto> GetAsync(Guid id) |
|||
{ |
|||
return MenuAdminAppService.GetAsync(id); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.MenuItems.Update)] |
|||
public Task MoveMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemMoveInput input) |
|||
{ |
|||
return MenuAdminAppService.MoveMenuItemAsync(menuId, menuItemId, input); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public Task<MenuDto> UpdateAsync(Guid menuId, MenuUpdateInput input) |
|||
{ |
|||
return MenuAdminAppService.UpdateAsync(menuId, input); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.MenuItems.Update)] |
|||
public Task<MenuItemDto> UpdateMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemUpdateInput input) |
|||
{ |
|||
return MenuAdminAppService.UpdateMenuItemAsync(menuId, menuItemId, input); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public static class MenuConsts |
|||
{ |
|||
public const int MaxNameLength = 128; |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; |
|||
using Shouldly; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.CmsKit.Admin.Menus; |
|||
using Xunit; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public class MenuAdminAppService_Tests : CmsKitApplicationTestBase |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
protected CmsKitTestData TestData { get; } |
|||
protected IMenuRepository MenuRepository { get; } |
|||
|
|||
public MenuAdminAppService_Tests() |
|||
{ |
|||
MenuAdminAppService = GetRequiredService<IMenuAdminAppService>(); |
|||
TestData = GetRequiredService<CmsKitTestData>(); |
|||
MenuRepository = GetRequiredService<IMenuRepository>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task GetAsync_ShouldWorkProperly_WithCorrectId() |
|||
{ |
|||
var menu = await MenuAdminAppService.GetAsync(TestData.Menu_1_Id); |
|||
|
|||
menu.ShouldNotBeNull(); |
|||
menu.Name.ShouldBe(TestData.Menu_1_Name); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task GetAsync_ShouldGetItemsProperly_WithCorrectId() |
|||
{ |
|||
var menu = await MenuAdminAppService.GetAsync(TestData.Menu_1_Id); |
|||
|
|||
menu.ShouldNotBeNull(); |
|||
menu.Items.ShouldNotBeEmpty(); |
|||
menu.Items.Count.ShouldBe(2); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task CreateAsync_ShouldWorkProperly_WithOnlyName() |
|||
{ |
|||
var name = "My Awesome Menu"; |
|||
var menu = await MenuAdminAppService.CreateAsync(new MenuCreateInput |
|||
{ |
|||
Name = name |
|||
}); |
|||
|
|||
menu.ShouldNotBeNull(); |
|||
menu.Id.ShouldNotBe(Guid.Empty); |
|||
menu.Name.ShouldBe(name); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task UpdateAsync_ShouldWorkProperly_WithName() |
|||
{ |
|||
var newName = "My New Name"; |
|||
|
|||
await MenuAdminAppService.UpdateAsync(TestData.Menu_1_Id, new MenuUpdateInput |
|||
{ |
|||
Name = newName |
|||
}); |
|||
|
|||
var menu = await MenuRepository.FindAsync(TestData.Menu_1_Id); |
|||
|
|||
menu.ShouldNotBeNull(); |
|||
menu.Name.ShouldBe(newName); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DeleteAsync_ShouldWorkProperly_WithExistingId() |
|||
{ |
|||
await MenuAdminAppService.DeleteAsync(TestData.Menu_1_Id); |
|||
|
|||
|
|||
var menu = await MenuRepository.FindAsync(TestData.Menu_1_Id); |
|||
|
|||
menu.ShouldBeNull(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue