Browse Source

Merge branch 'dev' into cotur/cms-kit/comments

pull/7823/head
Ahmet 6 years ago
parent
commit
78dc7809c5
  1. 2
      framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs
  2. 1576
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201224140744_Initial.Designer.cs
  3. 1647
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201225120048_Added_Page.Designer.cs
  4. 46
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201225120048_Added_Page.cs
  5. 1643
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.Designer.cs
  6. 24
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.cs
  7. 1725
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201231111657_Added_Blob_Storing.Designer.cs
  8. 95
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201231111657_Added_Blob_Storing.cs
  9. 1891
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210209082122_UrlSlugToSlug.Designer.cs
  10. 106
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210209082122_UrlSlugToSlug.cs
  11. 73
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210210105857_Added_Media.cs
  12. 46
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219084931_PageSlugChange.cs
  13. 66
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219113255_Initial.Designer.cs
  14. 241
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219113255_Initial.cs
  15. 137
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.Designer.cs
  16. 23
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.cs
  17. 62
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  18. 4
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj
  19. 11
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs
  20. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs
  21. 16
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogFeatureAdminAppService.cs
  22. 1
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs
  23. 1
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs
  24. 49
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs
  25. 16
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs
  26. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs
  27. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs
  28. 4
      modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs
  29. 2
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs
  30. 40
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminController.cs
  31. 3
      modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminController.cs
  32. 11
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs
  33. 10
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureAppService.cs
  34. 14
      modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureCacheManager.cs
  35. 25
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo.CmsKit.Common.Application.csproj
  36. 41
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs
  37. 46
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureCacheManager.cs
  38. 22
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs
  39. 4
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/MediaDescriptors/MediaDescriptorAppService.cs
  40. 2
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs
  41. 31
      modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Blogs/BlogFeatureController.cs
  42. 17
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs
  43. 7
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureConsts.cs
  44. 12
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs
  45. 13
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json
  46. 1
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json
  47. 12
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs
  48. 28
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs
  49. 67
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs
  50. 19
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs
  51. 31
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs
  52. 7
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs
  53. 21
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs
  54. 5
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Extensions/SlugExtensions.cs
  55. 17
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureManager.cs
  56. 18
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureRepository.cs
  57. 4
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs
  58. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs
  59. 5
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs
  60. 14
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IDefaultBlogFeatureProvider.cs
  61. 32
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs
  62. 0
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/ContentAlreadyExistException.cs
  63. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs
  64. 6
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs
  65. 37
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs
  66. 51
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs
  67. 12
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs
  68. 95
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs
  69. 13
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs
  70. 1
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs
  71. 10
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs
  72. 1
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitEntityFrameworkCoreModule.cs
  73. 12
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs
  74. 5
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs
  75. 13
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs
  76. 39
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs
  77. 51
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs
  78. 13
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs
  79. 4
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContext.cs
  80. 5
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContextExtensions.cs
  81. 11
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs
  82. 26
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs
  83. 2
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/ICmsKitMongoDbContext.cs
  84. 34
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs
  85. 22
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs
  86. 10
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs
  87. 13
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/GetBlogFeatureInput.cs
  88. 7
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs
  89. 9
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs
  90. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicApplicationModule.cs
  91. 2
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/PublicApplicationAutoMapperProfile.cs
  92. 10
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs
  93. 10
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs
  94. 2
      modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs
  95. 44
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml
  96. 41
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml.cs
  97. 67
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs
  98. 43
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs
  99. 14
      modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogFeatureRepository_Test.cs
  100. 14
      modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogFeatureRepository_Test.cs

2
framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingProvider.cs

@ -43,7 +43,7 @@ namespace Volo.Abp.Settings
return value;
}
public async Task<List<SettingValue>> GetAllAsync(string[] names)
public virtual async Task<List<SettingValue>> GetAllAsync(string[] names)
{
var result = new Dictionary<string, SettingValue>();
var settingDefinitions = SettingDefinitionManager.GetAll().Where(x => names.Contains(x.Name)).ToList();

1576
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201224140744_Initial.Designer.cs

File diff suppressed because it is too large

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

@ -1,46 +0,0 @@
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");
}
}
}

1643
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.Designer.cs

File diff suppressed because it is too large

24
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201228083120_Updated_Tag_Removed_HexColor.cs

@ -1,24 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Updated_Tag_Removed_HexColor : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "HexColor",
table: "CmsTags");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "HexColor",
table: "CmsTags",
type: "nvarchar(6)",
maxLength: 6,
nullable: true);
}
}
}

1725
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201231111657_Added_Blob_Storing.Designer.cs

File diff suppressed because it is too large

95
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201231111657_Added_Blob_Storing.cs

@ -1,95 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Added_Blob_Storing : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "CmsPages",
type: "nvarchar(512)",
maxLength: 512,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(515)",
oldMaxLength: 515,
oldNullable: true);
migrationBuilder.CreateTable(
name: "AbpBlobContainers",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpBlobContainers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpBlobs",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ContainerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Content = table.Column<byte[]>(type: "varbinary(max)", maxLength: 2147483647, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpBlobs", x => x.Id);
table.ForeignKey(
name: "FK_AbpBlobs_AbpBlobContainers_ContainerId",
column: x => x.ContainerId,
principalTable: "AbpBlobContainers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AbpBlobContainers_TenantId_Name",
table: "AbpBlobContainers",
columns: new[] { "TenantId", "Name" });
migrationBuilder.CreateIndex(
name: "IX_AbpBlobs_ContainerId",
table: "AbpBlobs",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_AbpBlobs_TenantId_ContainerId_Name",
table: "AbpBlobs",
columns: new[] { "TenantId", "ContainerId", "Name" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AbpBlobs");
migrationBuilder.DropTable(
name: "AbpBlobContainers");
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "CmsPages",
type: "nvarchar(515)",
maxLength: 515,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(512)",
oldMaxLength: 512,
oldNullable: true);
}
}
}

1891
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210209082122_UrlSlugToSlug.Designer.cs

File diff suppressed because it is too large

106
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210209082122_UrlSlugToSlug.cs

@ -1,106 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class UrlSlugToSlug : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "CmsBlogPosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
BlogId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Title = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Slug = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
ShortDescription = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
TenantId = table.Column<Guid>(type: "uniqueidentifier", 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_CmsBlogPosts", x => x.Id);
table.ForeignKey(
name: "FK_CmsBlogPosts_CmsUsers_CreatorId",
column: x => x.CreatorId,
principalTable: "CmsUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CmsBlogPosts_CmsUsers_DeleterId",
column: x => x.DeleterId,
principalTable: "CmsUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CmsBlogPosts_CmsUsers_LastModifierId",
column: x => x.LastModifierId,
principalTable: "CmsUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CmsBlogs",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Slug = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", 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_CmsBlogs", x => x.Id);
});
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.CreateIndex(
name: "IX_CmsBlogPosts_Slug_BlogId",
table: "CmsBlogPosts",
columns: new[] { "Slug", "BlogId" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CmsBlogPosts");
migrationBuilder.DropTable(
name: "CmsBlogs");
}
}
}

73
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210210105857_Added_Media.cs

@ -1,73 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Added_Media : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CmsPages");
migrationBuilder.CreateTable(
name: "CmsMediaDescriptors",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
MimeType = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Size = table.Column<long>(type: "bigint", maxLength: 2147483647, nullable: false),
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_CmsMediaDescriptors", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CmsMediaDescriptors");
migrationBuilder.CreateTable(
name: "CmsPages",
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),
Description = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
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),
Title = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Url = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CmsPages", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_CmsPages_TenantId_Url",
table: "CmsPages",
columns: new[] { "TenantId", "Url" });
}
}
}

46
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219084931_PageSlugChange.cs

@ -1,46 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class PageSlugChange : 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),
Slug = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "nvarchar(512)", maxLength: 512, 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_Slug",
table: "CmsPages",
columns: new[] { "TenantId", "Slug" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CmsPages");
}
}
}

66
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219084931_PageSlugChange.Designer.cs → modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219113255_Initial.Designer.cs

