Browse Source

Refactor constants.

pull/5052/head
Halil İbrahim Kalkan 6 years ago
parent
commit
70b595f59d
  1. 8
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs
  2. 9
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs
  3. 10
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs
  4. 4
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs
  5. 10
      modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs
  6. 4
      modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs

8
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs

@ -1,10 +1,12 @@
namespace Volo.CmsKit.Comments using Volo.CmsKit.Entities;
namespace Volo.CmsKit.Comments
{ {
public static class CommentConsts public static class CommentConsts
{ {
public static int EntityTypeLength { get; set; } = 64; public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength;
public static int EntityIdLength { get; set; } = 64; public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength;
public static int MaxTextLength { get; set; } = 512; public static int MaxTextLength { get; set; } = 512;
} }

9
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs

@ -0,0 +1,9 @@
namespace Volo.CmsKit.Entities
{
public class CmsEntityConsts
{
public static int MaxEntityTypeLength { get; set; } = 64;
public static int MaxEntityIdLength { get; set; } = 64;
}
}

10
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs

@ -1,11 +1,13 @@
namespace Volo.CmsKit.Reactions using Volo.CmsKit.Entities;
namespace Volo.CmsKit.Reactions
{ {
public static class UserReactionConsts public static class UserReactionConsts
{ {
public static int EntityTypeLength { get; set; } = 64; public static int MaxEntityTypeLength { get; set; } = CmsEntityConsts.MaxEntityTypeLength;
public static int EntityIdLength { get; set; } = 64; public static int MaxEntityIdLength { get; set; } = CmsEntityConsts.MaxEntityIdLength;
public static int ReactionNameLength { get; set; } = 32; public static int MaxReactionNameLength { get; set; } = 32;
} }
} }

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

@ -38,8 +38,8 @@ namespace Volo.CmsKit.Comments
Guid? tenantId = null) Guid? tenantId = null)
: base(id) : base(id)
{ {
EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.EntityTypeLength); EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength);
EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.EntityIdLength); EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength);
RepliedCommentId = repliedCommentId; RepliedCommentId = repliedCommentId;
CreatorId = creatorId; CreatorId = creatorId;
TenantId = tenantId; TenantId = tenantId;

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

@ -37,9 +37,9 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ToTable(options.TablePrefix + "UserReactions", options.Schema); b.ToTable(options.TablePrefix + "UserReactions", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.EntityTypeLength); b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength);
b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.EntityIdLength); b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength);
b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.ReactionNameLength); b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength);
b.Property(x => x.CreationTime); b.Property(x => x.CreationTime);
b.HasIndex(x => new { x.EntityType, x.EntityId }); b.HasIndex(x => new { x.EntityType, x.EntityId });
@ -51,8 +51,8 @@ namespace Volo.CmsKit.EntityFrameworkCore
b.ToTable(options.TablePrefix + "Comments", options.Schema); b.ToTable(options.TablePrefix + "Comments", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.EntityTypeLength); b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength);
b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.EntityIdLength); b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength);
b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength);
b.Property(x => x.RepliedCommentId); b.Property(x => x.RepliedCommentId);
b.Property(x => x.CreationTime); b.Property(x => x.CreationTime);

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

@ -8,11 +8,11 @@ namespace Volo.CmsKit.Public.Comments
public class CreateCommentInput public class CreateCommentInput
{ {
[Required] [Required]
[DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityTypeLength))] [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityTypeLength))]
public string EntityType { get; set; } public string EntityType { get; set; }
[Required] [Required]
[DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityIdLength))] [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityIdLength))]
public string EntityId { get; set; } public string EntityId { get; set; }
[Required] [Required]

Loading…
Cancel
Save