diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs index 9fed054cae..68091c7f2d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Comments/CommentConsts.cs +++ b/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 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; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Entities/CmsEntityConsts.cs new file mode 100644 index 0000000000..7176240196 --- /dev/null +++ b/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; + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs index be9b10af1b..e89067f869 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Reactions/UserReactionConsts.cs +++ b/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 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; } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs index a0ee37ccb7..06e22aa919 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/Comment.cs @@ -38,8 +38,8 @@ namespace Volo.CmsKit.Comments Guid? tenantId = null) : base(id) { - EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.EntityTypeLength); - EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.EntityIdLength); + EntityType = Check.NotNullOrWhiteSpace(entityType, nameof(entityType), CommentConsts.MaxEntityTypeLength); + EntityId = Check.NotNullOrWhiteSpace(entityId, nameof(entityId), CommentConsts.MaxEntityIdLength); RepliedCommentId = repliedCommentId; CreatorId = creatorId; TenantId = tenantId; diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs index cb7a7b78d6..e945ddc7ed 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs +++ b/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.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.EntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.EntityIdLength); - b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.ReactionNameLength); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); + b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); b.Property(x => x.CreationTime); b.HasIndex(x => new { x.EntityType, x.EntityId }); @@ -51,8 +51,8 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ToTable(options.TablePrefix + "Comments", options.Schema); b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.EntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.EntityIdLength); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); b.Property(x => x.RepliedCommentId); b.Property(x => x.CreationTime); diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs index ebbc41898e..a0bcbfd6bd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Comments/CreateCommentInput.cs +++ b/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 { [Required] - [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityTypeLength))] + [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityTypeLength))] public string EntityType { get; set; } [Required] - [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.EntityIdLength))] + [DynamicStringLength(typeof(CommentConsts), nameof(CommentConsts.MaxEntityIdLength))] public string EntityId { get; set; } [Required]