@ -11,8 +11,8 @@ using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Migrations
{
[DbContext(typeof(UnifiedDbContext))]
[Migration("20210219084931_PageSlugChange")]
partial class PageSlugChange
[Migration("20210219113255_Initial")]
partial class Initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -1191,6 +1191,68 @@ namespace Volo.CmsKit.Migrations
b.ToTable("CmsBlogs");
});
modelBuilder.Entity("Volo.CmsKit.Blogs.BlogFeature", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("BlogId")
.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<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("FeatureName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
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.HasKey("Id");
b.ToTable("CmsBlogFeatures");
});
modelBuilder.Entity("Volo.CmsKit.Blogs.BlogPost", b =>
{
b.Property<Guid>("Id")

241
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20201224140744_Initial.cs → modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219113255_Initial.cs

@ -39,6 +39,21 @@ namespace Volo.CmsKit.Migrations
table.PrimaryKey("PK_AbpAuditLogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpBlobContainers",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpBlobContainers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AbpClaimTypes",
columns: table => new
@ -251,6 +266,52 @@ namespace Volo.CmsKit.Migrations
table.PrimaryKey("PK_AbpUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CmsBlogFeatures",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
BlogId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
FeatureName = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Enabled = table.Column<bool>(type: "bit", nullable: false),
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_CmsBlogFeatures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CmsBlogs",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Slug = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", 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_CmsBlogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CmsComments",
columns: table => new
@ -306,6 +367,54 @@ namespace Volo.CmsKit.Migrations
table.PrimaryKey("PK_CmsEntityTags", x => new { x.EntityId, x.TagId });
});
migrationBuilder.CreateTable(
name: "CmsMediaDescriptors",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
MimeType = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Size = table.Column<long>(type: "bigint", maxLength: 2147483647, nullable: false),
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_CmsMediaDescriptors", x => x.Id);
});
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),
Slug = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Description = table.Column<string>(type: "nvarchar(512)", maxLength: 512, 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.CreateTable(
name: "CmsRatings",
columns: table => new
@ -328,10 +437,9 @@ namespace Volo.CmsKit.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
EntityType = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: false),
HexColor = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: true),
TenantId = table.Column<Guid>(type: "uniqueidentifier", 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),
@ -435,6 +543,29 @@ namespace Volo.CmsKit.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpBlobs",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ContainerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
Content = table.Column<byte[]>(type: "varbinary(max)", maxLength: 2147483647, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpBlobs", x => x.Id);
table.ForeignKey(
name: "FK_AbpBlobs_AbpBlobContainers_ContainerId",
column: x => x.ContainerId,
principalTable: "AbpBlobContainers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AbpOrganizationUnitRoles",
columns: table => new
@ -617,6 +748,49 @@ namespace Volo.CmsKit.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CmsBlogPosts",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
BlogId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Title = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
Slug = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
ShortDescription = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
TenantId = table.Column<Guid>(type: "uniqueidentifier", 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_CmsBlogPosts", x => x.Id);
table.ForeignKey(
name: "FK_CmsBlogPosts_CmsUsers_CreatorId",
column: x => x.CreatorId,
principalTable: "CmsUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CmsBlogPosts_CmsUsers_DeleterId",
column: x => x.DeleterId,
principalTable: "CmsUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CmsBlogPosts_CmsUsers_LastModifierId",
column: x => x.LastModifierId,
principalTable: "CmsUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AbpEntityPropertyChanges",
columns: table => new
@ -660,6 +834,21 @@ namespace Volo.CmsKit.Migrations
table: "AbpAuditLogs",
columns: new[] { "TenantId", "UserId", "ExecutionTime" });
migrationBuilder.CreateIndex(
name: "IX_AbpBlobContainers_TenantId_Name",
table: "AbpBlobContainers",
columns: new[] { "TenantId", "Name" });
migrationBuilder.CreateIndex(
name: "IX_AbpBlobs_ContainerId",
table: "AbpBlobs",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_AbpBlobs_TenantId_ContainerId_Name",
table: "AbpBlobs",
columns: new[] { "TenantId", "ContainerId", "Name" });
migrationBuilder.CreateIndex(
name: "IX_AbpEntityChanges_AuditLogId",
table: "AbpEntityChanges",
@ -787,6 +976,26 @@ namespace Volo.CmsKit.Migrations
table: "AbpUsers",
column: "UserName");
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.CreateIndex(
name: "IX_CmsBlogPosts_Slug_BlogId",
table: "CmsBlogPosts",
columns: new[] { "Slug", "BlogId" });
migrationBuilder.CreateIndex(
name: "IX_CmsComments_TenantId_EntityType_EntityId",
table: "CmsComments",
@ -807,6 +1016,11 @@ namespace Volo.CmsKit.Migrations
table: "CmsEntityTags",
columns: new[] { "TenantId", "EntityId", "TagId" });
migrationBuilder.CreateIndex(
name: "IX_CmsPages_TenantId_Slug",
table: "CmsPages",
columns: new[] { "TenantId", "Slug" });
migrationBuilder.CreateIndex(
name: "IX_CmsRatings_TenantId_EntityType_EntityId_CreatorId",
table: "CmsRatings",
@ -843,6 +1057,9 @@ namespace Volo.CmsKit.Migrations
migrationBuilder.DropTable(
name: "AbpAuditLogActions");
migrationBuilder.DropTable(
name: "AbpBlobs");
migrationBuilder.DropTable(
name: "AbpClaimTypes");
@ -888,6 +1105,15 @@ namespace Volo.CmsKit.Migrations
migrationBuilder.DropTable(
name: "AbpUserTokens");
migrationBuilder.DropTable(
name: "CmsBlogFeatures");
migrationBuilder.DropTable(
name: "CmsBlogPosts");
migrationBuilder.DropTable(
name: "CmsBlogs");
migrationBuilder.DropTable(
name: "CmsComments");
@ -897,6 +1123,12 @@ namespace Volo.CmsKit.Migrations
migrationBuilder.DropTable(
name: "CmsEntityTags");
migrationBuilder.DropTable(
name: "CmsMediaDescriptors");
migrationBuilder.DropTable(
name: "CmsPages");
migrationBuilder.DropTable(
name: "CmsRatings");
@ -907,7 +1139,7 @@ namespace Volo.CmsKit.Migrations
name: "CmsUserReactions");
migrationBuilder.DropTable(
name: "CmsUsers");
name: "AbpBlobContainers");
migrationBuilder.DropTable(
name: "AbpEntityChanges");
@ -924,6 +1156,9 @@ namespace Volo.CmsKit.Migrations
migrationBuilder.DropTable(
name: "AbpUsers");
migrationBuilder.DropTable(
name: "CmsUsers");
migrationBuilder.DropTable(
name: "AbpAuditLogs");
}

137
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210210105857_Added_Media.Designer.cs → modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.Designer.cs

@ -11,8 +11,8 @@ using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Migrations
{
[DbContext(typeof(UnifiedDbContext))]
[Migration("20210210105857_Added_Media")]
partial class Added_Media
[Migration("20210219144454_BlogFeatureEnabledColumnRename")]
partial class BlogFeatureEnabledColumnRename
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -1191,6 +1191,68 @@ namespace Volo.CmsKit.Migrations
b.ToTable("CmsBlogs");
});
modelBuilder.Entity("Volo.CmsKit.Blogs.BlogFeature", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("BlogId")
.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>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("FeatureName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<bool>("IsEnabled")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.HasKey("Id");
b.ToTable("CmsBlogFeatures");
});
modelBuilder.Entity("Volo.CmsKit.Blogs.BlogPost", b =>
{
b.Property<Guid>("Id")
@ -1457,6 +1519,77 @@ namespace Volo.CmsKit.Migrations
b.ToTable("CmsMediaDescriptors");
});
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(512)
.HasColumnType("nvarchar(512)");
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<string>("Slug")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("TenantId", "Slug");
b.ToTable("CmsPages");
});
modelBuilder.Entity("Volo.CmsKit.Ratings.Rating", b =>
{
b.Property<Guid>("Id")

23
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20210219144454_BlogFeatureEnabledColumnRename.cs

@ -0,0 +1,23 @@
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");
}
}
}

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

@ -1189,6 +1189,68 @@ namespace Volo.CmsKit.Migrations
b.ToTable("CmsBlogs");
});
modelBuilder.Entity("Volo.CmsKit.Blogs.BlogFeature", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<Guid>("BlogId")
.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>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("FeatureName")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<bool>("IsEnabled")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.HasKey("Id");
b.ToTable("CmsBlogFeatures");
});
modelBuilder.Entity("Volo.CmsKit.Blogs.BlogPost", b =>
{
b.Property<Guid>("Id")

4
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Volo.CmsKit.Web.Unified.csproj

@ -62,4 +62,8 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations" />
</ItemGroup>
</Project>

11
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogFeatureInputDto.cs

@ -0,0 +1,11 @@
using System.ComponentModel.DataAnnotations;
namespace Volo.CmsKit.Admin.Blogs
{
public class BlogFeatureInputDto
{
[Required]
public string FeatureName { get; set; }
public bool IsEnabled { get; set; }
}
}

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
namespace Volo.CmsKit.Admin.Blogs

16
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogFeatureAdminAppService.cs

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Blogs;
namespace Volo.CmsKit.Admin.Blogs
{
public interface IBlogFeatureAdminAppService
{
Task SetAsync(Guid blogId, BlogFeatureInputDto dto);
Task<List<BlogFeatureDto>> GetListAsync(Guid blogId);
}
}

1
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs

@ -49,6 +49,7 @@ namespace Volo.CmsKit.Permissions
blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Create, L("Permission:BlogManagement.Create"));
blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Update, L("Permission:BlogManagement.Update"));
blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Delete, L("Permission:BlogManagement.Delete"));
blogManagement.AddChild(CmsKitAdminPermissions.Blogs.Features, L("Permission:BlogManagement.Features"));
var blogPostManagement = cmsGroup.AddPermission(CmsKitAdminPermissions.BlogPosts.Default, L("Permission:BlogPostManagement"));
blogManagement.AddChild(CmsKitAdminPermissions.BlogPosts.Create, L("Permission:BlogPostManagement.Create"));

1
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs

@ -42,6 +42,7 @@ namespace Volo.CmsKit.Permissions
public const string Create = Default + ".Create";
public const string Update = Default + ".Update";
public const string Delete = Default + ".Delete";
public const string Features = Default + ".Features";
}
public static class BlogPosts

49
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminAppService.cs

@ -0,0 +1,49 @@
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Admin.Blogs;
using Volo.CmsKit.Blogs;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Permissions;
namespace Volo.CmsKit.Admin.Blogs
{
[RequiresGlobalFeature(typeof(BlogsFeature))]
public class BlogFeatureAdminAppService : CmsKitAdminAppServiceBase, IBlogFeatureAdminAppService
{
protected IBlogFeatureRepository BlogFeatureRepository { get; }
protected IBlogFeatureManager BlogFeatureManager { get; }
protected IDistributedEventBus EventBus { get; }
public BlogFeatureAdminAppService(
IBlogFeatureRepository blogFeatureRepository,
IBlogFeatureManager blogFeatureManager,
IDistributedEventBus eventBus)
{
BlogFeatureRepository = blogFeatureRepository;
BlogFeatureManager = blogFeatureManager;
EventBus = eventBus;
}
[Authorize(CmsKitAdminPermissions.Blogs.Features)]
public async Task<List<BlogFeatureDto>> GetListAsync(Guid blogId)
{
var blogFeatures = await BlogFeatureManager.GetListAsync(blogId);
return ObjectMapper.Map<List<BlogFeature>, List<BlogFeatureDto>>(blogFeatures);
}
[Authorize(CmsKitAdminPermissions.Blogs.Features)]
public Task SetAsync(Guid blogId, BlogFeatureInputDto dto)
{
return BlogFeatureManager.SetAsync(blogId, dto.FeatureName, dto.IsEnabled);
}
}
}

16
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs

@ -27,11 +27,11 @@ namespace Volo.CmsKit.Admin.Blogs
UpdateBlogPostDto>
, IBlogPostAdminAppService
{
protected readonly IBlogPostManager BlogPostManager;
protected readonly IBlogPostRepository BlogPostRepository;
protected readonly IBlogRepository BlogRepository;
protected readonly IBlobContainer<BlogPostCoverImageContainer> BlobContainer;
protected readonly ICmsUserLookupService UserLookupService;
protected IBlogPostManager BlogPostManager { get; }
protected IBlogPostRepository BlogPostRepository { get; }
protected IBlogRepository BlogRepository { get; }
protected IBlobContainer<BlogPostCoverImageContainer> BlobContainer { get; }
protected ICmsUserLookupService UserLookupService { get; }
public BlogPostAdminAppService(
IRepository<BlogPost, Guid> repository,
@ -60,7 +60,7 @@ namespace Volo.CmsKit.Admin.Blogs
var blogPost = await BlogPostRepository.GetBySlugAsync(blog.Id, blogPostSlug);
return MapToGetOutputDto(blogPost);
return await MapToGetOutputDtoAsync(blogPost);
}
[Authorize(CmsKitAdminPermissions.BlogPosts.Create)]
@ -77,7 +77,7 @@ namespace Volo.CmsKit.Admin.Blogs
input.Slug,
input.ShortDescription));
return MapToGetOutputDto(entity);
return await MapToGetOutputDtoAsync(entity);
}
[Authorize(CmsKitAdminPermissions.BlogPosts.Update)]
@ -96,7 +96,7 @@ namespace Volo.CmsKit.Admin.Blogs
await BlogPostManager.UpdateAsync(blogPost);
return MapToGetOutputDto(blogPost);
return await MapToGetOutputDtoAsync(blogPost);
}
public virtual async Task SetCoverImageAsync(Guid id, RemoteStreamContent streamContent)

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

@ -40,6 +40,8 @@ namespace Volo.CmsKit.Admin
CreateMap<Blog, BlogDto>(MemberList.Destination)
.ReverseMap();
CreateMap<BlogFeature, BlogFeatureDto>();
CreateMap<TagEntityTypeDefiniton, TagDefinitionDto>(MemberList.Destination);
CreateMap<MediaDescriptor, MediaDescriptorDto>();

2
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Contents/ContentAdminAppService.cs

