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 fed0eed037..16c4f066a3 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 @@ -28,5 +28,14 @@ public interface IBlogPostRepository : IBasicRepository Task GetBySlugAsync(Guid blogId, string slug, CancellationToken cancellationToken = default); - Task> GetAuthorsHasBlogPosts(CancellationToken cancellationToken = default); + Task> GetAuthorsHasBlogPostsAsync( + int skipCount, + int maxResultCount, + string sorting, + string filter, + CancellationToken cancellationToken = default); + + Task GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default); + + Task GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs index cfc39a62c7..b7fce01be6 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs @@ -7,6 +7,7 @@ using System.Linq.Dynamic.Core; using System.Threading; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; @@ -100,9 +101,31 @@ public class EfCoreBlogPostRepository : EfCoreRepository> GetAuthorsHasBlogPosts(CancellationToken cancellationToken = default) + public async Task> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default) { - return await (await GetDbContextAsync()).BlogPosts.Select(x => x.Author).Distinct() + return await (await CreateAuthorsQueryableAsync()) + .Skip(skipCount) + .Take(maxResultCount) + .WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower())) + .OrderBy(sorting.IsNullOrEmpty() ? nameof(CmsUser.UserName) : sorting) .ToListAsync(GetCancellationToken(cancellationToken)); } + + public async Task GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default) + { + return await (await CreateAuthorsQueryableAsync()) + .WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower())) + .CountAsync(GetCancellationToken(cancellationToken)); + } + + public async Task GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default) + { + return await (await CreateAuthorsQueryableAsync()).FirstOrDefaultAsync(x => x.Id == id, GetCancellationToken(cancellationToken)) + ?? throw new EntityNotFoundException(typeof(CmsUser), id); + } + + private async Task> CreateAuthorsQueryableAsync() + { + return (await GetDbContextAsync()).BlogPosts.Select(x => x.Author).Distinct(); + } } diff --git a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs index 1db7fee75e..84570810cd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs @@ -8,6 +8,7 @@ using System.Linq.Dynamic.Core; using System.Threading; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories.MongoDB; using Volo.Abp.MongoDB; using Volo.CmsKit.Blogs; @@ -105,13 +106,37 @@ public class MongoBlogPostRepository : MongoDbRepository x.BlogId == blogId && x.Slug.ToLower() == slug, cancellationToken); } - public async Task> GetAuthorsHasBlogPosts(CancellationToken cancellationToken = default) + public async Task> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default) + { + var queryable = (await CreateAuthorsQueryableAsync()) + .Skip(skipCount) + .Take(maxResultCount) + .OrderBy(sorting.IsNullOrEmpty() ? nameof(CmsUser.UserName) : sorting) + .WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower())); + + return await AsyncExecuter.ToListAsync(queryable, GetCancellationToken(cancellationToken)); + } + + public async Task GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default) + { + return await AsyncExecuter.CountAsync( + (await CreateAuthorsQueryableAsync()) + .WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower()))); + } + + public async Task GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default) + { + return await AsyncExecuter.FirstOrDefaultAsync(await CreateAuthorsQueryableAsync(), x => x.Id == id) + ?? throw new EntityNotFoundException(typeof(CmsUser), id); + } + + private async Task> CreateAuthorsQueryableAsync() { var blogPostQueryable = (await GetQueryableAsync()); var usersQueryable = (await GetDbContextAsync()).Collection().AsQueryable(); - var queryable = blogPostQueryable + return blogPostQueryable .Join( usersQueryable, o => o.AuthorId, @@ -119,7 +144,5 @@ public class MongoBlogPostRepository : MongoDbRepository new { blogPost, user }) .Select(s => s.user) .Distinct(); - - return await AsyncExecuter.ToListAsync(queryable, GetCancellationToken(cancellationToken)); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostFilteredPagedAndSortedResultRequestDto.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostFilteredPagedAndSortedResultRequestDto.cs new file mode 100644 index 0000000000..cb930ea37c --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostFilteredPagedAndSortedResultRequestDto.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Application.Dtos; + +namespace Volo.CmsKit.Public.Blogs; + +public class BlogPostFilteredPagedAndSortedResultRequestDto : PagedAndSortedResultRequestDto +{ + public string Filter { get; set; } +} 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 02b6d2a5f4..42161f884c 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 @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.CmsKit.Users; +using System; namespace Volo.CmsKit.Public.Blogs; @@ -12,6 +13,8 @@ public interface IBlogPostPublicAppService : IApplicationService Task> GetListAsync([NotNull] string blogSlug, BlogPostGetListInput input); Task GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug); - - Task> GetAuthorsHasBlogPostsAsync(); + + Task> GetAuthorsHasBlogPostsAsync(BlogPostFilteredPagedAndSortedResultRequestDto input); + + Task GetAuthorHasBlogPostAsync(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 a9121a5c2b..fc9da1bffb 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 JetBrains.Annotations; +using System; using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; @@ -15,7 +16,6 @@ public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPub protected IBlogRepository BlogRepository { get; } protected IBlogPostRepository BlogPostRepository { get; } - public BlogPostPublicAppService( IBlogRepository blogRepository, @@ -46,9 +46,20 @@ public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPub ObjectMapper.Map, List>(blogPosts)); } - public virtual async Task> GetAuthorsHasBlogPostsAsync() + public virtual async Task> GetAuthorsHasBlogPostsAsync(BlogPostFilteredPagedAndSortedResultRequestDto input) { - var authors = await BlogPostRepository.GetAuthorsHasBlogPosts(); - return ObjectMapper.Map, List>(authors); + var authors = await BlogPostRepository.GetAuthorsHasBlogPostsAsync(input.SkipCount, input.MaxResultCount, input.Sorting, input.Filter); + var authorDtos = ObjectMapper.Map, List>(authors); + + return new PagedResultDto( + await BlogPostRepository.GetAuthorsHasBlogPostsCountAsync(input.Filter), + authorDtos); + } + + public async Task GetAuthorHasBlogPostAsync(Guid id) + { + var author = await BlogPostRepository.GetAuthorHasBlogPostAsync(id); + + return ObjectMapper.Map(author); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.Generated.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.Generated.cs index 9cc926515d..b1bbf6be07 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.Generated.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/BlogPostPublicClientProxy.Generated.cs @@ -1,6 +1,5 @@ // This file is automatically generated by ABP framework to use MVC Controllers from CSharp using System; -using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Http.Client; @@ -25,7 +24,7 @@ public partial class BlogPostPublicClientProxy : ClientProxyBase> GetListAsync(string blogSlug, BlogPostGetListInput input) { return await RequestAsync>(nameof(GetListAsync), new ClientProxyRequestTypeValue @@ -35,8 +34,19 @@ public partial class BlogPostPublicClientProxy : ClientProxyBase> GetAuthorsHasBlogPostsAsync() + public virtual async Task> GetAuthorsHasBlogPostsAsync(BlogPostFilteredPagedAndSortedResultRequestDto input) + { + return await RequestAsync>(nameof(GetAuthorsHasBlogPostsAsync), new ClientProxyRequestTypeValue + { + { typeof(BlogPostFilteredPagedAndSortedResultRequestDto), input } + }); + } + + public virtual async Task GetAuthorHasBlogPostAsync(Guid id) { - return await RequestAsync>(nameof(GetAuthorsHasBlogPostsAsync)); + return await RequestAsync(nameof(GetAuthorHasBlogPostAsync), new ClientProxyRequestTypeValue + { + { typeof(Guid), id } + }); } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/GlobalResourcePublicClientProxy.Generated.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/GlobalResourcePublicClientProxy.Generated.cs new file mode 100644 index 0000000000..d7354b9e87 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/GlobalResourcePublicClientProxy.Generated.cs @@ -0,0 +1,27 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Modeling; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client.ClientProxying; +using Volo.CmsKit.Public.GlobalResources; + +// ReSharper disable once CheckNamespace +namespace Volo.CmsKit.Public.GlobalResources.ClientProxies; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IGlobalResourcePublicAppService), typeof(GlobalResourcePublicClientProxy))] +public partial class GlobalResourcePublicClientProxy : ClientProxyBase, IGlobalResourcePublicAppService +{ + public virtual async Task GetGlobalScriptAsync() + { + return await RequestAsync(nameof(GetGlobalScriptAsync)); + } + + public virtual async Task GetGlobalStyleAsync() + { + return await RequestAsync(nameof(GetGlobalStyleAsync)); + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/GlobalResourcePublicClientProxy.cs b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/GlobalResourcePublicClientProxy.cs new file mode 100644 index 0000000000..76549aec1e --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/GlobalResourcePublicClientProxy.cs @@ -0,0 +1,7 @@ +// This file is part of GlobalResourcePublicClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace Volo.CmsKit.Public.GlobalResources.ClientProxies; + +public partial class GlobalResourcePublicClientProxy +{ +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json index 0387176b02..d39e795845 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json +++ b/modules/cms-kit/src/Volo.CmsKit.Public.HttpApi.Client/ClientProxies/cms-kit-generate-proxy.json @@ -7,6 +7,8 @@ "Volo.CmsKit.Public.Tags.TagPublicController": { "controllerName": "TagPublic", "controllerGroupName": "TagPublic", + "isRemoteService": true, + "apiVersion": null, "type": "Volo.CmsKit.Public.Tags.TagPublicController", "interfaces": [ { @@ -76,6 +78,8 @@ "Volo.CmsKit.Public.Reactions.ReactionPublicController": { "controllerName": "ReactionPublic", "controllerGroupName": "ReactionPublic", + "isRemoteService": true, + "apiVersion": null, "type": "Volo.CmsKit.Public.Reactions.ReactionPublicController", "interfaces": [ { @@ -299,6 +303,8 @@ "Volo.CmsKit.Public.Ratings.RatingPublicController": { "controllerName": "RatingPublic", "controllerGroupName": "RatingPublic", + "isRemoteService": true, + "apiVersion": null, "type": "Volo.CmsKit.Public.Ratings.RatingPublicController", "interfaces": [ { @@ -502,6 +508,8 @@ "Volo.CmsKit.Public.Pages.PagesPublicController": { "controllerName": "PagesPublic", "controllerGroupName": "PagesPublic", + "isRemoteService": true, + "apiVersion": null, "type": "Volo.CmsKit.Public.Pages.PagesPublicController", "interfaces": [ { @@ -551,6 +559,8 @@ "Volo.CmsKit.Public.Menus.MenuItemPublicController": { "controllerName": "MenuItemPublic", "controllerGroupName": "MenuItemPublic", + "isRemoteService": true, + "apiVersion": null, "type": "Volo.CmsKit.Public.Menus.MenuItemPublicController", "interfaces": [ { @@ -575,9 +585,55 @@ } } }, + "Volo.CmsKit.Public.GlobalResources.GlobalResourcePublicController": { + "controllerName": "GlobalResourcePublic", + "controllerGroupName": "GlobalResourcePublic", + "isRemoteService": true, + "apiVersion": null, + "type": "Volo.CmsKit.Public.GlobalResources.GlobalResourcePublicController", + "interfaces": [ + { + "type": "Volo.CmsKit.Public.GlobalResources.IGlobalResourcePublicAppService" + } + ], + "actions": { + "GetGlobalScriptAsync": { + "uniqueName": "GetGlobalScriptAsync", + "name": "GetGlobalScriptAsync", + "httpMethod": "GET", + "url": "api/cms-kit-public/global-resources/script", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "Volo.CmsKit.Public.GlobalResources.GlobalResourceDto", + "typeSimple": "Volo.CmsKit.Public.GlobalResources.GlobalResourceDto" + }, + "allowAnonymous": null, + "implementFrom": "Volo.CmsKit.Public.GlobalResources.IGlobalResourcePublicAppService" + }, + "GetGlobalStyleAsync": { + "uniqueName": "GetGlobalStyleAsync", + "name": "GetGlobalStyleAsync", + "httpMethod": "GET", + "url": "api/cms-kit-public/global-resources/style", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "Volo.CmsKit.Public.GlobalResources.GlobalResourceDto", + "typeSimple": "Volo.CmsKit.Public.GlobalResources.GlobalResourceDto" + }, + "allowAnonymous": null, + "implementFrom": "Volo.CmsKit.Public.GlobalResources.IGlobalResourcePublicAppService" + } + } + }, "Volo.CmsKit.Public.Comments.CommentPublicController": { "controllerName": "CommentPublic", "controllerGroupName": "CommentPublic", + "isRemoteService": true, + "apiVersion": null, "type": "Volo.CmsKit.Public.Comments.CommentPublicController", "interfaces": [ { @@ -818,6 +874,8 @@ "Volo.CmsKit.Public.Blogs.BlogPostPublicController": { "controllerName": "BlogPostPublic", "controllerGroupName": "BlogPostPublic", + "isRemoteService": true, + "apiVersion": null, "type": "Volo.CmsKit.Public.Blogs.BlogPostPublicController", "interfaces": [ { @@ -899,9 +957,9 @@ }, { "name": "input", - "typeAsString": "Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto, Volo.Abp.Ddd.Application.Contracts", - "type": "Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto", - "typeSimple": "Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto", + "typeAsString": "Volo.CmsKit.Public.Blogs.BlogPostGetListInput, Volo.CmsKit.Public.Application.Contracts", + "type": "Volo.CmsKit.Public.Blogs.BlogPostGetListInput", + "typeSimple": "Volo.CmsKit.Public.Blogs.BlogPostGetListInput", "isOptional": false, "defaultValue": null } @@ -919,6 +977,30 @@ "bindingSourceId": "Path", "descriptorName": "" }, + { + "nameOnMethod": "input", + "name": "AuthorId", + "jsonName": null, + "type": "System.Guid?", + "typeSimple": "string?", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "Sorting", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, { "nameOnMethod": "input", "name": "SkipCount", @@ -942,6 +1024,43 @@ "constraintTypes": null, "bindingSourceId": "ModelBinding", "descriptorName": "input" + } + ], + "returnValue": { + "type": "Volo.Abp.Application.Dtos.PagedResultDto", + "typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto" + }, + "allowAnonymous": null, + "implementFrom": "Volo.CmsKit.Public.Blogs.IBlogPostPublicAppService" + }, + "GetAuthorsHasBlogPostsAsyncByInput": { + "uniqueName": "GetAuthorsHasBlogPostsAsyncByInput", + "name": "GetAuthorsHasBlogPostsAsync", + "httpMethod": "GET", + "url": "api/cms-kit-public/blog-posts/authors", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "input", + "typeAsString": "Volo.CmsKit.Public.Blogs.BlogPostFilteredPagedAndSortedResultRequestDto, Volo.CmsKit.Public.Application.Contracts", + "type": "Volo.CmsKit.Public.Blogs.BlogPostFilteredPagedAndSortedResultRequestDto", + "typeSimple": "Volo.CmsKit.Public.Blogs.BlogPostFilteredPagedAndSortedResultRequestDto", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "input", + "name": "Filter", + "jsonName": null, + "type": "System.String", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" }, { "nameOnMethod": "input", @@ -954,11 +1073,72 @@ "constraintTypes": null, "bindingSourceId": "ModelBinding", "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "SkipCount", + "jsonName": null, + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" + }, + { + "nameOnMethod": "input", + "name": "MaxResultCount", + "jsonName": null, + "type": "System.Int32", + "typeSimple": "number", + "isOptional": false, + "defaultValue": null, + "constraintTypes": null, + "bindingSourceId": "ModelBinding", + "descriptorName": "input" } ], "returnValue": { - "type": "Volo.Abp.Application.Dtos.PagedResultDto", - "typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto" + "type": "Volo.Abp.Application.Dtos.PagedResultDto", + "typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto" + }, + "allowAnonymous": null, + "implementFrom": "Volo.CmsKit.Public.Blogs.IBlogPostPublicAppService" + }, + "GetAuthorHasBlogPostAsyncById": { + "uniqueName": "GetAuthorHasBlogPostAsyncById", + "name": "GetAuthorHasBlogPostAsync", + "httpMethod": "GET", + "url": "api/cms-kit-public/blog-posts/authors/{id}", + "supportedVersions": [], + "parametersOnMethod": [ + { + "name": "id", + "typeAsString": "System.Guid, System.Private.CoreLib", + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null + } + ], + "parameters": [ + { + "nameOnMethod": "id", + "name": "id", + "jsonName": null, + "type": "System.Guid", + "typeSimple": "string", + "isOptional": false, + "defaultValue": null, + "constraintTypes": [], + "bindingSourceId": "Path", + "descriptorName": "" + } + ], + "returnValue": { + "type": "Volo.CmsKit.Users.CmsUserDto", + "typeSimple": "Volo.CmsKit.Users.CmsUserDto" }, "allowAnonymous": null, "implementFrom": "Volo.CmsKit.Public.Blogs.IBlogPostPublicAppService" 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 8a788f7a34..9f43d65766 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 @@ -40,8 +40,15 @@ public class BlogPostPublicController : CmsKitPublicControllerBase, IBlogPostPub [HttpGet] [Route("authors")] - public virtual Task> GetAuthorsHasBlogPostsAsync() + public Task> GetAuthorsHasBlogPostsAsync(BlogPostFilteredPagedAndSortedResultRequestDto input) { - return BlogPostPublicAppService.GetAuthorsHasBlogPostsAsync(); + return BlogPostPublicAppService.GetAuthorsHasBlogPostsAsync(input); + } + + [HttpGet] + [Route("authors/{id}")] + public Task GetAuthorHasBlogPostAsync(Guid id) + { + return BlogPostPublicAppService.GetAuthorHasBlogPostAsync(id); } } \ No newline at end of file diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml index 4ae3c007c7..32df5fb2fd 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml @@ -24,19 +24,19 @@
- - + + @if(Model.SelectedAuthor != null) + { + }
diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs index c9dc49931d..c7f667382b 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs @@ -20,16 +20,15 @@ public class IndexModel : CmsKitPublicPageModelBase [BindProperty(SupportsGet = true)] public int CurrentPage { get; set; } = 1; - + [BindProperty(SupportsGet = true)] public Guid? AuthorId { get; set; } public PagedResultDto Blogs { get; private set; } public PagerModel PagerModel => new PagerModel(Blogs.TotalCount, Blogs.Items.Count, CurrentPage, PageSize, Request.Path.ToString()); - - [BindProperty(SupportsGet = true)] - public List Authors { get; set; } + + public CmsUserDto SelectedAuthor { get; set; } protected IBlogPostPublicAppService BlogPostPublicAppService { get; } @@ -48,7 +47,10 @@ public class IndexModel : CmsKitPublicPageModelBase MaxResultCount = PageSize, AuthorId = AuthorId }); - - Authors = await BlogPostPublicAppService.GetAuthorsHasBlogPostsAsync(); + + if (AuthorId != null) + { + SelectedAuthor = await BlogPostPublicAppService.GetAuthorHasBlogPostAsync(AuthorId.Value); + } } }