From cb0afcbe27a8c3a5e725a05ca88fb6335f02448d Mon Sep 17 00:00:00 2001 From: Ahmet Date: Tue, 16 Feb 2021 16:57:15 +0300 Subject: [PATCH 01/25] Added CommentAdminAppService dtos --- .../Volo/CmsKit/Admin/Comments/CommentDto.cs | 21 +++++++++++++++ .../Admin/Comments/CommentGetListInput.cs | 22 +++++++++++++++ .../Admin/Comments/CommentWithDetailsDto.cs | 27 +++++++++++++++++++ .../Admin/Comments/ICommentAdminAppService.cs | 15 +++++++++++ 4 files changed, 85 insertions(+) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithDetailsDto.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs new file mode 100644 index 0000000000..bf43a1e50a --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentDto.cs @@ -0,0 +1,21 @@ +using System; + +namespace Volo.CmsKit.Admin.Comments +{ + public class CommentDto + { + public Guid Id { get; set; } + + public string EntityType { get; set; } + + public string EntityId { get; set; } + + public string Text { get; set; } + + public Guid? RepliedCommentId { get; set; } + + public Guid CreatorId { get; set; } + + public DateTime CreationTime { get; set; } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs new file mode 100644 index 0000000000..2113f93e99 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -0,0 +1,22 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace Volo.CmsKit.Admin.Comments +{ + public class CommentGetListInput : PagedAndSortedResultRequestDto + { + public string EntityType { get; set; } + + public string EntityId { get; set; } + + public string Text { get; set; } + + public Guid? RepliedCommentId { get; set; } + + public Guid CreatorId { get; set; } + + public DateTime CreationStartDate { get; set; } + + public DateTime CreationEndDate { get; set; } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithDetailsDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithDetailsDto.cs new file mode 100644 index 0000000000..451b30ba86 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithDetailsDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Volo.CmsKit.Users; + +namespace Volo.CmsKit.Admin.Comments +{ + public class CommentWithDetailsDto + { + public Guid Id { get; set; } + + public string EntityType { get; set; } + + public string EntityId { get; set; } + + public string Text { get; set; } + + public Guid? RepliedCommentId { get; set; } + + public Guid CreatorId { get; set; } + + public DateTime CreationTime { get; set; } + + public List Replies { get; set; } + + public CmsUserDto Author { get; set; } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs new file mode 100644 index 0000000000..54b07c6f0a --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs @@ -0,0 +1,15 @@ +using System.Linq.Dynamic.Core; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; + +namespace Volo.CmsKit.Admin.Comments +{ + public interface ICommentAdminAppService : IApplicationService + { + Task> GetListAsync(CommentGetListInput input); + + Task GetAsync(string entityType, string entityId); + + Task DeleteAsync(string entityType, string entityId); + } +} \ No newline at end of file From 1843bae87137ebf3c1f50d58c12d2d39248793ff Mon Sep 17 00:00:00 2001 From: Ahmet Date: Tue, 16 Feb 2021 18:00:12 +0300 Subject: [PATCH 02/25] Added get comment to CommentAdminAppService --- .../Volo/CmsKit/Admin/Comments/CmsUserDto.cs | 15 +++++++ ...hDetailsDto.cs => CommentWithAuthorDto.cs} | 4 +- .../Admin/Comments/ICommentAdminAppService.cs | 7 ++-- ...CmsKitAdminApplicationAutoMapperProfile.cs | 11 ++++- .../Admin/Comments/CommentAdminAppService.cs | 40 +++++++++++++++++++ .../CmsKit/Comments/ICommentRepository.cs | 2 + .../Comments/EfCoreCommentRepository.cs | 22 ++++++++++ .../Comments/MongoCommentRepository.cs | 22 ++++++++++ 8 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs rename modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/{CommentWithDetailsDto.cs => CommentWithAuthorDto.cs} (84%) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs new file mode 100644 index 0000000000..90eb3d7fb2 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CmsUserDto.cs @@ -0,0 +1,15 @@ +using System; + +namespace Volo.CmsKit.Admin.Comments +{ + public class CmsUserDto + { + public Guid Id { get; set; } + + public string UserName { get; set; } + + public string Name { get; set; } + + public string Surname { get; set; } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithDetailsDto.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithAuthorDto.cs similarity index 84% rename from modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithDetailsDto.cs rename to modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithAuthorDto.cs index 451b30ba86..833a52180b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithDetailsDto.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentWithAuthorDto.cs @@ -4,7 +4,7 @@ using Volo.CmsKit.Users; namespace Volo.CmsKit.Admin.Comments { - public class CommentWithDetailsDto + public class CommentWithAuthorDto { public Guid Id { get; set; } @@ -20,8 +20,6 @@ namespace Volo.CmsKit.Admin.Comments public DateTime CreationTime { get; set; } - public List Replies { get; set; } - public CmsUserDto Author { get; set; } } } \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs index 54b07c6f0a..48fbd2d108 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs @@ -1,4 +1,5 @@ -using System.Linq.Dynamic.Core; +using System; +using System.Linq.Dynamic.Core; using System.Threading.Tasks; using Volo.Abp.Application.Services; @@ -8,8 +9,8 @@ namespace Volo.CmsKit.Admin.Comments { Task> GetListAsync(CommentGetListInput input); - Task GetAsync(string entityType, string entityId); + Task GetAsync(Guid id); - Task DeleteAsync(string entityType, string entityId); + Task DeleteAsync(Guid id); } } \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs index 33a9d9de84..f5624c5046 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/CmsKitAdminApplicationAutoMapperProfile.cs @@ -1,14 +1,18 @@ using AutoMapper; +using Volo.Abp.AutoMapper; using Volo.CmsKit.Admin.Blogs; +using Volo.CmsKit.Admin.Comments; using Volo.CmsKit.Admin.Contents; using Volo.CmsKit.Admin.MediaDescriptors; using Volo.CmsKit.Admin.Pages; using Volo.CmsKit.Blogs; using Volo.CmsKit.Admin.Tags; +using Volo.CmsKit.Comments; using Volo.CmsKit.Contents; using Volo.CmsKit.MediaDescriptors; using Volo.CmsKit.Pages; using Volo.CmsKit.Tags; +using Volo.CmsKit.Users; namespace Volo.CmsKit.Admin { @@ -16,6 +20,12 @@ namespace Volo.CmsKit.Admin { public CmsKitAdminApplicationAutoMapperProfile() { + CreateMap(); + + CreateMap(); + CreateMap() + .Ignore(x=> x.Author); + CreateMap(); CreateMap(MemberList.Destination); @@ -24,7 +34,6 @@ namespace Volo.CmsKit.Admin CreateMap(MemberList.Source); CreateMap(MemberList.Destination); - CreateMap(MemberList.Source); CreateMap(MemberList.Destination) .ReverseMap(); diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs new file mode 100644 index 0000000000..44c763cd7c --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -0,0 +1,40 @@ +using System; +using System.Linq.Dynamic.Core; +using System.Threading.Tasks; +using Volo.CmsKit.Comments; +using Volo.CmsKit.Users; + +namespace Volo.CmsKit.Admin.Comments +{ + public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAppService + { + protected readonly ICommentRepository CommentRepository; + + public CommentAdminAppService(ICommentRepository commentRepository) + { + CommentRepository = commentRepository; + } + + public virtual Task> GetListAsync(CommentGetListInput input) + { + throw new System.NotImplementedException(); + } + + public virtual async Task GetAsync(Guid id) + { + var comment = await CommentRepository.GetWithAuthorAsync(id); + + var dto = ObjectMapper.Map(comment.Comment); + dto.Author = ObjectMapper.Map(comment.Author); + + return dto; + } + + public virtual async Task DeleteAsync(Guid id) + { + var comment = await CommentRepository.GetAsync(id); + + await CommentRepository.DeleteWithRepliesAsync(comment); + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs index 0c61a22f02..523b03dd2f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs @@ -9,6 +9,8 @@ namespace Volo.CmsKit.Comments { public interface ICommentRepository : IBasicRepository { + Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default); + Task> GetListWithAuthorsAsync( [NotNull] string entityType, [NotNull] string entityId, diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 40496aaef8..725aa64e89 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Volo.Abp; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; @@ -20,6 +21,27 @@ namespace Volo.CmsKit.Comments { } + public async Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default) + { + var query = from comment in (await GetDbSetAsync()) + join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id + where id == comment.Id + select new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = user + }; + + var commentWithAuthor = await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + + if (commentWithAuthor == null) + { + throw new EntityNotFoundException(typeof(Comment), id); + } + + return commentWithAuthor; + } + public async Task> GetListWithAuthorsAsync( string entityType, string entityId, diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 5d16c6d55c..7e6a434c3f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using MongoDB.Driver.Linq; using MongoDB.Driver; using Volo.Abp; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Comments; @@ -18,6 +19,27 @@ namespace Volo.CmsKit.MongoDB.Comments { } + public async Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default) + { + var query = from comment in (await GetMongoQueryableAsync(cancellationToken)) + join user in (await GetDbContextAsync(cancellationToken)).CmsUsers on comment.CreatorId equals user.Id + where id == comment.Id + select new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = user + }; + + var commentWithAuthor = await query.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + + if (commentWithAuthor == null) + { + throw new EntityNotFoundException(typeof(Comment), id); + } + + return commentWithAuthor; + } + public async Task> GetListWithAuthorsAsync( string entityType, string entityId, From 681414dcd744143bc04ed5caa3d7e67c5a540d4f Mon Sep 17 00:00:00 2001 From: Ahmet Date: Tue, 16 Feb 2021 18:37:39 +0300 Subject: [PATCH 03/25] Added getlist to comment appservice and repositories --- .../Admin/Comments/CommentGetListInput.cs | 2 + .../Admin/Comments/ICommentAdminAppService.cs | 4 +- .../Admin/Comments/CommentAdminAppService.cs | 30 ++++++- .../CmsKit/Comments/ICommentRepository.cs | 25 ++++++ .../Comments/EfCoreCommentRepository.cs | 72 +++++++++++++++++ .../Comments/MongoCommentRepository.cs | 79 ++++++++++++++++++- 6 files changed, 207 insertions(+), 5 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs index 2113f93e99..69462870ff 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -5,6 +5,8 @@ namespace Volo.CmsKit.Admin.Comments { public class CommentGetListInput : PagedAndSortedResultRequestDto { + public string Filter { get; set; } + public string EntityType { get; set; } public string EntityId { get; set; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs index 48fbd2d108..d6903c0cc5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs @@ -1,13 +1,13 @@ using System; -using System.Linq.Dynamic.Core; using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; namespace Volo.CmsKit.Admin.Comments { public interface ICommentAdminAppService : IApplicationService { - Task> GetListAsync(CommentGetListInput input); + Task> GetListAsync(CommentGetListInput input); Task GetAsync(Guid id); diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index 44c763cd7c..a8e8faf6a2 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Linq.Dynamic.Core; using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; using Volo.CmsKit.Comments; using Volo.CmsKit.Users; @@ -15,9 +17,33 @@ namespace Volo.CmsKit.Admin.Comments CommentRepository = commentRepository; } - public virtual Task> GetListAsync(CommentGetListInput input) + public virtual async Task> GetListAsync(CommentGetListInput input) { - throw new System.NotImplementedException(); + var totalCount = await CommentRepository.GetCountAsync( + input.Filter, + input.EntityType, + input.EntityId, + input.RepliedCommentId, + input.CreatorId, + input.CreationStartDate, + input.CreationEndDate); + + var comments = await CommentRepository.GetListAsync( + input.Filter, + input.EntityType, + input.EntityId, + input.RepliedCommentId, + input.CreatorId, + input.CreationStartDate, + input.CreationEndDate, + input.Sorting, + input.MaxResultCount, + input.SkipCount + ); + + var dtos = ObjectMapper.Map, List>(comments); + + return new PagedResultDto(totalCount, dtos); } public virtual async Task GetAsync(Guid id) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs index 523b03dd2f..7ea61d47bf 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs @@ -10,6 +10,31 @@ namespace Volo.CmsKit.Comments public interface ICommentRepository : IBasicRepository { Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default); + + Task> GetListAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ); + + Task GetCountAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ); Task> GetListWithAuthorsAsync( [NotNull] string entityType, diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 725aa64e89..95781ae496 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Dynamic.Core; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; @@ -42,6 +43,57 @@ namespace Volo.CmsKit.Comments return commentWithAuthor; } + public async Task> GetListAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ) + { + var query = await GetListQueryAsync( + filter, + entityType, + entityId, + repliedCommentId, + creatorId, + creationStartDate, + creationEndDate); + + return await query.OrderBy(sorting ?? "creationTime desc") + .PageBy(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public async Task GetCountAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ) + { + var query = await GetListQueryAsync( + filter, + entityType, + entityId, + repliedCommentId, + creatorId, + creationStartDate, + creationEndDate); + + return await query.LongCountAsync(GetCancellationToken(cancellationToken)); + } + public async Task> GetListWithAuthorsAsync( string entityType, string entityId, @@ -81,5 +133,25 @@ namespace Volo.CmsKit.Comments await DeleteAsync(comment, cancellationToken: GetCancellationToken(cancellationToken)); } + + protected virtual async Task> GetListQueryAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null + ) + { + return (await GetDbSetAsync()) + .WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) + .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType) + .WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId == entityId) + .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) + .WhereIf(creatorId.HasValue, c => c.CreatorId == creatorId) + .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) + .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); + } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 7e6a434c3f..78d727b57c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -1,10 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Dynamic.Core; using System.Threading; using System.Threading.Tasks; -using MongoDB.Driver.Linq; using MongoDB.Driver; +using MongoDB.Driver.Linq; using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.MongoDB; @@ -40,6 +41,61 @@ namespace Volo.CmsKit.MongoDB.Comments return commentWithAuthor; } + public async Task> GetListAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + string sorting = null, + int maxResultCount = int.MaxValue, + int skipCount = 0, + CancellationToken cancellationToken = default + ) + { + var query = await GetListQueryAsync( + filter, + entityType, + entityId, + repliedCommentId, + creatorId, + creationStartDate, + creationEndDate, + cancellationToken); + + return await query.OrderBy(sorting ?? "creationTime desc") + .As>() + .PageBy>(skipCount, maxResultCount) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public async Task GetCountAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ) + { + var query = await GetListQueryAsync( + filter, + entityType, + entityId, + repliedCommentId, + creatorId, + creationStartDate, + creationEndDate, + cancellationToken); + + return await query.As>() + .LongCountAsync(GetCancellationToken(cancellationToken)); + } + public async Task> GetListWithAuthorsAsync( string entityType, string entityId, @@ -92,5 +148,26 @@ namespace Volo.CmsKit.MongoDB.Comments cancellationToken: GetCancellationToken(cancellationToken) ); } + + protected virtual async Task> GetListQueryAsync( + string filter = null, + string entityType = null, + string entityId = null, + Guid? repliedCommentId = null, + Guid? creatorId = null, + DateTime? creationStartDate = null, + DateTime? creationEndDate = null, + CancellationToken cancellationToken = default + ) + { + return (await GetMongoQueryableAsync(cancellationToken)) + .WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) + .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType) + .WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId == entityId) + .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) + .WhereIf(creatorId.HasValue, c => c.CreatorId == creatorId) + .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) + .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); + } } } From e109fd926068c86f4703ba75998cfd496dce5c07 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Wed, 17 Feb 2021 12:20:31 +0300 Subject: [PATCH 04/25] Added comment admin app service test --- .../Admin/Comments/CommentGetListInput.cs | 6 +-- .../Comments/CommentAdminAppService_Tests.cs | 49 +++++++++++++++++++ .../Comments/CommentRepository_Tests.cs | 25 ++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs index 69462870ff..88e8d459b1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -15,10 +15,10 @@ namespace Volo.CmsKit.Admin.Comments public Guid? RepliedCommentId { get; set; } - public Guid CreatorId { get; set; } + public Guid? CreatorId { get; set; } - public DateTime CreationStartDate { get; set; } + public DateTime? CreationStartDate { get; set; } - public DateTime CreationEndDate { get; set; } + public DateTime? CreationEndDate { get; set; } } } \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs new file mode 100644 index 0000000000..e42312a97b --- /dev/null +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs @@ -0,0 +1,49 @@ +using System.Threading.Tasks; +using Shouldly; +using Volo.Abp.Domain.Entities; +using Volo.CmsKit.Admin.Comments; +using Xunit; + +namespace Volo.CmsKit.Comments +{ + public class CommentAdminAppService_Tests : CmsKitApplicationTestBase + { + private readonly ICommentAdminAppService _commentAdminAppService; + private readonly CmsKitTestData _cmsKitTestData; + + public CommentAdminAppService_Tests() + { + _commentAdminAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } + + [Fact] + public async Task ShouldGet_PagedListAsync() + { + var comments = await _commentAdminAppService.GetListAsync(new CommentGetListInput + { + MaxResultCount = 3 + }); + + comments.TotalCount.ShouldBe(6); + comments.Items.Count.ShouldBe(3); + } + + [Fact] + public async Task ShouldGet_CommentWithAuthorAsync() + { + var comment = await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId); + + comment.ShouldNotBeNull(); + comment.Author.ShouldNotBeNull(); + } + + [Fact] + public async Task ShouldDelete_WithRepliesAsync() + { + await _commentAdminAppService.DeleteAsync(_cmsKitTestData.CommentWithChildId); + + await Should.ThrowAsync(async () => await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId)); + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs index 80b3052798..e7b36a242a 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs @@ -18,6 +18,31 @@ namespace Volo.CmsKit.Comments _commentRepository = GetRequiredService(); } + [Fact] + public async Task GetList_ShouldWork() + { + var comments = await _commentRepository.GetListAsync(); + + comments.ShouldNotBeNull(); + comments.Count.ShouldBe(6); + + var headCommentId = comments.First(x => x.RepliedCommentId != null).RepliedCommentId; + + var replies = await _commentRepository.GetListAsync(repliedCommentId: headCommentId); + + replies.ShouldNotBeNull(); + replies.Count.ShouldBeLessThan(6); + replies.Count.ShouldBeGreaterThanOrEqualTo(1); + } + + [Fact] + public async Task GetCount_ShouldWork() + { + var commentsCount = await _commentRepository.GetCountAsync(); + + commentsCount.ShouldBe(6); + } + [Fact] public async Task GetListWithAuthorsAsync() { From cc69bba8a0a8fde8f41ea96a435c6929d747cdd1 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Wed, 17 Feb 2021 12:24:42 +0300 Subject: [PATCH 05/25] Added comment admin permissions --- .../Permissions/CmsKitAdminPermissionDefinitionProvider.cs | 7 +++++++ .../Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs | 6 ++++++ .../Volo/CmsKit/Localization/Resources/en.json | 2 ++ 3 files changed, 15 insertions(+) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs index a5a30a60ef..4b6b0b38de 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissionDefinitionProvider.cs @@ -13,6 +13,12 @@ namespace Volo.CmsKit.Permissions { var cmsGroup = context.GetGroupOrNull(CmsKitAdminPermissions.GroupName) ?? context.AddGroup(CmsKitAdminPermissions.GroupName, L("Permission:CmsKit")); + if (GlobalFeatureManager.Instance.IsEnabled()) + { + var contentGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Comments.Default, L("Permission:Comments")); + contentGroup.AddChild(CmsKitAdminPermissions.Comments.Delete, L("Permission:Comments.Delete")); + } + if (GlobalFeatureManager.Instance.IsEnabled()) { var contentGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Contents.Default, L("Permission:Contents")); @@ -20,6 +26,7 @@ namespace Volo.CmsKit.Permissions contentGroup.AddChild(CmsKitAdminPermissions.Contents.Update, L("Permission:Contents.Update")); contentGroup.AddChild(CmsKitAdminPermissions.Contents.Delete, L("Permission:Contents.Delete")); } + if (GlobalFeatureManager.Instance.IsEnabled()) { var tagGroup = cmsGroup.AddPermission(CmsKitAdminPermissions.Tags.Default, L("Permission:TagManagement")); diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs index 4c106d4d3c..4efa6c059c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Permissions/CmsKitAdminPermissions.cs @@ -6,6 +6,12 @@ namespace Volo.CmsKit.Permissions { public const string GroupName = "CmsKit"; + public static class Comments + { + public const string Default = GroupName + ".Comments"; + public const string Delete = Default + ".Delete"; + } + public static class Tags { public const string Default = GroupName + ".Tags"; diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json index 7b7dd69308..9f481f94b0 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Localization/Resources/en.json @@ -17,6 +17,8 @@ "Menu:CMS": "CMS", "MessageDeletionConfirmationMessage": "This comment will be deleted completely.", "Permission:CmsKit": "CmsKit", + "Permission:Comments": "Comment Management", + "Permission:Comments.Delete": "Delete", "Permission:Contents": "Content Management", "Permission:Contents.Create": "Create Content", "Permission:Contents.Delete": "Delete Content", From 90601d74e678bb92a1355c45bb6ccb05542c9c12 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Wed, 17 Feb 2021 12:30:21 +0300 Subject: [PATCH 06/25] Added comment admin controller --- .../Admin/Comments/CommentAdminAppService.cs | 8 +++- .../Admin/Comments/CommentAdminController.cs | 48 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index a8e8faf6a2..12ac3b247e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -1,13 +1,18 @@ using System; using System.Collections.Generic; -using System.Linq.Dynamic.Core; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; +using Volo.Abp.GlobalFeatures; using Volo.CmsKit.Comments; +using Volo.CmsKit.GlobalFeatures; +using Volo.CmsKit.Permissions; using Volo.CmsKit.Users; namespace Volo.CmsKit.Admin.Comments { + [RequiresGlobalFeature(typeof(CommentsFeature))] + [Authorize(CmsKitAdminPermissions.Comments.Default)] public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAppService { protected readonly ICommentRepository CommentRepository; @@ -56,6 +61,7 @@ namespace Volo.CmsKit.Admin.Comments return dto; } + [Authorize(CmsKitAdminPermissions.Comments.Delete)] public virtual async Task DeleteAsync(Guid id) { var comment = await CommentRepository.GetAsync(id); diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs new file mode 100644 index 0000000000..8d25f93b32 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs @@ -0,0 +1,48 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.GlobalFeatures; +using Volo.CmsKit.GlobalFeatures; +using Volo.CmsKit.Permissions; + +namespace Volo.CmsKit.Admin.Comments +{ + [Authorize(CmsKitAdminPermissions.Comments.Default)] + [RequiresGlobalFeature(typeof(CommentsFeature))] + [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] + [Area("cms-kit")] + [Route("api/cms-kit-admin/comments")] + public class CommentAdminController : CmsKitAdminController, ICommentAdminAppService + { + protected readonly ICommentAdminAppService CommentAdminAppService; + + public CommentAdminController(ICommentAdminAppService commentAdminAppService) + { + CommentAdminAppService = commentAdminAppService; + } + + [HttpGet] + public virtual Task> GetListAsync(CommentGetListInput input) + { + return CommentAdminAppService.GetListAsync(input); + } + + [HttpGet] + [Route("{id}")] + public virtual Task GetAsync(Guid id) + { + return CommentAdminAppService.GetAsync(id); + } + + [HttpDelete] + [Route("{id}")] + [Authorize(CmsKitAdminPermissions.Comments.Delete)] + public virtual Task DeleteAsync(Guid id) + { + return CommentAdminAppService.DeleteAsync(id); + } + } +} \ No newline at end of file From edae47d9e060460bbdc07ec0560f6a0a166e4332 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 17 Feb 2021 15:10:10 +0300 Subject: [PATCH 07/25] CmsKit - Refactoring for blogs domain --- .../Volo/CmsKit/Blogs/Blog.cs | 12 ++++---- .../Volo/CmsKit/Blogs/BlogPost.cs | 17 ++++++----- .../Volo/CmsKit/Blogs/BlogPostManager.cs | 29 +++++++++++-------- .../BlogPostSlugAlreadyExistException.cs | 7 +++-- .../Volo/CmsKit/Blogs/IBlogPostManager.cs | 5 ++-- .../Volo/CmsKit/Blogs/IBlogRepository.cs | 5 ++-- .../Volo/CmsKit/Blogs/EfCoreBlogRepository.cs | 9 +++--- .../MongoDB/Blogs/MongoBlogRepository.cs | 5 ++-- 8 files changed, 52 insertions(+), 37 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs index 79c496970c..832ed4385e 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/Blog.cs +++ b/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); diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs index 7a52fe0d9f..bd7cf61516 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs @@ -12,15 +12,18 @@ namespace Volo.CmsKit.Blogs { public class BlogPost : FullAuditedAggregateRootWithUser, 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 +42,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 +54,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); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs index aed2b9fffd..2754794b26 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs @@ -1,44 +1,49 @@ -using System; +using JetBrains.Annotations; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Services; +using Volo.Abp.VirtualFileSystem; 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; + this.BlogPostRepository = blogPostRepository; + this.BlogRepository = blogRepository; } - public async Task CreateAsync(BlogPost blogPost) + public virtual async Task 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 +51,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 +59,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); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs index 8e59249299..034cb8e60d 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostSlugAlreadyExistException.cs +++ b/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; } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs index 5027fa8e38..334b4912ef 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs @@ -1,4 +1,5 @@ -using System; +using JetBrains.Annotations; +using System; using System.Threading.Tasks; namespace Volo.CmsKit.Blogs @@ -9,6 +10,6 @@ namespace Volo.CmsKit.Blogs Task UpdateAsync(BlogPost blogPost); - Task SetSlugUrlAsync(BlogPost blogPost, string newSlug); + Task SetSlugUrlAsync(BlogPost blogPost, [NotNull] string newSlug); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs index 4213884057..2feb057111 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogRepository.cs +++ b/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 { - public Task GetBySlugAsync(string slug); - Task ExistsAsync(Guid blogId); + public Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default); + Task ExistsAsync(Guid blogId, CancellationToken cancellationToken = default); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs index d2ddbf35aa..f04889299c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogRepository.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using System; using System.Security.Cryptography.X509Certificates; +using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; @@ -14,14 +15,14 @@ namespace Volo.CmsKit.Blogs { } - public async Task ExistsAsync(Guid blogId) + public virtual async Task ExistsAsync(Guid blogId, CancellationToken cancellationToken = default) { - return await (await GetQueryableAsync()).AnyAsync(x => x.Id == blogId); + return await (await GetQueryableAsync()).AnyAsync(x => x.Id == blogId, cancellationToken); } - public Task GetBySlugAsync(string slug) + public virtual Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default) { - return GetAsync(x => x.Slug == slug); + return GetAsync(x => x.Slug == slug, cancellationToken: cancellationToken); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs index d733f82bf6..d917842c59 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs @@ -1,5 +1,6 @@ using MongoDB.Driver.Core.Operations; using System; +using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; @@ -13,14 +14,14 @@ namespace Volo.CmsKit.MongoDB.Blogs { } - public async Task ExistsAsync(Guid blogId) + public virtual async Task ExistsAsync(Guid blogId, CancellationToken cancellationToken = default) { return await AsyncExecuter.AnyAsync( await GetQueryableAsync(), x => x.Id == blogId); } - public Task GetBySlugAsync(string slug) + public virtual Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default) { return GetAsync(x => x.Slug == slug); } From a90343b674a4fbae31fb0c3f41cf246324bc3598 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 17 Feb 2021 15:22:30 +0300 Subject: [PATCH 08/25] CmsKit - Blogs Application Refactoring --- .../Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs | 1 + .../CmsKit/Public/Blogs/IBlogPostPublicAppService.cs | 7 ++++--- .../Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs index d2c1114dfb..ee5ed3e126 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Authorization; using System; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs index 0c9079ee7e..04234b4f06 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs +++ b/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> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input); + Task> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input); - Task GetAsync(string blogSlug, string blogPostSlug); + Task GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug); Task GetCoverImageAsync(Guid id); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs index 3994720d73..644b4e4cc3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs +++ b/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 GetAsync(string blogSlug, string blogPostSlug) + public virtual async Task 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); } - public async Task> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input) + public virtual async Task> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input) { var blog = await BlogRepository.GetBySlugAsync(blogSlug); @@ -46,7 +47,7 @@ namespace Volo.CmsKit.Public.Blogs ObjectMapper.Map, List>(blogPosts)); } - public async Task GetCoverImageAsync(Guid id) + public virtual async Task GetCoverImageAsync(Guid id) { var stream = await BlobContainer.GetAsync(id.ToString()); From 899ab7aa76cd335f33e468a48d8429cb6d19f31f Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 17 Feb 2021 15:22:49 +0300 Subject: [PATCH 09/25] CmsKit - Blogs HttpApi refactoring --- .../Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs index 7f3545ad9c..ff95e71e45 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs @@ -28,14 +28,14 @@ namespace Volo.CmsKit.Public.Blogs [HttpGet] [Route("{blogSlug}/{blogPostSlug}")] - public Task GetAsync(string blogSlug, string blogPostSlug) + public virtual Task GetAsync(string blogSlug, string blogPostSlug) { return BlogPostPublicAppService.GetAsync(blogSlug, blogPostSlug); } [HttpGet] [Route("{id}/cover-image")] - public Task GetCoverImageAsync(Guid id) + public virtual Task GetCoverImageAsync(Guid id) { Response.Headers.Add("Content-Disposition", $"inline;filename=\"{id}\""); Response.Headers.Add("Accept-Ranges", "bytes"); @@ -47,7 +47,7 @@ namespace Volo.CmsKit.Public.Blogs [HttpGet] [Route("{blogSlug}")] - public Task> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input) + public virtual Task> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input) { return BlogPostPublicAppService.GetListAsync(blogSlug, input); } From ea2227fbb1fd6c241b868f74edd7c98b4674fc8c Mon Sep 17 00:00:00 2001 From: Ahmet Date: Wed, 17 Feb 2021 17:45:57 +0300 Subject: [PATCH 10/25] refactoring --- .../Volo/CmsKit/Admin/Comments/CommentGetListInput.cs | 2 -- .../Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs | 4 ++-- .../Volo/CmsKit/Comments/ICommentRepository.cs | 2 +- .../Volo/CmsKit/Comments/EfCoreCommentRepository.cs | 8 ++++---- .../CmsKit/MongoDB/Comments/MongoCommentRepository.cs | 4 ++-- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs index 88e8d459b1..beaf997947 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -5,8 +5,6 @@ namespace Volo.CmsKit.Admin.Comments { public class CommentGetListInput : PagedAndSortedResultRequestDto { - public string Filter { get; set; } - public string EntityType { get; set; } public string EntityId { get; set; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index 12ac3b247e..60c83a2551 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -25,7 +25,7 @@ namespace Volo.CmsKit.Admin.Comments public virtual async Task> GetListAsync(CommentGetListInput input) { var totalCount = await CommentRepository.GetCountAsync( - input.Filter, + input.Text, input.EntityType, input.EntityId, input.RepliedCommentId, @@ -34,7 +34,7 @@ namespace Volo.CmsKit.Admin.Comments input.CreationEndDate); var comments = await CommentRepository.GetListAsync( - input.Filter, + input.Text, input.EntityType, input.EntityId, input.RepliedCommentId, diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs index 7ea61d47bf..6293e125b6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs @@ -26,7 +26,7 @@ namespace Volo.CmsKit.Comments ); Task GetCountAsync( - string filter = null, + string text = null, string entityType = null, string entityId = null, Guid? repliedCommentId = null, diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 95781ae496..1e939e7740 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -72,7 +72,7 @@ namespace Volo.CmsKit.Comments } public async Task GetCountAsync( - string filter = null, + string text = null, string entityType = null, string entityId = null, Guid? repliedCommentId = null, @@ -83,7 +83,7 @@ namespace Volo.CmsKit.Comments ) { var query = await GetListQueryAsync( - filter, + text, entityType, entityId, repliedCommentId, @@ -146,8 +146,8 @@ namespace Volo.CmsKit.Comments { return (await GetDbSetAsync()) .WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) - .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType) - .WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId == entityId) + .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType.Contains(entityType)) + .WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId.Contains(entityId)) .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) .WhereIf(creatorId.HasValue, c => c.CreatorId == creatorId) .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 78d727b57c..39eb8cb223 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -72,7 +72,7 @@ namespace Volo.CmsKit.MongoDB.Comments } public async Task GetCountAsync( - string filter = null, + string text = null, string entityType = null, string entityId = null, Guid? repliedCommentId = null, @@ -83,7 +83,7 @@ namespace Volo.CmsKit.MongoDB.Comments ) { var query = await GetListQueryAsync( - filter, + text, entityType, entityId, repliedCommentId, From f3195ecd1eca8a2a9242b447626bf4b52dd043e4 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 17 Feb 2021 17:49:36 +0300 Subject: [PATCH 11/25] CmsKit - Blogs Refactor namespaces --- .../Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs | 2 -- .../Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs | 1 - .../src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs | 2 -- .../Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs | 4 ---- .../Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs | 1 - .../Volo/CmsKit/Blogs/IBlogPostRepository.cs | 2 -- .../Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs | 4 ---- 7 files changed, 16 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs index f0485cc344..3544b3d7af 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/IBlogAdminAppService.cs +++ b/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 diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs index ee5ed3e126..d2c1114dfb 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Authorization; using System; -using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs index bd7cf61516..2e4949cd84 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPost.cs +++ b/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; diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs index 2754794b26..dd920b637f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs @@ -1,13 +1,9 @@ using JetBrains.Annotations; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Services; -using Volo.Abp.VirtualFileSystem; namespace Volo.CmsKit.Blogs { diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs index 334b4912ef..9a3afebf71 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostManager.cs @@ -1,5 +1,4 @@ using JetBrains.Annotations; -using System; using System.Threading.Tasks; namespace Volo.CmsKit.Blogs diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs index 198cfca104..943ea381f3 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs +++ b/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; diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs index ff95e71e45..e22ef54545 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs +++ b/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 { From 2b5ad0ac42cb182aedfd3a8a96fbcfdb912486f3 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 17 Feb 2021 17:53:51 +0300 Subject: [PATCH 12/25] CmsKit - Remove this keyword from BlogPostManager --- .../Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs index dd920b637f..7ba85f8ce6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/BlogPostManager.cs @@ -16,8 +16,8 @@ namespace Volo.CmsKit.Blogs IBlogPostRepository blogPostRepository, IBlogRepository blogRepository) { - this.BlogPostRepository = blogPostRepository; - this.BlogRepository = blogRepository; + BlogPostRepository = blogPostRepository; + BlogRepository = blogRepository; } public virtual async Task CreateAsync(BlogPost blogPost) From 950552575564f833b0a44191f2ce993715ae511d Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 17 Feb 2021 17:55:13 +0300 Subject: [PATCH 13/25] CmsKit - CancellationToken usage at MongoBlogRepository --- .../Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs index d917842c59..e6b5f01e7f 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs @@ -18,12 +18,13 @@ namespace Volo.CmsKit.MongoDB.Blogs { return await AsyncExecuter.AnyAsync( await GetQueryableAsync(), - x => x.Id == blogId); + x => x.Id == blogId, + cancellationToken); } public virtual Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default) { - return GetAsync(x => x.Slug == slug); + return GetAsync(x => x.Slug == slug, cancellationToken); } } } From c3579202056b0796bf35e4124498a716cf4810a9 Mon Sep 17 00:00:00 2001 From: enisn Date: Wed, 17 Feb 2021 17:56:47 +0300 Subject: [PATCH 14/25] CmsKit - Fix of CancellationToken usage at MongoBlogRepository --- .../Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs index e6b5f01e7f..2b215d55c6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogRepository.cs @@ -24,7 +24,7 @@ namespace Volo.CmsKit.MongoDB.Blogs public virtual Task GetBySlugAsync(string slug, CancellationToken cancellationToken = default) { - return GetAsync(x => x.Slug == slug, cancellationToken); + return GetAsync(x => x.Slug == slug, cancellationToken: cancellationToken); } } } From f9285cb649ccbb463592e50ef3d4ca80d1106009 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Thu, 18 Feb 2021 12:01:03 +0300 Subject: [PATCH 15/25] Use getter only properties instead of variables for injected services --- .../Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs | 3 +-- .../Volo/CmsKit/Admin/Comments/CommentAdminController.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index 60c83a2551..e045f1137a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -15,7 +15,7 @@ namespace Volo.CmsKit.Admin.Comments [Authorize(CmsKitAdminPermissions.Comments.Default)] public class CommentAdminAppService : CmsKitAdminAppServiceBase, ICommentAdminAppService { - protected readonly ICommentRepository CommentRepository; + protected ICommentRepository CommentRepository { get; } public CommentAdminAppService(ICommentRepository commentRepository) { @@ -65,7 +65,6 @@ namespace Volo.CmsKit.Admin.Comments public virtual async Task DeleteAsync(Guid id) { var comment = await CommentRepository.GetAsync(id); - await CommentRepository.DeleteWithRepliesAsync(comment); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs index 8d25f93b32..9f71761235 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs @@ -17,7 +17,7 @@ namespace Volo.CmsKit.Admin.Comments [Route("api/cms-kit-admin/comments")] public class CommentAdminController : CmsKitAdminController, ICommentAdminAppService { - protected readonly ICommentAdminAppService CommentAdminAppService; + protected ICommentAdminAppService CommentAdminAppService { get; } public CommentAdminController(ICommentAdminAppService commentAdminAppService) { From f565994fc7e2d6113a3fa6f289e0a09f7d93b0f8 Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 18 Feb 2021 14:51:16 +0300 Subject: [PATCH 16/25] CmsKit - Remove duplicated 'Blogs' from route --- .../Volo/CmsKit/Admin/Blogs/BlogAdminController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs index d63a3317ce..da565413b1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Blogs/BlogAdminController.cs +++ b/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; } From e586f8fb85cf070295b86873ae5145ef71a5c715 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Fri, 19 Feb 2021 14:59:23 +0300 Subject: [PATCH 17/25] content app service renaming. --- .../{IContentAppService.cs => IContentPublicAppService.cs} | 4 ++-- .../Volo/CmsKit/Public/Contents/ContentPublicAppService.cs | 2 +- .../Volo/CmsKit/Public/Contents/ContentController.cs | 6 +++--- .../Shared/Components/Contents/ContentViewComponent.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) rename modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/{IContentAppService.cs => IContentPublicAppService.cs} (78%) diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentPublicAppService.cs similarity index 78% rename from modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentAppService.cs rename to modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentPublicAppService.cs index 6f691ceca1..df8b07cfce 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Contents/IContentPublicAppService.cs @@ -3,8 +3,8 @@ using Volo.CmsKit.Contents; namespace Volo.CmsKit.Public.Contents { - public interface IContentAppService + public interface IContentPublicAppService { Task GetAsync(GetContentInput input); } -} +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs index 0fc31e1b4b..995c99c2ed 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Contents/ContentPublicAppService.cs @@ -3,7 +3,7 @@ using Volo.CmsKit.Contents; namespace Volo.CmsKit.Public.Contents { - public class ContentPublicAppService : CmsKitAppServiceBase, IContentAppService + public class ContentPublicAppService : CmsKitPublicAppServiceBase, IContentPublicAppService { protected IContentRepository ContentRepository { get; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs index 4a348fc7bf..ab8270a2a1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Contents/ContentController.cs @@ -9,11 +9,11 @@ namespace Volo.CmsKit.Public.Contents [RemoteService(Name = CmsKitCommonRemoteServiceConsts.RemoteServiceName)] [Area("cms-kit")] [Route("api/cms-kit-public/contents")] - public class ContentController : CmsKitControllerBase, IContentAppService + public class ContentController : CmsKitControllerBase, IContentPublicAppService { - protected readonly IContentAppService _contentAppService; + protected readonly IContentPublicAppService _contentAppService; - public ContentController(IContentAppService contentAppService) + public ContentController(IContentPublicAppService contentAppService) { _contentAppService = contentAppService; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs index 6a2a4e5a13..70baaf4436 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/CmsKit/Shared/Components/Contents/ContentViewComponent.cs @@ -12,11 +12,11 @@ namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents public class ContentViewComponent : AbpViewComponent { private readonly IContentRenderer contentRenderer; - private readonly IContentAppService contentAppService; + private readonly IContentPublicAppService contentAppService; public ContentViewComponent( IContentRenderer contentRenderer, - IContentAppService contentAppService) + IContentPublicAppService contentAppService) { this.contentRenderer = contentRenderer; this.contentAppService = contentAppService; From 7fcb5121aeda73c72fc78cceb5f012f73bfbcc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 19 Feb 2021 18:15:10 +0300 Subject: [PATCH 18/25] Should check the result of QueueBindCommands.TryPeek. --- .../Abp/RabbitMQ/RabbitMqMessageConsumer.cs | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs index f757efab64..894f68d097 100644 --- a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs +++ b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs @@ -90,29 +90,30 @@ namespace Volo.Abp.RabbitMQ lock (ChannelSendSyncLock) { - QueueBindCommands.TryPeek(out var command); - - switch (command.Type) + if (QueueBindCommands.TryPeek(out var command)) { - case QueueBindType.Bind: - Channel.QueueBind( - queue: Queue.QueueName, - exchange: Exchange.ExchangeName, - routingKey: command.RoutingKey - ); - break; - case QueueBindType.Unbind: - Channel.QueueUnbind( - queue: Queue.QueueName, - exchange: Exchange.ExchangeName, - routingKey: command.RoutingKey - ); - break; - default: - throw new AbpException($"Unknown {nameof(QueueBindType)}: {command.Type}"); + switch (command.Type) + { + case QueueBindType.Bind: + Channel.QueueBind( + queue: Queue.QueueName, + exchange: Exchange.ExchangeName, + routingKey: command.RoutingKey + ); + break; + case QueueBindType.Unbind: + Channel.QueueUnbind( + queue: Queue.QueueName, + exchange: Exchange.ExchangeName, + routingKey: command.RoutingKey + ); + break; + default: + throw new AbpException($"Unknown {nameof(QueueBindType)}: {command.Type}"); + } + + QueueBindCommands.TryDequeue(out command); } - - QueueBindCommands.TryDequeue(out command); } } } From 909e5c0db815bb485a08d628f992bbb6bc309279 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 22 Feb 2021 11:14:53 +0800 Subject: [PATCH 19/25] Localize login&logout text --- .../Themes/Basic/LoginDisplay.razor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor index 18ebfbd4ba..312c741032 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor @@ -1,11 +1,16 @@ @using Microsoft.AspNetCore.Components.WebAssembly.Authentication +@using Microsoft.Extensions.Localization +@using Volo.Abp.Localization @using Volo.Abp.Users @using Volo.Abp.MultiTenancy +@using Volo.Abp.Validation.Localization +@using global::Localization.Resources.AbpUi @inject ICurrentUser CurrentUser @inject ICurrentTenant CurrentTenant @inject IJSRuntime JsRuntime @inject NavigationManager Navigation @inject SignOutSessionStateManager SignOutManager +@inject IStringLocalizer UiLocalizer @@ -28,12 +33,12 @@ } } - Logout + @UiLocalizer["Logout"] - Log in + @UiLocalizer["Login"] @code{ From 8a3c70d13a9d339bce3e8e750de63afb96d2654e Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 22 Feb 2021 11:17:19 +0800 Subject: [PATCH 20/25] Remove unnecessary using --- .../Themes/Basic/LoginDisplay.razor | 2 -- 1 file changed, 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor index 312c741032..eebfb501a5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LoginDisplay.razor @@ -1,9 +1,7 @@ @using Microsoft.AspNetCore.Components.WebAssembly.Authentication @using Microsoft.Extensions.Localization -@using Volo.Abp.Localization @using Volo.Abp.Users @using Volo.Abp.MultiTenancy -@using Volo.Abp.Validation.Localization @using global::Localization.Resources.AbpUi @inject ICurrentUser CurrentUser @inject ICurrentTenant CurrentTenant From da78623e83fa3fb9c29df15b58cfeaf99f4cbdd4 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Mon, 22 Feb 2021 14:06:58 +0300 Subject: [PATCH 21/25] added author information to comment return list --- .../Admin/Comments/ICommentAdminAppService.cs | 2 +- .../Admin/Comments/CommentAdminAppService.cs | 13 +++++++--- .../Admin/Comments/CommentAdminController.cs | 2 +- .../CmsKit/Comments/ICommentRepository.cs | 2 +- .../Comments/EfCoreCommentRepository.cs | 18 ++++++++++---- .../Comments/MongoCommentRepository.cs | 24 +++++++++++++++++-- .../Comments/CommentAdminAppService_Tests.cs | 4 +++- .../Comments/CommentRepository_Tests.cs | 4 ++-- 8 files changed, 54 insertions(+), 15 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs index d6903c0cc5..2bddc35a25 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/ICommentAdminAppService.cs @@ -7,7 +7,7 @@ namespace Volo.CmsKit.Admin.Comments { public interface ICommentAdminAppService : IApplicationService { - Task> GetListAsync(CommentGetListInput input); + Task> GetListAsync(CommentGetListInput input); Task GetAsync(Guid id); diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index e045f1137a..238e475f15 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; @@ -22,7 +23,7 @@ namespace Volo.CmsKit.Admin.Comments CommentRepository = commentRepository; } - public virtual async Task> GetListAsync(CommentGetListInput input) + public virtual async Task> GetListAsync(CommentGetListInput input) { var totalCount = await CommentRepository.GetCountAsync( input.Text, @@ -46,9 +47,15 @@ namespace Volo.CmsKit.Admin.Comments input.SkipCount ); - var dtos = ObjectMapper.Map, List>(comments); + var dtos = comments.Select(queryResultItem => + { + var dto = ObjectMapper.Map(queryResultItem.Comment); + dto.Author = ObjectMapper.Map(queryResultItem.Author); - return new PagedResultDto(totalCount, dtos); + return dto; + }).ToList(); + + return new PagedResultDto(totalCount, dtos); } public virtual async Task GetAsync(Guid id) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs index 9f71761235..91482d137a 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.HttpApi/Volo/CmsKit/Admin/Comments/CommentAdminController.cs @@ -25,7 +25,7 @@ namespace Volo.CmsKit.Admin.Comments } [HttpGet] - public virtual Task> GetListAsync(CommentGetListInput input) + public virtual Task> GetListAsync(CommentGetListInput input) { return CommentAdminAppService.GetListAsync(input); } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs index 6293e125b6..f6c4cfb25c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs @@ -11,7 +11,7 @@ namespace Volo.CmsKit.Comments { Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default); - Task> GetListAsync( + Task> GetListAsync( string filter = null, string entityType = null, string entityId = null, diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 1e939e7740..9be480ce11 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -43,7 +43,7 @@ namespace Volo.CmsKit.Comments return commentWithAuthor; } - public async Task> GetListAsync( + public async Task> GetListAsync( string filter = null, string entityType = null, string entityId = null, @@ -66,9 +66,19 @@ namespace Volo.CmsKit.Comments creationStartDate, creationEndDate); - return await query.OrderBy(sorting ?? "creationTime desc") - .PageBy(skipCount, maxResultCount) - .ToListAsync(GetCancellationToken(cancellationToken)); + query = query.OrderBy(sorting ?? "creationTime desc") + .PageBy(skipCount, maxResultCount); + + var query2 = from comment in query + join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id + orderby comment.CreationTime + select new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = user + }; + + return await query2.ToListAsync(GetCancellationToken(cancellationToken)); } public async Task GetCountAsync( diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 39eb8cb223..351a78333b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -11,6 +11,7 @@ using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Comments; +using Volo.CmsKit.Users; namespace Volo.CmsKit.MongoDB.Comments { @@ -41,7 +42,7 @@ namespace Volo.CmsKit.MongoDB.Comments return commentWithAuthor; } - public async Task> GetListAsync( + public async Task> GetListAsync( string filter = null, string entityType = null, string entityId = null, @@ -65,10 +66,29 @@ namespace Volo.CmsKit.MongoDB.Comments creationEndDate, cancellationToken); - return await query.OrderBy(sorting ?? "creationTime desc") + var comments = await query.OrderBy(sorting ?? "creationTime desc") .As>() .PageBy>(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); + + 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 + where commentIds.Contains(comment.Id) + orderby comment.CreationTime + select user; + + var authors = await authorsQuery.ToListAsync(cancellationToken); + + return comments + .Select( + comment => + new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = authors.FirstOrDefault(a => a.Id == comment.CreatorId) + }).ToList(); } public async Task GetCountAsync( diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs index e42312a97b..7c62889201 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Linq; +using System.Threading.Tasks; using Shouldly; using Volo.Abp.Domain.Entities; using Volo.CmsKit.Admin.Comments; @@ -27,6 +28,7 @@ namespace Volo.CmsKit.Comments comments.TotalCount.ShouldBe(6); comments.Items.Count.ShouldBe(3); + comments.Items.Any(x => x.Author != null).ShouldBeTrue(); } [Fact] diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs index e7b36a242a..3b166834a0 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs @@ -26,7 +26,7 @@ namespace Volo.CmsKit.Comments comments.ShouldNotBeNull(); comments.Count.ShouldBe(6); - var headCommentId = comments.First(x => x.RepliedCommentId != null).RepliedCommentId; + var headCommentId = comments.First(x => x.Comment.RepliedCommentId != null).Comment.RepliedCommentId; var replies = await _commentRepository.GetListAsync(repliedCommentId: headCommentId); @@ -63,7 +63,7 @@ namespace Volo.CmsKit.Comments var list = await _commentRepository.GetListAsync(); list.Any(x=> - x.Id == _cmsKitTestData.CommentWithChildId || x.RepliedCommentId == _cmsKitTestData.CommentWithChildId) + x.Comment.Id == _cmsKitTestData.CommentWithChildId || x.Comment.RepliedCommentId == _cmsKitTestData.CommentWithChildId) .ShouldBeFalse(); } } From 9fea961c52fffdcd638b5eec22041a8a005aef80 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Mon, 22 Feb 2021 14:25:45 +0300 Subject: [PATCH 22/25] added author username filter to commits --- .../Admin/Comments/CommentGetListInput.cs | 2 +- .../Admin/Comments/CommentAdminAppService.cs | 4 +-- .../CmsKit/Comments/ICommentRepository.cs | 4 +-- .../Comments/EfCoreCommentRepository.cs | 27 +++++++++++++------ .../Comments/MongoCommentRepository.cs | 27 +++++++++++++------ 5 files changed, 43 insertions(+), 21 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs index beaf997947..0b0e6ab1c9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -13,7 +13,7 @@ namespace Volo.CmsKit.Admin.Comments public Guid? RepliedCommentId { get; set; } - public Guid? CreatorId { get; set; } + public string AuthorUserName { get; set; } public DateTime? CreationStartDate { get; set; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index 238e475f15..276d58af05 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -30,7 +30,7 @@ namespace Volo.CmsKit.Admin.Comments input.EntityType, input.EntityId, input.RepliedCommentId, - input.CreatorId, + input.AuthorUserName, input.CreationStartDate, input.CreationEndDate); @@ -39,7 +39,7 @@ namespace Volo.CmsKit.Admin.Comments input.EntityType, input.EntityId, input.RepliedCommentId, - input.CreatorId, + input.AuthorUserName, input.CreationStartDate, input.CreationEndDate, input.Sorting, diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs index f6c4cfb25c..234b866183 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Comments/ICommentRepository.cs @@ -16,7 +16,7 @@ namespace Volo.CmsKit.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null, string sorting = null, @@ -30,7 +30,7 @@ namespace Volo.CmsKit.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null, CancellationToken cancellationToken = default diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 9be480ce11..17408a95cd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -48,7 +48,7 @@ namespace Volo.CmsKit.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null, string sorting = null, @@ -61,8 +61,8 @@ namespace Volo.CmsKit.Comments filter, entityType, entityId, - repliedCommentId, - creatorId, + repliedCommentId, + authorUsername, creationStartDate, creationEndDate); @@ -86,7 +86,7 @@ namespace Volo.CmsKit.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null, CancellationToken cancellationToken = default @@ -97,7 +97,7 @@ namespace Volo.CmsKit.Comments entityType, entityId, repliedCommentId, - creatorId, + authorUsername, creationStartDate, creationEndDate); @@ -149,17 +149,28 @@ namespace Volo.CmsKit.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null ) { - return (await GetDbSetAsync()) + var dbSet = await GetDbSetAsync(); + var queryable = dbSet.AsQueryable(); + + if (string.IsNullOrEmpty(authorUsername)) + { + var author = await (await GetDbContextAsync()).User.FirstOrDefaultAsync(x => x.UserName == authorUsername); + + var authorId = author?.Id ?? Guid.Empty; + + queryable.Where(x => x.CreatorId == authorId); + } + + return (dbSet) .WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType.Contains(entityType)) .WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId.Contains(entityId)) .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) - .WhereIf(creatorId.HasValue, c => c.CreatorId == creatorId) .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 351a78333b..741d3b8b83 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -47,7 +47,7 @@ namespace Volo.CmsKit.MongoDB.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null, string sorting = null, @@ -61,7 +61,7 @@ namespace Volo.CmsKit.MongoDB.Comments entityType, entityId, repliedCommentId, - creatorId, + authorUsername, creationStartDate, creationEndDate, cancellationToken); @@ -96,7 +96,7 @@ namespace Volo.CmsKit.MongoDB.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null, CancellationToken cancellationToken = default @@ -107,7 +107,7 @@ namespace Volo.CmsKit.MongoDB.Comments entityType, entityId, repliedCommentId, - creatorId, + authorUsername, creationStartDate, creationEndDate, cancellationToken); @@ -174,18 +174,29 @@ namespace Volo.CmsKit.MongoDB.Comments string entityType = null, string entityId = null, Guid? repliedCommentId = null, - Guid? creatorId = null, + string authorUsername = null, DateTime? creationStartDate = null, DateTime? creationEndDate = null, CancellationToken cancellationToken = default ) { - return (await GetMongoQueryableAsync(cancellationToken)) - .WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) + var queryable = await GetMongoQueryableAsync(cancellationToken); + + if (string.IsNullOrEmpty(authorUsername)) + { + var authorQuerable = (await GetDbContextAsync(cancellationToken)).Collection().AsQueryable(); + + var author = await authorQuerable.FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken); + + var authorId = author?.Id ?? Guid.Empty; + + queryable.Where(x => x.CreatorId == authorId); + } + + return queryable.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType == entityType) .WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId == entityId) .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) - .WhereIf(creatorId.HasValue, c => c.CreatorId == creatorId) .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); } From ddc270e5986b46f67243a91b35a924b2426a4afe Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 22 Feb 2021 16:38:20 +0300 Subject: [PATCH 23/25] remove forwardRef from AbstractNgModelComponent spec --- .../packages/core/src/lib/tests/ng-model.component.spec.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/tests/ng-model.component.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/ng-model.component.spec.ts index c0dc284815..fbb19ac3fc 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/ng-model.component.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/ng-model.component.spec.ts @@ -1,8 +1,8 @@ -import { Component, forwardRef, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'; import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest'; -import { AbstractNgModelComponent } from '../abstracts'; import { timer } from 'rxjs'; +import { AbstractNgModelComponent } from '../abstracts'; @Component({ selector: 'abp-test', @@ -10,8 +10,7 @@ import { timer } from 'rxjs'; providers: [ { provide: NG_VALUE_ACCESSOR, - // tslint:disable-next-line: no-forward-ref - useExisting: forwardRef(() => TestComponent), + useExisting: TestComponent, multi: true, }, ], From afd9cd9d39b8c6366f0e8aa089995e015c0470e4 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Mon, 22 Feb 2021 16:52:35 +0300 Subject: [PATCH 24/25] refactoring --- .../Admin/Comments/CommentGetListInput.cs | 2 +- .../Admin/Comments/CommentAdminAppService.cs | 5 +- .../Comments/EfCoreCommentRepository.cs | 49 ++++++++++--------- .../Comments/MongoCommentRepository.cs | 8 +-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs index 0b0e6ab1c9..f2d14c8153 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -13,7 +13,7 @@ namespace Volo.CmsKit.Admin.Comments public Guid? RepliedCommentId { get; set; } - public string AuthorUserName { get; set; } + public string Author { get; set; } public DateTime? CreationStartDate { get; set; } diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs index 276d58af05..df381fbc2b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Comments/CommentAdminAppService.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; @@ -30,7 +29,7 @@ namespace Volo.CmsKit.Admin.Comments input.EntityType, input.EntityId, input.RepliedCommentId, - input.AuthorUserName, + input.Author, input.CreationStartDate, input.CreationEndDate); @@ -39,7 +38,7 @@ namespace Volo.CmsKit.Admin.Comments input.EntityType, input.EntityId, input.RepliedCommentId, - input.AuthorUserName, + input.Author, input.CreationStartDate, input.CreationEndDate, input.Sorting, diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 17408a95cd..8c8e777185 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -66,19 +66,15 @@ namespace Volo.CmsKit.Comments creationStartDate, creationEndDate); - query = query.OrderBy(sorting ?? "creationTime desc") - .PageBy(skipCount, maxResultCount); + if (sorting != null) + { + sorting = "comment." + sorting; + } - var query2 = from comment in query - join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id - orderby comment.CreationTime - select new CommentWithAuthorQueryResultItem - { - Comment = comment, - Author = user - }; + query = query.OrderBy(sorting ?? "comment.creationTime desc") + .PageBy(skipCount, maxResultCount); - return await query2.ToListAsync(GetCancellationToken(cancellationToken)); + return await query.ToListAsync(GetCancellationToken(cancellationToken)); } public async Task GetCountAsync( @@ -144,7 +140,7 @@ namespace Volo.CmsKit.Comments await DeleteAsync(comment, cancellationToken: GetCancellationToken(cancellationToken)); } - protected virtual async Task> GetListQueryAsync( + protected virtual async Task> GetListQueryAsync( string filter = null, string entityType = null, string entityId = null, @@ -154,25 +150,30 @@ namespace Volo.CmsKit.Comments DateTime? creationEndDate = null ) { - var dbSet = await GetDbSetAsync(); - var queryable = dbSet.AsQueryable(); + var query = from comment in (await GetDbSetAsync()) + join user in (await GetDbContextAsync()).Set() + on comment.CreatorId equals user.Id + select new CommentWithAuthorQueryResultItem + { + Comment = comment, + Author = user + }; - if (string.IsNullOrEmpty(authorUsername)) + if (!string.IsNullOrWhiteSpace(authorUsername)) { - var author = await (await GetDbContextAsync()).User.FirstOrDefaultAsync(x => x.UserName == authorUsername); + var author = await (await GetDbContextAsync()).Set().FirstOrDefaultAsync(x => x.UserName == authorUsername); var authorId = author?.Id ?? Guid.Empty; - queryable.Where(x => x.CreatorId == authorId); + query = query.Where(x => x.Comment.CreatorId == authorId); } - return (dbSet) - .WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) - .WhereIf(!entityType.IsNullOrWhiteSpace(), c => c.EntityType.Contains(entityType)) - .WhereIf(!entityId.IsNullOrWhiteSpace(), c => c.EntityId.Contains(entityId)) - .WhereIf(repliedCommentId.HasValue, c => c.RepliedCommentId == repliedCommentId) - .WhereIf(creationStartDate.HasValue, c => c.CreationTime >= creationStartDate) - .WhereIf(creationEndDate.HasValue, c => c.CreationTime <= creationEndDate); + 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(creationStartDate.HasValue, c => c.Comment.CreationTime >= creationStartDate) + .WhereIf(creationEndDate.HasValue, c => c.Comment.CreationTime <= creationEndDate); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index 741d3b8b83..c58b550305 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs @@ -182,15 +182,15 @@ namespace Volo.CmsKit.MongoDB.Comments { var queryable = await GetMongoQueryableAsync(cancellationToken); - if (string.IsNullOrEmpty(authorUsername)) + if (!string.IsNullOrEmpty(authorUsername)) { - var authorQuerable = (await GetDbContextAsync(cancellationToken)).Collection().AsQueryable(); + var authorQueryable = (await GetDbContextAsync(cancellationToken)).Collection().AsQueryable(); - var author = await authorQuerable.FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken); + var author = await authorQueryable.FirstOrDefaultAsync(x => x.UserName == authorUsername, cancellationToken: cancellationToken); var authorId = author?.Id ?? Guid.Empty; - queryable.Where(x => x.CreatorId == authorId); + queryable = queryable.Where(x => x.CreatorId == authorId); } return queryable.WhereIf(!filter.IsNullOrWhiteSpace(), c => c.Text.Contains(filter)) From c388e491d1e21c8e2ce93b65ac728d50b6c9f4cc Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Mon, 22 Feb 2021 18:22:16 +0300 Subject: [PATCH 25/25] repository refactorings --- .../Comments/EfCoreCommentRepository.cs | 95 ++++++++++--------- .../Comments/MongoCommentRepository.cs | 11 ++- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 8c8e777185..8ca73426be 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -22,7 +22,8 @@ namespace Volo.CmsKit.Comments { } - public async Task GetWithAuthorAsync(Guid id, CancellationToken cancellationToken = default) + public async Task GetWithAuthorAsync(Guid id, + CancellationToken cancellationToken = default) { var query = from comment in (await GetDbSetAsync()) join user in (await GetDbContextAsync()).Set() on comment.CreatorId equals user.Id @@ -44,60 +45,64 @@ namespace Volo.CmsKit.Comments } public async Task> 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 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> GetListWithAuthorsAsync( @@ -141,39 +146,35 @@ namespace Volo.CmsKit.Comments } protected virtual async Task> 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() + var commentDbSet = await GetDbSetAsync(); + var cmsUserSet = (await GetDbContextAsync()).Set(); + + 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().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); } } -} +} \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs index c58b550305..6c3158b0e5 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Comments/MongoCommentRepository.cs +++ b/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>() .PageBy>(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(