@ -53,7 +53,7 @@ namespace Volo.CmsKit.Admin.Contents
await ContentManager.InsertAsync(entity);
return MapToGetOutputDto(entity);
return await MapToGetOutputDtoAsync(entity);
}
public virtual async Task<ContentDto> GetAsync(

4
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs

@ -50,7 +50,7 @@ namespace Volo.CmsKit.Admin.Tags
input.Name,
CurrentTenant?.Id);
return MapToGetOutputDto(tag);
return await MapToGetOutputDtoAsync(tag);
}
[Authorize(CmsKitAdminPermissions.Tags.Update)]
@ -60,7 +60,7 @@ namespace Volo.CmsKit.Admin.Tags
id,
input.Name);
return MapToGetOutputDto(tag);
return await MapToGetOutputDtoAsync(tag);
}
protected override IQueryable<Tag> CreateFilteredQuery(TagGetListInput input)
{

2
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs

@ -17,7 +17,7 @@ namespace Volo.CmsKit.Admin.Blogs
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Authorize(CmsKitAdminPermissions.Blogs.Default)]
[Route("api/cms-kit-admin/blogs/blogs")]
[Route("api/cms-kit-admin/blogs")]
public class BlogAdminController : CmsKitAdminController, IBlogAdminAppService
{
protected IBlogAdminAppService BlogAdminAppService { get; }

40
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogFeatureAdminController.cs

@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Blogs;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Permissions;
namespace Volo.CmsKit.Admin.Blogs
{
[RequiresGlobalFeature(typeof(BlogsFeature))]
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Authorize(CmsKitAdminPermissions.Blogs.Features)]
[Route("api/cms-kit-admin/blogs/{blogId}/features")]
public class BlogFeatureAdminController : CmsKitAdminController, IBlogFeatureAdminAppService
{
protected IBlogFeatureAdminAppService BlogFeatureAdminAppService { get; }
public BlogFeatureAdminController(IBlogFeatureAdminAppService blogFeatureAdminAppService)
{
BlogFeatureAdminAppService = blogFeatureAdminAppService;
}
[HttpGet]
public Task<List<BlogFeatureDto>> GetListAsync(Guid blogId)
{
return BlogFeatureAdminAppService.GetListAsync(blogId);
}
[HttpPut]
public Task SetAsync(Guid blogId, BlogFeatureInputDto dto)
{
return BlogFeatureAdminAppService.SetAsync(blogId, dto);
}
}
}

3
modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/MediaDescriptors/MediaDescriptorAdminController.cs

@ -1,4 +1,5 @@
using System;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@ -57,7 +58,7 @@ namespace Volo.CmsKit.Admin.MediaDescriptors
var mediaDescriptorDto = await MediaDescriptorAdminAppService.CreateAsync(inputStream);
return StatusCode(201, mediaDescriptorDto);
return StatusCode((int)HttpStatusCode.Created, mediaDescriptorDto);
}
}
}

11
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/BlogFeatureDto.cs

@ -0,0 +1,11 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureDto : EntityDto<Guid>
{
public string FeatureName { get; set; }
public bool IsEnabled { get; set; }
}
}

10
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureAppService.cs

@ -0,0 +1,10 @@
using System;
using System.Threading.Tasks;
namespace Volo.CmsKit.Blogs
{
public interface IBlogFeatureAppService
{
Task<BlogFeatureDto> GetOrDefaultAsync(Guid blogId, string featureName);
}
}

14
modules/cms-kit/src/Volo.CmsKit.Common.Application.Contracts/Volo/CmsKit/Blogs/IBlogFeatureCacheManager.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Volo.CmsKit.Blogs
{
public interface IBlogFeatureCacheManager
{
Task<BlogFeatureDto> AddOrGetAsync(Guid blogId, string featureName, Func<Task<BlogFeatureDto>> factory);
Task ClearAsync(Guid blogId, string featureName);
}
}

25
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo.CmsKit.Common.Application.csproj

@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<Import Project="..\..\..\..\configureawait.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Ddd.Application\Volo.Abp.Ddd.Application.csproj" />
<ProjectReference Include="..\Volo.CmsKit.Common.Application.Contracts\Volo.CmsKit.Common.Application.Contracts.csproj" />
<ProjectReference Include="..\Volo.CmsKit.Domain\Volo.CmsKit.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Ddd.Application\Volo.Abp.Ddd.Application.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Caching\Volo.Abp.Caching.csproj" />
<ProjectReference Include="..\Volo.CmsKit.Common.Application.Contracts\Volo.CmsKit.Common.Application.Contracts.csproj" />
<ProjectReference Include="..\Volo.CmsKit.Domain\Volo.CmsKit.Domain.csproj" />
</ItemGroup>
</Project>

41
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs

@ -0,0 +1,41 @@
using Microsoft.Extensions.Caching.Distributed;
using System;
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.EventBus.Distributed;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureAppService : CmsKitAppServiceBase, IBlogFeatureAppService
{
protected virtual IBlogFeatureRepository BlogFeatureRepository { get; }
protected virtual IBlogFeatureCacheManager BlogFeatureCacheManager { get; }
public BlogFeatureAppService(
IBlogFeatureRepository blogFeatureRepository,
IBlogFeatureCacheManager blogFeatureCacheManager)
{
BlogFeatureRepository = blogFeatureRepository;
BlogFeatureCacheManager = blogFeatureCacheManager;
}
public virtual Task<BlogFeatureDto> GetOrDefaultAsync(Guid blogId, string featureName)
{
return BlogFeatureCacheManager
.AddOrGetAsync(
blogId,
featureName,
()=> GetOrDefaultFroRepositoryAsync(blogId, featureName)
);
}
protected virtual async Task<BlogFeatureDto> GetOrDefaultFroRepositoryAsync(Guid blogId, string featureName)
{
var feature = await BlogFeatureRepository.FindAsync(blogId, featureName);
var blogFeature = feature ?? new BlogFeature(blogId, featureName);
return ObjectMapper.Map<BlogFeature, BlogFeatureDto>(blogFeature);
}
}
}

46
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureCacheManager.cs

@ -0,0 +1,46 @@
using JetBrains.Annotations;
using Microsoft.Extensions.Caching.Distributed;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureCacheManager : IBlogFeatureCacheManager, ITransientDependency
{
protected IDistributedCache<BlogFeatureDto> Cache { get; }
public BlogFeatureCacheManager(IDistributedCache<BlogFeatureDto> cache)
{
Cache = cache;
}
public async Task<BlogFeatureDto> AddOrGetAsync(Guid blogId, string featureName, Func<Task<BlogFeatureDto>> factory)
{
return await Cache.GetOrAddAsync(
GetCacheKey(blogId, featureName),
factory,
() => new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1)
});
}
public Task ClearAsync(Guid blogId, string featureName)
{
return Cache.RemoveAsync(GetCacheKey(blogId, featureName));
}
private string GetCacheKey(Guid blogId, [NotNull] string featureName)
{
Check.NotNullOrWhiteSpace(featureName, nameof(featureName));
return $"{blogId}_{featureName}";
}
}
}

22
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs

@ -0,0 +1,22 @@
using System.Threading.Tasks;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureChangedHandler : IDistributedEventHandler<BlogFeatureChangedEto>, ITransientDependency
{
protected IDistributedCache<BlogFeatureDto> Cache { get; }
public BlogFeatureChangedHandler(IDistributedCache<BlogFeatureDto> cache)
{
Cache = cache;
}
public async Task HandleEventAsync(BlogFeatureChangedEto eventData)
{
await Cache.RemoveAsync($"{eventData.BlogId}_{eventData.FeatureName}");
}
}
}

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

