Browse Source

CmsKit: Implement Multi-Tenancy for UserReaction ve Comment.

pull/5016/head
Yunus Emre Kalkan 6 years ago
parent
commit
297dfefc64
  1. 1194
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.Designer.cs
  2. 32
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs
  3. 8
      modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/UnifiedDbContextModelSnapshot.cs
  4. 9
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs
  5. 4
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionManager.cs
  6. 9
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/UserReaction.cs
  7. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Comments/CommentPublicAppService.cs

1194
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.Designer.cs

File diff suppressed because it is too large

32
modules/cms-kit/host/Volo.CmsKit.Web.Unified/Migrations/20200807070949_Reaction_Comment_Multitenancy.cs

@ -0,0 +1,32 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.CmsKit.Migrations
{
public partial class Reaction_Comment_Multitenancy : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "TenantId",
table: "CmsUserReactions",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "TenantId",
table: "CmsComments",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "TenantId",
table: "CmsUserReactions");
migrationBuilder.DropColumn(
name: "TenantId",
table: "CmsComments");
}
}
}

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

@ -939,6 +939,10 @@ namespace Volo.CmsKit.Migrations
b.Property<Guid?>("RepliedCommentId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("TenantId")
.HasColumnName("TenantId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(512)")
@ -982,6 +986,10 @@ namespace Volo.CmsKit.Migrations
.HasColumnType("nvarchar(32)")
.HasMaxLength(32);
b.Property<Guid?>("TenantId")
.HasColumnName("TenantId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("EntityType", "EntityId");

9
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs

@ -3,11 +3,14 @@ using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace Volo.CmsKit.Comments
{
public class Comment: Entity<Guid>, IAggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator
public class Comment: Entity<Guid>, IAggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }
public virtual string EntityType { get; protected set; }
public virtual string EntityId { get; protected set; }
@ -31,13 +34,15 @@ namespace Volo.CmsKit.Comments
[NotNull] string entityId,
[NotNull] string text,
Guid? repliedCommentId,
Guid creatorId)
Guid creatorId,
Guid? tenantId = null)
: base(id)
{
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.EntityTypeLength);
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.EntityIdLength);
RepliedCommentId = repliedCommentId;
CreatorId = creatorId;
TenantId = tenantId;
SetText(text);
}

4
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/ReactionManager.cs

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.MultiTenancy;
namespace Volo.CmsKit.Reactions
{
@ -72,7 +73,8 @@ namespace Volo.CmsKit.Reactions
entityType,
entityId,
reactionName,
creatorId
creatorId,
CurrentTenant.GetId()
)
);
}

9
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Reactions/UserReaction.cs

@ -3,11 +3,14 @@ using JetBrains.Annotations;
using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace Volo.CmsKit.Reactions
{
public class UserReaction : Entity<Guid>, IAggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator
public class UserReaction : Entity<Guid>, IAggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }
public virtual string EntityType { get; protected set; }
public virtual string EntityId { get; protected set; }
@ -28,13 +31,15 @@ namespace Volo.CmsKit.Reactions
[NotNull] string entityType,
[NotNull] string entityId,
[NotNull] string reactionName,
Guid creatorId)
Guid creatorId,
Guid? tenantId = null)
: base(id)
{
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType));
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId));
ReactionName = Check.NotNullOrWhiteSpace(reactionName, nameof(reactionName));
CreatorId = creatorId;
TenantId = tenantId;
}
}
}

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

@ -8,6 +8,7 @@ using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Authorization;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Users;
using Volo.CmsKit.Comments;
using Volo.CmsKit.Users;
@ -57,7 +58,8 @@ namespace Volo.CmsKit.Public.Comments
input.EntityId,
input.Text,
input.RepliedCommentId,
user.Id
user.Id,
CurrentTenant.GetId()
));
return ObjectMapper.Map<Comment, CommentDto>(comment);

Loading…
Cancel
Save