@ -10,8 +10,8 @@ namespace Volo.CmsKit.MediaDescriptors
[RequiresGlobalFeature(typeof(MediaFeature))]
public class MediaDescriptorAppService : CmsKitAppServiceBase, IMediaDescriptorAppService
{
protected readonly IMediaDescriptorRepository MediaDescriptorRepository;
protected readonly IBlobContainer<MediaContainer> MediaContainer;
protected IMediaDescriptorRepository MediaDescriptorRepository { get; }
protected IBlobContainer<MediaContainer> MediaContainer { get; }
public MediaDescriptorAppService(IMediaDescriptorRepository mediaDescriptorRepository, IBlobContainer<MediaContainer> mediaContainer)
{

2
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Tags/TagAppService.cs

@ -9,7 +9,7 @@ namespace Volo.CmsKit.Tags
{
public class TagAppService : CmsKitAppServiceBase, ITagAppService
{
protected readonly ITagRepository TagRepository;
protected ITagRepository TagRepository { get; }
public TagAppService(ITagRepository tagRepository)
{

31
modules/cms-kit/src/Volo.CmsKit.Common.HttpApi/Volo/CmsKit/Blogs/BlogFeatureController.cs

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Blogs;
using Volo.CmsKit.GlobalFeatures;
namespace Volo.CmsKit.Blogs
{
[RequiresGlobalFeature(typeof(BlogsFeature))]
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit/blogs/{blogId}/features")]
public class BlogFeatureController : CmsKitControllerBase, IBlogFeatureAppService
{
protected IBlogFeatureAppService BlogFeatureAppService { get; }
public BlogFeatureController(IBlogFeatureAppService blogFeatureAppService)
{
BlogFeatureAppService = blogFeatureAppService;
}
[HttpGet]
[Route("{featureName}")]
public Task<BlogFeatureDto> GetOrDefaultAsync(Guid blogId, string featureName)
{
return BlogFeatureAppService.GetOrDefaultAsync(blogId, featureName);
}
}
}

17
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.EventBus;
namespace Volo.CmsKit.Blogs
{
[EventName("CmsKit.Blogs.BlogFeature.Changed")]
public class BlogFeatureChangedEto
{
public Guid BlogId { get; set; }
public string FeatureName { get; set; }
public bool IsEnabled { get; set; }
}
}

7
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureConsts.cs

@ -0,0 +1,7 @@
namespace Volo.CmsKit.Blogs
{
public static class BlogFeatureConsts
{
public const int MaxFeatureNameLenth = 64;
}
}

12
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogPostConsts.cs

@ -1,4 +1,6 @@
namespace Volo.CmsKit.Blogs
using Volo.CmsKit.GlobalFeatures;
namespace Volo.CmsKit.Blogs
{
public static class BlogPostConsts
{
@ -11,5 +13,13 @@
public static int MaxShortDescriptionLength { get; set; } = 256;
public const string EntityType = "BlogPost";
public const string CommentsFeatureName = CommentsFeature.Name;
public const string ReactionsFeatureName = ReactionsFeature.Name;
public const string RatingsFeatureName = RatingsFeature.Name;
public const string TagsFeatureName = TagsFeature.Name;
}
}

13
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json

@ -4,7 +4,8 @@
"CmsKit:0002": "Content already exists!",
"CmsKit:0003": "The entity {0} is not taggable.",
"CmsKit:BlogPost:0001": "The given slug already exists!",
"CmsKit:Page:0001": "The given slug ({0}) already exists.",
"CmsKit:Media:0001": "'{Name}' is not a valid media name.",
"CmsKit:Page:0001": "The given url ({0}) already exists.",
"CmsKit:Tag:0002": "The entity is not taggable!",
"CommentAuthorizationExceptionMessage": "Those comments are not allowed for public display.",
"Comments": "Comments",
@ -16,6 +17,7 @@
"LoginToReply": "Login to reply",
"Menu:CMS": "CMS",
"MessageDeletionConfirmationMessage": "This comment will be deleted completely.",
"Permission:BlogManagement.Features": "Features",
"Permission:CmsKit": "CmsKit",
"Permission:Comments": "Comment Management",
"Permission:Comments.Delete": "Delete",
@ -23,6 +25,9 @@
"Permission:Contents.Create": "Create Content",
"Permission:Contents.Delete": "Delete Content",
"Permission:Contents.Update": "Update Content",
"Permission:MediaDescriptorManagement": "Media Management",
"Permission:MediaDescriptorManagement:Create": "Create",
"Permission:MediaDescriptorManagement:Delete": "Delete",
"Permission:PageManagement": "Page Management",
"Permission:PageManagement:Create": "Create",
"Permission:PageManagement:Delete": "Delete",
@ -42,10 +47,6 @@
"Undo": "Undo",
"Update": "Update",
"YourComment": "Your comment",
"YourReply": "Your reply",
"CmsKit:Media:0001": "'{Name}' is not a valid media name.",
"Permission:MediaDescriptorManagement": "Media Management",
"Permission:MediaDescriptorManagement:Create": "Create",
"Permission:MediaDescriptorManagement:Delete": "Delete"
"YourReply": "Your reply"
}
}

1
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/tr.json

@ -16,6 +16,7 @@
"LoginToReply": "Cevap vermek için giriş yap",
"Menu:CMS": "CMS",
"MessageDeletionConfirmationMessage": "Bu yorum tamamen silinecektir",
"Permission:BlogManagement.Features": "Özellikler",
"Permission:CmsKit": "CmsKit",
"Permission:Contents": "İçerik Yönetimi",
"Permission:Contents.Create": "İçerik Oluşturma",

12
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs

@ -20,18 +20,20 @@ namespace Volo.CmsKit.Blogs
TenantId = tenantId;
}
public string Name { get; protected set; }
[NotNull]
public virtual string Name { get; protected set; }
public string Slug { get; protected set; }
[NotNull]
public virtual string Slug { get; protected set; }
public Guid? TenantId { get; protected set; }
public virtual Guid? TenantId { get; protected set; }
public void SetName(string name)
public virtual void SetName(string name)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), maxLength: BlogConsts.MaxNameLength);
}
public void SetSlug(string slug)
public virtual void SetSlug(string slug)
{
Check.NotNullOrWhiteSpace(slug, nameof(slug), maxLength: BlogConsts.MaxNameLength);

28
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeature.cs

@ -0,0 +1,28 @@
using JetBrains.Annotations;
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
namespace Volo.CmsKit.Blogs
{
public class BlogFeature : FullAuditedAggregateRoot<Guid>, IEquatable<BlogFeature>
{
public Guid BlogId { get; protected set; }
public string FeatureName { get; protected set; }
public bool IsEnabled { get; set; } = true;
public BlogFeature(Guid blogId, [NotNull] string featureName, bool isEnabled = true)
{
BlogId = blogId;
FeatureName = Check.NotNullOrWhiteSpace(featureName, nameof(featureName));
IsEnabled = isEnabled;
}
public bool Equals(BlogFeature other)
{
return BlogId == other?.BlogId && FeatureName == other?.FeatureName;
}
}
}

67
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogFeatureManager.cs

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Uow;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureManager : DomainService, IBlogFeatureManager
{
protected IBlogFeatureRepository BlogFeatureRepository { get; }
protected IDefaultBlogFeatureProvider DefaultBlogFeatureProvider { get; }
protected IUnitOfWorkManager UnitOfWorkManager { get; }
protected IDistributedEventBus EventBus { get; }
public BlogFeatureManager(
IBlogFeatureRepository blogFeatureRepository,
IDefaultBlogFeatureProvider defaultBlogFeatureProvider,
IUnitOfWorkManager unitOfWorkManager,
IDistributedEventBus eventBus)
{
BlogFeatureRepository = blogFeatureRepository;
DefaultBlogFeatureProvider = defaultBlogFeatureProvider;
UnitOfWorkManager = unitOfWorkManager;
EventBus = eventBus;
}
public async Task<List<BlogFeature>> GetListAsync(Guid blogId)
{
var blogFeatures = await BlogFeatureRepository.GetListAsync(blogId);
var defaultFeatures = await DefaultBlogFeatureProvider.GetDefaultFeaturesAsync(blogId);
defaultFeatures.ForEach(x => blogFeatures.AddIfNotContains(x));
return blogFeatures;
}
public async Task SetAsync(Guid blogId, string featureName, bool isEnabled)
{
var blogFeature = await BlogFeatureRepository.FindAsync(blogId, featureName);
if (blogFeature == null)
{
var newBlogFeature = new BlogFeature(blogId, featureName, isEnabled);
await BlogFeatureRepository.InsertAsync(newBlogFeature);
}
else
{
blogFeature.IsEnabled = isEnabled;
await BlogFeatureRepository.UpdateAsync(blogFeature);
}
await UnitOfWorkManager.Current.SaveChangesAsync();
await EventBus.PublishAsync(new BlogFeatureChangedEto
{
BlogId = blogId,
FeatureName = featureName,
IsEnabled = isEnabled
});
}
}
}

19
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs

@ -1,10 +1,8 @@
using JetBrains.Annotations;
using System;
using System.Text.RegularExpressions;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;
using Volo.CmsKit.Blogs;
using Volo.CmsKit.Blogs.Extensions;
using Volo.CmsKit.Users;
@ -12,15 +10,18 @@ namespace Volo.CmsKit.Blogs
{
public class BlogPost : FullAuditedAggregateRootWithUser<Guid, CmsUser>, IMultiTenant
{
public Guid BlogId { get; protected set; }
public virtual Guid BlogId { get; protected set; }
public string Title { get; protected set; }
[NotNull]
public virtual string Title { get; protected set; }
public string Slug { get; protected set; }
[NotNull]
public virtual string Slug { get; protected set; }
public string ShortDescription { get; protected set; }
[NotNull]
public virtual string ShortDescription { get; protected set; }
public Guid? TenantId { get; protected set; }
public virtual Guid? TenantId { get; protected set; }
protected BlogPost()
{
@ -39,7 +40,7 @@ namespace Volo.CmsKit.Blogs
ShortDescription = shortDescription;
}
public void SetTitle(string title)
public virtual void SetTitle(string title)
{
Title = Check.NotNullOrWhiteSpace(title, nameof(title), BlogPostConsts.MaxTitleLength);
}
@ -51,7 +52,7 @@ namespace Volo.CmsKit.Blogs
Slug = slug.NormalizeSlug();
}
public void SetShortDescription(string shortDescription)
public virtual void SetShortDescription(string shortDescription)
{
ShortDescription = Check.Length(shortDescription, nameof(shortDescription), BlogPostConsts.MaxShortDescriptionLength);
}

31
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs

@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JetBrains.Annotations;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Services;
@ -10,35 +9,37 @@ namespace Volo.CmsKit.Blogs
{
public class BlogPostManager : DomainService, IBlogPostManager
{
protected readonly IBlogPostRepository blogPostRepository;
protected readonly IBlogRepository blogRepository;
protected IBlogPostRepository BlogPostRepository { get; }
protected IBlogRepository BlogRepository { get; }
public BlogPostManager(
IBlogPostRepository blogPostRepository,
IBlogRepository blogRepository)
{
this.blogPostRepository = blogPostRepository;
this.blogRepository = blogRepository;
BlogPostRepository = blogPostRepository;
BlogRepository = blogRepository;
}
public async Task<BlogPost> CreateAsync(BlogPost blogPost)
public virtual async Task<BlogPost> CreateAsync(BlogPost blogPost)
{
await CheckBlogExistenceAsync(blogPost.BlogId);
await CheckSlugExistenceAsync(blogPost.BlogId, blogPost.Slug);
return await blogPostRepository.InsertAsync(blogPost);
return await BlogPostRepository.InsertAsync(blogPost);
}
public async Task UpdateAsync(BlogPost blogPost)
public virtual async Task UpdateAsync(BlogPost blogPost)
{
await CheckBlogExistenceAsync(blogPost.BlogId);
await blogPostRepository.UpdateAsync(blogPost);
await BlogPostRepository.UpdateAsync(blogPost);
}
public async Task SetSlugUrlAsync(BlogPost blogPost, string newSlug)
public virtual async Task SetSlugUrlAsync(BlogPost blogPost, [NotNull] string newSlug)
{
Check.NotNullOrWhiteSpace(newSlug, nameof(newSlug));
await CheckSlugExistenceAsync(blogPost.BlogId, newSlug);
blogPost.SetSlug(newSlug);
@ -46,7 +47,7 @@ namespace Volo.CmsKit.Blogs
private async Task CheckSlugExistenceAsync(Guid blogId, string slug)
{
if (await blogPostRepository.SlugExistsAsync(blogId, slug))
if (await BlogPostRepository.SlugExistsAsync(blogId, slug))
{
throw new BlogPostSlugAlreadyExistException(blogId, slug);
}
@ -54,7 +55,7 @@ namespace Volo.CmsKit.Blogs
private async Task CheckBlogExistenceAsync(Guid blogId)
{
if (!await blogRepository.ExistsAsync(blogId))
if (!await BlogRepository.ExistsAsync(blogId))
throw new EntityNotFoundException(typeof(Blog), blogId);
}
}

7
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs

@ -1,4 +1,5 @@
using System;
using System.Runtime.Serialization;
using Volo.Abp;
namespace Volo.CmsKit.Blogs
@ -9,7 +10,7 @@ namespace Volo.CmsKit.Blogs
{
}
internal BlogPostSlugAlreadyExistException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext context) : base(serializationInfo, context)
internal BlogPostSlugAlreadyExistException(SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext context) : base(serializationInfo, context)
{
}
@ -24,8 +25,8 @@ namespace Volo.CmsKit.Blogs
WithData(nameof(BlogId), BlogId);
}
public string Slug { get; }
public virtual string Slug { get; }
public Guid BlogId { get; }
public virtual Guid BlogId { get; }
}
}

21
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/DefaultBlogFeatureProvider.cs

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace Volo.CmsKit.Blogs
{
public class DefaultBlogFeatureProvider : IDefaultBlogFeatureProvider, ITransientDependency
{
public virtual Task<List<BlogFeature>> GetDefaultFeaturesAsync(Guid blogId)
{
return Task.FromResult(new List<BlogFeature>
{
new BlogFeature(blogId, BlogPostConsts.CommentsFeatureName),
new BlogFeature(blogId, BlogPostConsts.ReactionsFeatureName),
new BlogFeature(blogId, BlogPostConsts.RatingsFeatureName),
new BlogFeature(blogId, BlogPostConsts.TagsFeatureName),
});
}
}
}

5
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Extensions/SlugExtensions.cs

@ -5,11 +5,10 @@ namespace Volo.CmsKit.Blogs.Extensions
{
public static class SlugExtensions
{
static readonly SlugHelper SlugHelper = new ();
public static string NormalizeSlug(this string value)
{
var slugHelper = new SlugHelper();
return slugHelper.GenerateSlug(value?.Unidecode());
return SlugHelper.GenerateSlug(value?.Unidecode());
}
}
}

17
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureManager.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.CmsKit.Blogs;
namespace Volo.CmsKit.Blogs
{
public interface IBlogFeatureManager : IDomainService
{
Task<List<BlogFeature>> GetListAsync(Guid blogId);
Task SetAsync(Guid blogId, string featureName, bool isEnabled);
}
}

18
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogFeatureRepository.cs

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace Volo.CmsKit.Blogs
{
public interface IBlogFeatureRepository : IBasicRepository<BlogFeature, Guid>
{
Task<List<BlogFeature>> GetListAsync(Guid blogId);
Task<List<BlogFeature>> GetListAsync(Guid blogId, List<string> featureNames);
Task<BlogFeature> FindAsync(Guid blogId, string featureName);
}
}

4
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs

@ -1,4 +1,4 @@
using System;
using JetBrains.Annotations;
using System.Threading.Tasks;
namespace Volo.CmsKit.Blogs
@ -9,6 +9,6 @@ namespace Volo.CmsKit.Blogs
Task UpdateAsync(BlogPost blogPost);
Task SetSlugUrlAsync(BlogPost blogPost, string newSlug);
Task SetSlugUrlAsync(BlogPost blogPost, [NotNull] string newSlug);
}
}

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

5
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs

@ -1,4 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
@ -6,7 +7,7 @@ namespace Volo.CmsKit.Blogs
{
public interface IBlogRepository : IBasicRepository<Blog, Guid>
{
public Task<Blog> GetBySlugAsync(string slug);
Task<bool> ExistsAsync(Guid blogId);
public Task<Blog> GetBySlugAsync(string slug, CancellationToken cancellationToken = default);
Task<bool> ExistsAsync(Guid blogId, CancellationToken cancellationToken = default);
}
}

14
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IDefaultBlogFeatureProvider.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Blogs;
namespace Volo.CmsKit.Blogs
{
public interface IDefaultBlogFeatureProvider
{
Task<List<BlogFeature>> GetDefaultFeaturesAsync(Guid blogId);
}
}

32
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs

@ -8,41 +8,37 @@ namespace Volo.CmsKit.Contents
{
public class Content : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
[CanBeNull]
public virtual Guid? TenantId { get; protected set; }
[NotNull]
public virtual string EntityType { get; protected set; }
[NotNull]
public virtual string EntityId { get; protected set; }
[NotNull]
public virtual string Value { get; protected set; }
[CanBeNull] public virtual Guid? TenantId { get; protected set; }
[NotNull] public virtual string EntityType { get; protected set; }
[NotNull] public virtual string EntityId { get; protected set; }
[NotNull] public virtual string Value { get; protected set; }
protected Content()
{
}
public Content(Guid id, [NotNull] string entityType, [NotNull] string entityId, [NotNull] string value, Guid? tenantId = null) : base(id)
public Content(Guid id, [NotNull] string entityType, [NotNull] string entityId, [NotNull] string value,
Guid? tenantId = null) : base(id)
{
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), ContentConsts.MaxEntityIdLength);
EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength);
Value = Check.NotNullOrEmpty(value, nameof(value), ContentConsts.MaxValueLength);
TenantId = tenantId;
}
public void SetValue([NotNull] string value)
public virtual void SetValue([NotNull] string value)
{
Value = Check.NotNullOrEmpty(value, nameof(value), ContentConsts.MaxValueLength);
}
public void SetEntity([NotNull] string entityType, [NotNull] string entityId)
public virtual void SetEntity([NotNull] string entityType, [NotNull] string entityId)
{
EntityType = Check.NotNullOrEmpty(entityType, nameof(entityType), ContentConsts.MaxEntityTypeLength);
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), ContentConsts.MaxEntityIdLength);
}
}
}
}

0
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/TagAlreadyExistException.cs → modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/ContentAlreadyExistException.cs

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

@ -8,7 +8,7 @@ namespace Volo.CmsKit.Pages
{
public class Page : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
[CanBeNull] public virtual Guid? TenantId { get; set; }
[CanBeNull] public virtual Guid? TenantId { get; protected set; }
[NotNull] public virtual string Title { get; protected set; }

6
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs

@ -8,7 +8,7 @@ namespace Volo.CmsKit.Tags
{
public class Tag : FullAuditedAggregateRoot<Guid>, IMultiTenant
{
public virtual Guid? TenantId { get; set; }
public virtual Guid? TenantId { get; protected set; }
[NotNull]
public virtual string EntityType { get; protected set; }
@ -31,9 +31,9 @@ namespace Volo.CmsKit.Tags
TenantId = tenantId;
}
public virtual void SetName(string name)
public virtual void SetName([NotNull] string name)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name), TagConsts.MaxNameLength);
Name = Check.NotNullOrEmpty(name, nameof(name), TagConsts.MaxNameLength);
}
public virtual void SetEntityType(string entityType)

37
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogFeatureRepository.cs

@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
namespace Volo.CmsKit.Blogs
{
public class EfCoreBlogFeatureRepository : EfCoreRepository<CmsKitDbContext, BlogFeature, Guid>, IBlogFeatureRepository
{
public EfCoreBlogFeatureRepository(IDbContextProvider<CmsKitDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public Task<BlogFeature> FindAsync(Guid blogId, string featureName)
{
return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName);
}
public async Task<List<BlogFeature>> GetListAsync(Guid blogId)
{
return await (await GetQueryableAsync())
.Where(x => x.BlogId == blogId)
.ToListAsync();
}
public async Task<List<BlogFeature>> GetListAsync(Guid blogId, List<string> featureNames)
{
return await (await GetQueryableAsync())
.Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName))
.ToListAsync();
}
}
}

51
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs

@ -10,6 +10,8 @@ using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
using System.Linq;
using System.Data.Common;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
namespace Volo.CmsKit.Blogs
@ -20,30 +22,30 @@ namespace Volo.CmsKit.Blogs
{
}
public async Task<BlogPost> GetBySlugAsync(Guid blogId, string slug, CancellationToken cancellationToken = default)
public async Task<BlogPost> GetBySlugAsync(Guid blogId, [NotNull] string slug,
CancellationToken cancellationToken = default)
{
var dbSet = await GetDbSetAsync();
Check.NotNullOrEmpty(slug, nameof(slug));
return await dbSet
.Include(i=> i.Creator)
.Where(x =>
x.BlogId == blogId && x.Slug.ToLower() == slug)
.FirstOrDefaultAsync(cancellationToken: cancellationToken)
?? throw new EntityNotFoundException(typeof(BlogPost));
return await (await WithDetailsAsync())
.Where(x =>
x.BlogId == blogId && x.Slug.ToLower() == slug)
.FirstOrDefaultAsync(cancellationToken: GetCancellationToken(cancellationToken))
?? throw new EntityNotFoundException(typeof(BlogPost));
}
public async Task<int> GetCountAsync(Guid blogId, CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync()).CountAsync(
x => x.BlogId == blogId,
cancellationToken);
x => x.BlogId == blogId,
GetCancellationToken(cancellationToken));
}
public async Task<List<BlogPost>> GetPagedListAsync(Guid blogId, int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
public async Task<List<BlogPost>> GetPagedListAsync(Guid blogId, int skipCount, int maxResultCount,
string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
{
var queryable = (await GetQueryableAsync())
.Include(i => i.Creator)
.Where(x => x.BlogId == blogId);
var queryable = (await WithDetailsAsync())
.Where(x => x.BlogId == blogId);
if (!sorting.IsNullOrWhiteSpace())
{
@ -51,16 +53,23 @@ namespace Volo.CmsKit.Blogs
}
return await queryable
.Skip(skipCount)
.Take(maxResultCount)
.ToListAsync(cancellationToken);
.Skip(skipCount)
.Take(maxResultCount)
.ToListAsync(GetCancellationToken());
}
public async Task<bool> SlugExistsAsync(Guid blogId, string slug, CancellationToken cancellationToken = default)
public async Task<bool> SlugExistsAsync(Guid blogId, [NotNull] string slug,
CancellationToken cancellationToken = default)
{
var dbSet = await GetDbSetAsync();
Check.NotNullOrEmpty(slug, nameof(slug));
return await dbSet.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, cancellationToken);
return await (await WithDetailsAsync()).AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug,
GetCancellationToken(cancellationToken));
}
public override async Task<IQueryable<BlogPost>> WithDetailsAsync()
{
return (await GetDbSetAsync()).Include(i => i.Creator);
}
}
}
}

12
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs

@ -1,7 +1,10 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
@ -14,14 +17,15 @@ namespace Volo.CmsKit.Blogs
{
}
public async Task<bool> ExistsAsync(Guid blogId)
public virtual async Task<bool> ExistsAsync(Guid blogId, CancellationToken cancellationToken = default)
{
return await (await GetQueryableAsync()).AnyAsync(x => x.Id == blogId);
return await (await GetQueryableAsync()).AnyAsync(x => x.Id == blogId, GetCancellationToken(cancellationToken));
}
public Task<Blog> GetBySlugAsync(string slug)
public virtual Task<Blog> GetBySlugAsync([NotNull]string slug, CancellationToken cancellationToken = default)
{
return GetAsync(x => x.Slug == slug);
Check.NotNullOrEmpty(slug, nameof(slug));
return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
}
}

95
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs

@ -22,7 +22,8 @@ namespace Volo.CmsKit.Comments
{
}
public async Task<CommentWithAuthorQueryResultItem> GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default)
public async Task<CommentWithAuthorQueryResultItem> GetWithAuthorAsync(Guid id,
CancellationToken cancellationToken = default)
{
var query = from comment in (await GetDbSetAsync())
join user in (await GetDbContextAsync()).Set<CmsUser>() on comment.CreatorId equals user.Id
@ -44,60 +45,64 @@ namespace Volo.CmsKit.Comments
}
public async Task<List<CommentWithAuthorQueryResultItem>> GetListAsync(
string filter = null,
string entityType = null,
string entityId = null,
string filter = null,
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default
)
)
{
var token = GetCancellationToken(cancellationToken);
var query = await GetListQueryAsync(
filter,
entityType,
entityId,
filter,
entityType,
entityId,
repliedCommentId,
authorUsername,
creationStartDate,
creationEndDate);
creationStartDate,
creationEndDate,
token);
if (sorting != null)
{
sorting = "comment." + sorting;
}
query = query.OrderBy(sorting ?? "comment.creationTime desc")
.PageBy(skipCount, maxResultCount);
return await query.ToListAsync(GetCancellationToken(cancellationToken));
.PageBy(skipCount, maxResultCount);
return await query.ToListAsync(token);
}
public async Task<long> GetCountAsync(
string text = null,
string entityType = null,
string text = null,
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? repliedCommentId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null,
DateTime? creationEndDate = null,
CancellationToken cancellationToken = default
)
)
{
var token = GetCancellationToken(cancellationToken);
var query = await GetListQueryAsync(
text,
entityType,
entityId,
repliedCommentId,
text,
entityType,
entityId,
repliedCommentId,
authorUsername,
creationStartDate,
creationEndDate);
creationStartDate,
creationEndDate,
token);
return await query.LongCountAsync(GetCancellationToken(cancellationToken));
return await query.LongCountAsync(token);
}
public async Task<List<CommentWithAuthorQueryResultItem>> GetListWithAuthorsAsync(
@ -141,39 +146,35 @@ namespace Volo.CmsKit.Comments
}
protected virtual async Task<IQueryable<CommentWithAuthorQueryResultItem>> GetListQueryAsync(
string filter = null,
string entityType = null,
string filter = null,
string entityType = null,
string entityId = null,
Guid? repliedCommentId = null,
Guid? repliedCommentId = null,
string authorUsername = null,
DateTime? creationStartDate = null,
DateTime? creationEndDate = null
)
DateTime? creationEndDate = null,
CancellationToken cancellationToken = default
)
{
var query = from comment in (await GetDbSetAsync())
join user in (await GetDbContextAsync()).Set<CmsUser>()
var commentDbSet = await GetDbSetAsync();
var cmsUserSet = (await GetDbContextAsync()).Set<CmsUser>();
var query = from comment in commentDbSet
join user in cmsUserSet
on comment.CreatorId equals user.Id
select new CommentWithAuthorQueryResultItem
{
Comment = comment,
Author = user
};
if (!string.IsNullOrWhiteSpace(authorUsername))
{
var author = await (await GetDbContextAsync()).Set<CmsUser>().FirstOrDefaultAsync(x => x.UserName == authorUsername);
var authorId = author?.Id ?? Guid.Empty;
query = query.Where(x => x.Comment.CreatorId == authorId);
}
return query.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Comment.Text.Contains(filter))
.WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.Comment.EntityType.Contains(entityType))
.WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.Comment.EntityId.Contains(entityId))
.WhereIf(repliedCommentId.HasValue, c => c.Comment.RepliedCommentId == repliedCommentId)
.WhereIf(!authorUsername.IsNullOrWhiteSpace(),c=>c.Author.UserName.Contains(authorUsername))
.WhereIf(creationStartDate.HasValue, c => c.Comment.CreationTime >= creationStartDate)
.WhereIf(creationEndDate.HasValue, c => c.Comment.CreationTime <= creationEndDate);
}
}
}
}

13
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Contents/EfCoreContentRepository.cs

@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using System;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
@ -21,6 +22,9 @@ namespace Volo.CmsKit.Contents
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
return GetAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&
@ -35,6 +39,9 @@ namespace Volo.CmsKit.Contents
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
return FindAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&
@ -49,6 +56,9 @@ namespace Volo.CmsKit.Contents
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
return DeleteAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&
@ -62,6 +72,9 @@ namespace Volo.CmsKit.Contents
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
var dbSet = await GetDbSetAsync();
return await dbSet.AnyAsync(x =>
x.EntityType == entityType &&

1
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs

@ -26,6 +26,7 @@ namespace Volo.CmsKit.EntityFrameworkCore
public DbSet<Page> Pages { get; set; }
public DbSet<Blog> Blogs { get; set; }
public DbSet<BlogPost> BlogPosts { get; set; }
public DbSet<BlogFeature> BlogFeatures { get; set; }
public DbSet<MediaDescriptor> MediaDescriptors { get; set; }
public CmsKitDbContext(DbContextOptions<CmsKitDbContext> options)

10
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs

@ -216,11 +216,21 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.HasIndex(x => new { x.Slug, x.BlogId });
});
builder.Entity<BlogFeature>(b =>
{
b.ToTable(options.TablePrefix + "BlogFeatures", options.Schema);
b.ConfigureByConvention();
b.Property(p => p.FeatureName).IsRequired().HasMaxLength(BlogFeatureConsts.MaxFeatureNameLenth);
});
}
else
{
builder.Ignore<Blog>();
builder.Ignore<BlogPost>();
builder.Ignore<BlogFeature>();
}
if (GlobalFeatureManager.Instance.IsEnabled<MediaFeature>())

1
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitEntityFrameworkCoreModule.cs

@ -35,6 +35,7 @@ namespace Volo.CmsKit.EntityFrameworkCore
options.AddRepository<Page, EfCorePageRepository>();
options.AddRepository<Blog, EfCoreBlogRepository>();
options.AddRepository<BlogPost, EfCoreBlogPostRepository>();
options.AddRepository<BlogFeature, EfCoreBlogFeatureRepository>();
options.AddRepository<MediaDescriptor, EfCoreMediaDescriptorRepository>();
});
}

12
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Pages/EfCorePageRepository.cs

@ -4,7 +4,9 @@ using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
@ -43,18 +45,22 @@ namespace Volo.CmsKit.Pages
.ToListAsync(GetCancellationToken(cancellationToken));
}
public virtual Task<Page> GetBySlugAsync(string slug, CancellationToken cancellationToken = default)
public virtual Task<Page> GetBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(slug, nameof(slug));
return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual Task<Page> FindBySlugAsync(string slug, CancellationToken cancellationToken = default)
public virtual Task<Page> FindBySlugAsync([NotNull] string slug, CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(slug, nameof(slug));
return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> ExistsAsync(string slug, CancellationToken cancellationToken = default)
public virtual async Task<bool> ExistsAsync([NotNull] string slug,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(slug, nameof(slug));
return await (await GetDbSetAsync()).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken));
}
}

5
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreEntityTagRepository.cs

@ -3,6 +3,7 @@ using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
@ -30,11 +31,13 @@ namespace Volo.CmsKit.Tags
[CanBeNull] Guid? tenantId,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityId, nameof(entityId));
return base.FindAsync(x =>
x.TagId == tagId &&
x.EntityId == entityId &&
x.TenantId == tenantId,
cancellationToken: cancellationToken);
cancellationToken: GetCancellationToken(cancellationToken));
}
}
}

13
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.CmsKit.EntityFrameworkCore;
@ -23,6 +24,9 @@ namespace Volo.CmsKit.Tags
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(name, nameof(name));
return await (await GetDbSetAsync()).AnyAsync(x =>
x.EntityType == entityType &&
x.Name == name &&
@ -36,6 +40,9 @@ namespace Volo.CmsKit.Tags
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(name, nameof(name));
return GetAsync(x =>
x.EntityType == entityType &&
x.Name == name &&
@ -49,6 +56,9 @@ namespace Volo.CmsKit.Tags
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(name, nameof(name));
return FindAsync(x =>
x.EntityType == entityType &&
x.Name == name &&
@ -62,6 +72,9 @@ namespace Volo.CmsKit.Tags
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
var entityTagIds = await (await GetDbContextAsync()).Set<EntityTag>()
.Where(q => q.EntityId == entityId && q.TenantId == tenantId)
.Select(q => q.TagId)

39
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogFeatureRepository.cs

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MongoDB.Driver.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.CmsKit.Blogs;
using MongoDB.Driver;
namespace Volo.CmsKit.MongoDB.Blogs
{
public class MongoBlogFeatureRepository : MongoDbRepository<ICmsKitMongoDbContext, BlogFeature, Guid> , IBlogFeatureRepository
{
public MongoBlogFeatureRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(dbContextProvider)
{
}
public Task<BlogFeature> FindAsync(Guid blogId, string featureName)
{
return base.FindAsync(x => x.BlogId == blogId && x.FeatureName == featureName);
}
public async Task<List<BlogFeature>> GetListAsync(Guid blogId)
{
return await (await GetMongoQueryableAsync())
.Where(x => x.BlogId == blogId)
.ToListAsync();
}
public async Task<List<BlogFeature>> GetListAsync(Guid blogId, List<string> featureNames)
{
return await (await GetMongoQueryableAsync())
.Where(x => x.BlogId == blogId && featureNames.Contains(x.FeatureName))
.ToListAsync();
}
}
}

51
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs

@ -7,6 +7,8 @@ using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.CmsKit.Blogs;
@ -16,34 +18,40 @@ namespace Volo.CmsKit.MongoDB.Blogs
{
public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, BlogPost, Guid>, IBlogPostRepository
{
public MongoBlogPostRepository(IMongoDbContextProvider<CmsKitMongoDbContext> dbContextProvider) : base(dbContextProvider)
public MongoBlogPostRepository(IMongoDbContextProvider<CmsKitMongoDbContext> dbContextProvider) : base(
dbContextProvider)
{
}
public Task<BlogPost> GetBySlugAsync(Guid blogId, string slug, CancellationToken cancellationToken = default)
public Task<BlogPost> GetBySlugAsync(Guid blogId, [NotNull] string slug,
CancellationToken cancellationToken = default)
{
return GetAsync(x =>
x.BlogId == blogId &&
x.Slug.ToLower() == slug,
includeDetails: true,
cancellationToken: cancellationToken);
Check.NotNullOrEmpty(slug, nameof(slug));
return GetAsync(x =>
x.BlogId == blogId &&
x.Slug.ToLower() == slug,
includeDetails: true,
cancellationToken: GetCancellationToken(cancellationToken));
}
public async Task<int> GetCountAsync(Guid blogId, CancellationToken cancellationToken = default)
{
return await AsyncExecuter.CountAsync(
await WithDetailsAsync(),
x => x.BlogId == blogId,
cancellationToken);
await WithDetailsAsync(),
x => x.BlogId == blogId,
GetCancellationToken(cancellationToken));
}
public async Task<List<BlogPost>> GetPagedListAsync(Guid blogId, int skipCount, int maxResultCount, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
public async Task<List<BlogPost>> GetPagedListAsync(Guid blogId, int skipCount, int maxResultCount,
string sorting, bool includeDetails = false, CancellationToken cancellationToken = default)
{
var dbContext = await GetDbContextAsync(cancellationToken);
var token = GetCancellationToken(cancellationToken);
var dbContext = await GetDbContextAsync(token);
var blogPostQueryable = await WithDetailsAsync();
var queryable = blogPostQueryable
.Where(x => x.BlogId == blogId);
.Where(x => x.BlogId == blogId);
if (!sorting.IsNullOrWhiteSpace())
{
@ -51,17 +59,20 @@ namespace Volo.CmsKit.MongoDB.Blogs
}
queryable = queryable
.Skip(skipCount)
.Take(maxResultCount);
.Skip(skipCount)
.Take(maxResultCount);
return await AsyncExecuter.ToListAsync(queryable, cancellationToken);
return await AsyncExecuter.ToListAsync(queryable, token);
}
public async Task<bool> SlugExistsAsync(Guid blogId, string slug, CancellationToken cancellationToken = default)
public async Task<bool> SlugExistsAsync(Guid blogId, [NotNull] string slug,
CancellationToken cancellationToken = default)
{
var queryable = await GetMongoQueryableAsync();
Check.NotNullOrEmpty(slug, nameof(slug));
return await queryable.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, cancellationToken);
var token = GetCancellationToken(cancellationToken);
var queryable = await GetMongoQueryableAsync(token);
return await queryable.AnyAsync(x => x.BlogId == blogId && x.Slug.ToLower() == slug, token);
}
}
}
}

13
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs

@ -1,6 +1,9 @@
using MongoDB.Driver.Core.Operations;
using System;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.CmsKit.Blogs;
@ -13,16 +16,18 @@ namespace Volo.CmsKit.MongoDB.Blogs
{
}
public async Task<bool> ExistsAsync(Guid blogId)
public virtual async Task<bool> ExistsAsync(Guid blogId, CancellationToken cancellationToken = default)
{
return await AsyncExecuter.AnyAsync(
await GetQueryableAsync(),
x => x.Id == blogId);
x => x.Id == blogId,
cancellationToken);
}
public Task<Blog> GetBySlugAsync(string slug)
public virtual Task<Blog> GetBySlugAsync([NotNull]string slug, CancellationToken cancellationToken = default)
{
return GetAsync(x => x.Slug == slug);
Check.NotNullOrEmpty(slug, nameof(slug));
return GetAsync(x => x.Slug == slug, cancellationToken: cancellationToken);
}
}
}

4
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContext.cs

@ -36,7 +36,9 @@ namespace Volo.CmsKit.MongoDB
public IMongoCollection<Blog> Blogs => Collection<Blog>();
public IMongoCollection<BlogPost> BlogPosts => Collection<BlogPost>();
public IMongoCollection<BlogFeature> BlogFeatures => Collection<BlogFeature>();
public IMongoCollection<MediaDescriptor> MediaDescriptors => Collection<MediaDescriptor>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)

5
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/CmsKitMongoDbContextExtensions.cs

@ -76,6 +76,11 @@ namespace Volo.CmsKit.MongoDB
{
x.CollectionName = CmsKitDbProperties.DbTablePrefix + "BlogPosts";
});
builder.Entity<BlogFeature>(x =>
{
x.CollectionName = CmsKitDbProperties.DbTablePrefix + "BlogFeatures";
});
builder.Entity<MediaDescriptor>(x =>
{

11
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs

@ -56,6 +56,7 @@ namespace Volo.CmsKit.MongoDB.Comments
CancellationToken cancellationToken = default
)
{
var token = GetCancellationToken(cancellationToken);
var query = await GetListQueryAsync(
filter,
entityType,
@ -64,22 +65,22 @@ namespace Volo.CmsKit.MongoDB.Comments
authorUsername,
creationStartDate,
creationEndDate,
cancellationToken);
token);
var comments = await query.OrderBy(sorting ?? "creationTime desc")
.As<IMongoQueryable<Comment>>()
.PageBy<Comment, IMongoQueryable<Comment>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(token);
var commentIds = comments.Select(x => x.Id).ToList();
var authorsQuery = from comment in (await GetMongoQueryableAsync(cancellationToken))
join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id
var authorsQuery = from comment in (await GetMongoQueryableAsync(token))
join user in (await GetDbContextAsync(token)).CmsUsers on comment.CreatorId equals user.Id
where commentIds.Contains(comment.Id)
orderby comment.CreationTime
select user;
var authors = await authorsQuery.ToListAsync(cancellationToken);
var authors = await authorsQuery.ToListAsync(token);
return comments
.Select(

26
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Contents/MongoContentRepository.cs

@ -3,6 +3,7 @@ using MongoDB.Driver.Linq;
using System;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.CmsKit.Contents;
@ -11,7 +12,8 @@ namespace Volo.CmsKit.MongoDB.Contents
{
public class MongoContentRepository : MongoDbRepository<ICmsKitMongoDbContext, Content, Guid>, IContentRepository
{
public MongoContentRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(dbContextProvider)
public MongoContentRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(
dbContextProvider)
{
}
@ -21,6 +23,9 @@ namespace Volo.CmsKit.MongoDB.Contents
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
return GetAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&
@ -28,23 +33,30 @@ namespace Volo.CmsKit.MongoDB.Contents
cancellationToken: GetCancellationToken(cancellationToken)
);
}
public virtual Task<Content> FindAsync(
string entityType,
string entityId,
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
return FindAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&
x.TenantId == tenantId,
cancellationToken: GetCancellationToken(cancellationToken)
);
);
}
public virtual Task DeleteAsync(string entityType, string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
public virtual Task DeleteAsync(string entityType, string entityId, Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
return DeleteAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&
@ -52,8 +64,12 @@ namespace Volo.CmsKit.MongoDB.Contents
cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> ExistsAsync([NotNull] string entityType, [NotNull] string entityId, Guid? tenantId = null, CancellationToken cancellationToken = default)
public virtual async Task<bool> ExistsAsync([NotNull] string entityType, [NotNull] string entityId,
Guid? tenantId = null, CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x =>
x.EntityType == entityType &&
x.EntityId == entityId &&

2
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/ICmsKitMongoDbContext.cs

@ -36,6 +36,8 @@ namespace Volo.CmsKit.MongoDB
IMongoCollection<Blog> Blogs { get; }
IMongoCollection<BlogPost> BlogPosts { get; }
IMongoCollection<BlogFeature> BlogFeatures { get; }
IMongoCollection<MediaDescriptor> MediaDescriptors { get; }
}

34
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Pages/MongoPageRepository.cs

@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using JetBrains.Annotations;
using MongoDB.Driver;
using Volo.Abp;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
@ -14,14 +16,16 @@ namespace Volo.CmsKit.MongoDB.Pages
{
public class MongoPageRepository : MongoDbRepository<ICmsKitMongoDbContext, Page, Guid>, IPageRepository
{
public MongoPageRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(dbContextProvider)
public MongoPageRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(
dbContextProvider)
{
}
public virtual async Task<int> GetCountAsync(string filter = null, CancellationToken cancellationToken = default)
public virtual async Task<int> GetCountAsync(string filter = null,
CancellationToken cancellationToken = default)
{
var cancellation = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellation))
.WhereIf<Page, IMongoQueryable<Page>>(
!filter.IsNullOrWhiteSpace(),
@ -33,12 +37,12 @@ namespace Volo.CmsKit.MongoDB.Pages
public virtual async Task<List<Page>> GetListAsync(
string filter = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
int skipCount = 0,
string sorting = null,
CancellationToken cancellationToken = default)
{
var cancellation = GetCancellationToken(cancellationToken);
return await (await GetMongoQueryableAsync(cancellation))
.WhereIf<Page, IMongoQueryable<Page>>(
!filter.IsNullOrWhiteSpace(),
@ -51,19 +55,23 @@ namespace Volo.CmsKit.MongoDB.Pages
.ToListAsync(cancellation);
}
public virtual Task<Page> GetBySlugAsync(string slug, CancellationToken cancellationToken = default)
public virtual Task<Page> GetBySlugAsync([NotNull]string slug, CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(slug, nameof(slug));
return GetAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual Task<Page> FindBySlugAsync(string slug, CancellationToken cancellationToken = default)
public virtual Task<Page> FindBySlugAsync([NotNull]string slug, CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(slug, nameof(slug));
return FindAsync(x => x.Slug == slug, cancellationToken: GetCancellationToken(cancellationToken));
}
public virtual async Task<bool> ExistsAsync(string slug, CancellationToken cancellationToken = default)
public virtual async Task<bool> ExistsAsync([NotNull]string slug, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.Slug == slug, GetCancellationToken(cancellationToken));
Check.NotNullOrEmpty(slug, nameof(slug));
return await (await GetMongoQueryableAsync(cancellationToken)).AnyAsync(x => x.Slug == slug,
GetCancellationToken(cancellationToken));
}
}
}
}

22
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoEntityTagRepository.cs

@ -4,23 +4,26 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.CmsKit.Tags;
namespace Volo.CmsKit.MongoDB.Tags
{
public class MongoEntityTagRepository: MongoDbRepository<ICmsKitMongoDbContext, EntityTag>, IEntityTagRepository
public class MongoEntityTagRepository : MongoDbRepository<ICmsKitMongoDbContext, EntityTag>, IEntityTagRepository
{
public MongoEntityTagRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(dbContextProvider)
public MongoEntityTagRepository(IMongoDbContextProvider<ICmsKitMongoDbContext> dbContextProvider) : base(
dbContextProvider)
{
}
public async Task DeleteManyAsync(Guid[] tagIds, CancellationToken cancellationToken = default)
{
var collection = await GetCollectionAsync();
await collection.DeleteManyAsync(Builders<EntityTag>.Filter.In(x => x.TagId, tagIds));
var token = GetCancellationToken(cancellationToken);
var collection = await GetCollectionAsync(token);
await collection.DeleteManyAsync(Builders<EntityTag>.Filter.In(x => x.TagId, tagIds), token);
}
public Task<EntityTag> FindAsync(
@ -29,11 +32,12 @@ namespace Volo.CmsKit.MongoDB.Tags
[CanBeNull] Guid? tenantId,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityId, nameof(entityId));
return base.FindAsync(x =>
x.TagId == tagId &&
x.EntityId == entityId &&
x.TenantId == tenantId,
cancellationToken: cancellationToken);
x.TagId == tagId &&
x.EntityId == entityId &&
x.TenantId == tenantId,
cancellationToken: GetCancellationToken(cancellationToken));
}
}
}

10
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
using Volo.CmsKit.Tags;
@ -24,6 +25,9 @@ namespace Volo.CmsKit.MongoDB.Tags
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(name, nameof(name));
return await (await GetMongoQueryableAsync(cancellationToken))
.AnyAsync(x =>
x.EntityType == entityType &&
@ -51,6 +55,9 @@ namespace Volo.CmsKit.MongoDB.Tags
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(name, nameof(name));
return FindAsync(x =>
x.EntityType == entityType &&
x.Name == name &&
@ -64,6 +71,9 @@ namespace Volo.CmsKit.MongoDB.Tags
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
Check.NotNullOrEmpty(entityType, nameof(entityType));
Check.NotNullOrEmpty(entityId, nameof(entityId));
var entityTagIds = await (await GetDbContextAsync(cancellationToken)).EntityTags.AsQueryable()
.Where(q => q.EntityId == entityId && q.TenantId == tenantId)
.Select(q => q.TagId)

13
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/GetBlogFeatureInput.cs

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Volo.CmsKit.Public.Blogs
{
public class GetBlogFeatureInput
{
public List<string> FeatureNames { get; set; }
}
}

7
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
@ -8,9 +9,9 @@ namespace Volo.CmsKit.Public.Blogs
{
public interface IBlogPostPublicAppService
{
Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input);
Task<PagedResultDto<BlogPostPublicDto>> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input);
Task<BlogPostPublicDto> GetAsync(string blogSlug, string blogPostSlug);
Task<BlogPostPublicDto> GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug);
Task<RemoteStreamContent> GetCoverImageAsync(Guid id);
}

9
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
@ -26,7 +27,7 @@ namespace Volo.CmsKit.Public.Blogs
BlobContainer = blobContainer;
}
public async Task<BlogPostPublicDto> GetAsync(string blogSlug, string blogPostSlug)
public virtual async Task<BlogPostPublicDto> GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug)
{
var blog = await BlogRepository.GetBySlugAsync(blogSlug);
@ -35,7 +36,7 @@ namespace Volo.CmsKit.Public.Blogs
return ObjectMapper.Map<BlogPost, BlogPostPublicDto>(blogPost);
}
public async Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input)
public virtual async Task<PagedResultDto<BlogPostPublicDto>> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input)
{
var blog = await BlogRepository.GetBySlugAsync(blogSlug);
@ -46,7 +47,7 @@ namespace Volo.CmsKit.Public.Blogs
ObjectMapper.Map<List<BlogPost>, List<BlogPostPublicDto>>(blogPosts));
}
public async Task<RemoteStreamContent> GetCoverImageAsync(Guid id)
public virtual async Task<RemoteStreamContent> GetCoverImageAsync(Guid id)
{
var stream = await BlobContainer.GetAsync(id.ToString());

4
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/CmsKitPublicApplicationModule.cs

@ -1,12 +1,14 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Caching;
using Volo.Abp.Modularity;
namespace Volo.CmsKit.Public
{
[DependsOn(
typeof(CmsKitCommonApplicationModule),
typeof(CmsKitPublicApplicationContractsModule)
typeof(CmsKitPublicApplicationContractsModule),
typeof(AbpCachingModule)
)]
public class CmsKitPublicApplicationModule : AbpModule
{

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

@ -34,6 +34,8 @@ namespace Volo.CmsKit.Public
CreateMap<Page, PageDto>();
CreateMap<BlogPost, BlogPostPublicDto>(MemberList.None);
CreateMap<BlogFeature, BlogFeatureDto>();
}
}
}

10
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs

@ -1,15 +1,11 @@
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.Application.Dtos;
using Volo.Abp.Content;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Public.Blogs;
namespace Volo.CmsKit.Public.Blogs
{
@ -28,14 +24,14 @@ namespace Volo.CmsKit.Public.Blogs
[HttpGet]
[Route("{blogSlug}/{blogPostSlug}")]
public Task<BlogPostPublicDto> GetAsync(string blogSlug, string blogPostSlug)
public virtual Task<BlogPostPublicDto> GetAsync(string blogSlug, string blogPostSlug)
{
return BlogPostPublicAppService.GetAsync(blogSlug, blogPostSlug);
}
[HttpGet]
[Route("{id}/cover-image")]
public Task<RemoteStreamContent> GetCoverImageAsync(Guid id)
public virtual Task<RemoteStreamContent> GetCoverImageAsync(Guid id)
{
Response.Headers.Add("Content-Disposition", $"inline;filename=\"{id}\"");
Response.Headers.Add("Accept-Ranges", "bytes");
@ -47,7 +43,7 @@ namespace Volo.CmsKit.Public.Blogs
[HttpGet]
[Route("{blogSlug}")]
public Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input)
public virtual Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input)
{
return BlogPostPublicAppService.GetListAsync(blogSlug, input);
}

10
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs

@ -1,27 +1,29 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Contents;
using Volo.CmsKit.GlobalFeatures;
namespace Volo.CmsKit.Public.Contents
{
[RequiresGlobalFeature(typeof(ContentsFeature))]
[RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)]
[Area("cms-kit")]
[Route("api/cms-kit-public/contents")]
public class ContentController : CmsKitControllerBase, IContentPublicAppService
{
protected readonly IContentPublicAppService _contentAppService;
protected IContentPublicAppService ContentAppService { get; }
public ContentController(IContentPublicAppService contentAppService)
{
_contentAppService = contentAppService;
ContentAppService = contentAppService;
}
[HttpGet]
public virtual Task<ContentDto> GetAsync(GetContentInput input)
{
return _contentAppService.GetAsync(input);
return ContentAppService.GetAsync(input);
}
}
}

2
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Tags/TagPublicController.cs

@ -14,7 +14,7 @@ namespace Volo.CmsKit.Public.Tags
[Route("api/cms-kit-public/tags")]
public class TagPublicController : CmsKitPublicControllerBase, ITagAppService
{
protected readonly ITagAppService TagAppService;
protected ITagAppService TagAppService { get; }
public TagPublicController(ITagAppService tagAppService)
{

44
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml

@ -26,38 +26,50 @@
@if (GlobalFeatureManager.Instance.IsEnabled<TagsFeature>())
{
@await Component.InvokeAsync(typeof(TagViewComponent), new
if (Model.TagsFeature?.IsEnabled == true)
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
@await Component.InvokeAsync(typeof(TagViewComponent), new
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
}
}
@if (GlobalFeatureManager.Instance.IsEnabled<ReactionsFeature>())
{
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new
if (Model.ReactionsFeature?.IsEnabled == true)
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
}
}
@if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>())
{
@await Component.InvokeAsync(typeof(RatingViewComponent), new
if (Model.RatingsFeature?.IsEnabled == true)
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
@await Component.InvokeAsync(typeof(RatingViewComponent), new
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
}
}
<hr />
@if (GlobalFeatureManager.Instance.IsEnabled<CommentsFeature>())
{
@await Component.InvokeAsync(typeof(DefaultBlogPostCommentViewComponent), new
if (Model.CommentsFeature?.IsEnabled == true)
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
@await Component.InvokeAsync(typeof(DefaultBlogPostCommentViewComponent), new
{
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType,
entityId = Model.BlogPost.Id.ToString()
})
}
}

41
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Blogs/BlogPost.cshtml.cs

@ -2,8 +2,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.GlobalFeatures;
using Volo.CmsKit.Blogs;
using Volo.CmsKit.GlobalFeatures;
using Volo.CmsKit.Public.Blogs;
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Blogs
@ -18,16 +22,49 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Blogs
public BlogPostPublicDto BlogPost { get; private set; }
public BlogFeatureDto CommentsFeature { get; private set; }
public BlogFeatureDto ReactionsFeature { get; private set; }
public BlogFeatureDto RatingsFeature { get; private set; }
public BlogFeatureDto TagsFeature { get; private set; }
protected IBlogPostPublicAppService BlogPostPublicAppService { get; }
public BlogPostModel(IBlogPostPublicAppService blogPostPublicAppService)
protected IBlogFeatureAppService BlogFeatureAppService { get; }
public BlogPostModel(
IBlogPostPublicAppService blogPostPublicAppService,
IBlogFeatureAppService blogFeaturePublicAppService)
{
BlogPostPublicAppService = blogPostPublicAppService;
BlogFeatureAppService = blogFeaturePublicAppService;
}
public async Task OnGetAsync()
public virtual async Task OnGetAsync()
{
BlogPost = await BlogPostPublicAppService.GetAsync(BlogSlug, BlogPostSlug);
if (GlobalFeatureManager.Instance.IsEnabled<CommentsFeature>())
{
CommentsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, BlogPostConsts.CommentsFeatureName);
}
if (GlobalFeatureManager.Instance.IsEnabled<ReactionsFeature>())
{
ReactionsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, BlogPostConsts.ReactionsFeatureName);
}
if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>())
{
RatingsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, BlogPostConsts.RatingsFeatureName);
}
if (GlobalFeatureManager.Instance.IsEnabled<TagsFeature>())
{
TagsFeature = await BlogFeatureAppService.GetOrDefaultAsync(BlogPost.BlogId, BlogPostConsts.TagsFeatureName);
}
}
}
}

67
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeatureAdminAppService_Test.cs

@ -0,0 +1,67 @@
using Shouldly;
using System.Threading.Tasks;
using Volo.CmsKit.Admin.Blogs;
using Xunit;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureAdminAppService_Test : CmsKitApplicationTestBase
{
private readonly CmsKitTestData testData;
private readonly IBlogFeatureAdminAppService blogFeatureAdminAppService;
private readonly IBlogFeatureRepository blogFeatureRepository;
public BlogFeatureAdminAppService_Test()
{
testData = GetRequiredService<CmsKitTestData>();
blogFeatureAdminAppService = GetRequiredService<IBlogFeatureAdminAppService>();
blogFeatureRepository = GetRequiredService<IBlogFeatureRepository>();
}
[Fact]
public async Task SetAsync_ShouldWorkProperly_WithNonExistingFeature()
{
var dto = new BlogFeatureInputDto
{
FeatureName = "My.Awesome.Feature",
IsEnabled = true
};
await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto);
var feature = await blogFeatureRepository.FindAsync(testData.Blog_Id, dto.FeatureName);
feature.ShouldNotBeNull();
feature.BlogId.ShouldBe(testData.Blog_Id);
feature.IsEnabled.ShouldBe(dto.IsEnabled);
}
[Fact]
public async Task SetAsync_ShouldWorkProperly_WithExistingFeature()
{
var dto = new BlogFeatureInputDto
{
FeatureName = testData.BlogFeature_2_FeatureName,
IsEnabled = !testData.BlogFeature_2_Enabled
};
await blogFeatureAdminAppService.SetAsync(testData.Blog_Id, dto);
var feature = await blogFeatureRepository.FindAsync(testData.Blog_Id, dto.FeatureName);
feature.ShouldNotBeNull();
feature.BlogId.ShouldBe(testData.Blog_Id);
feature.IsEnabled.ShouldBe(dto.IsEnabled);
}
[Fact]
public async Task GetListAsync_ShouldWorkProperly_WithBlogId()
{
var result = await blogFeatureAdminAppService.GetListAsync(testData.Blog_Id);
result.ShouldNotBeNull();
result.ShouldNotBeEmpty();
result.Count.ShouldBeGreaterThan(2); // 2 are seeded and there are built-in Features.
}
}
}

43
modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogFeaturePublicAppService_Test.cs

@ -0,0 +1,43 @@
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Public.Blogs;
using Xunit;
namespace Volo.CmsKit.Blogs
{
public class BlogFeaturePublicAppService_Test : CmsKitApplicationTestBase
{
private readonly CmsKitTestData testData;
private readonly IBlogFeatureAppService blogFeatureAppService;
public BlogFeaturePublicAppService_Test()
{
testData = GetRequiredService<CmsKitTestData>();
blogFeatureAppService = GetRequiredService<IBlogFeatureAppService>();
}
[Fact]
public async Task GetAsync_ShouldWorkProperly_WithExistingFeatureName()
{
var result = await blogFeatureAppService.GetOrDefaultAsync(testData.Blog_Id, testData.BlogFeature_1_FeatureName);
result.ShouldNotBeNull();
result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName);
}
[Fact]
public async Task GetAsync_ShouldReturnDefault_WithNonExistingFeatureName()
{
var nonExistingFeatureName = "AnyOtherFeature";
var result = await blogFeatureAppService.GetOrDefaultAsync(testData.Blog_Id, nonExistingFeatureName);
var defaultFeature = new BlogFeature(Guid.Empty, nonExistingFeatureName);
result.ShouldNotBeNull();
result.IsEnabled.ShouldBe(defaultFeature.IsEnabled);
}
}
}

14
modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Blogs/BlogFeatureRepository_Test.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Blogs;
namespace Volo.CmsKit.EntityFrameworkCore.Blogs
{
public class BlogFeatureRepository_Test : BlogFeatureRepository_Test<CmsKitEntityFrameworkCoreTestModule>
{
}
}

14
modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Blogs/BlogFeatureRepository_Test.cs

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Blogs;
namespace Volo.CmsKit.MongoDB.Blogs
{
public class BlogFeatureRepository_Test : BlogFeatureRepository_Test<CmsKitMongoDbTestModule>
{
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save