Musa Demir
5 years ago
No known key found for this signature in database
GPG Key ID: 117DF92322553DC8
10 changed files with
31 additions and
13 deletions
-
modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Blogs/BlogPostGetListInput.cs
-
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Blogs/BlogPostAdminAppService.cs
-
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Blogs/IBlogPostRepository.cs
-
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Blogs/EfCoreBlogPostRepository.cs
-
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs
-
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/BlogPostGetListInput.cs
-
modules/cms-kit/src/Volo.CmsKit.Public.Application.Contracts/Volo/CmsKit/Public/Blogs/IBlogPostPublicAppService.cs
-
modules/cms-kit/src/Volo.CmsKit.Public.Application/Volo/CmsKit/Public/Blogs/BlogPostPublicAppService.cs
-
modules/cms-kit/src/Volo.CmsKit.Public.HttpApi/Volo/CmsKit/Public/Blogs/BlogPostPublicController.cs
-
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs
|
|
|
@ -8,4 +8,6 @@ public class BlogPostGetListInput : PagedAndSortedResultRequestDto |
|
|
|
public string Filter { get; set; } |
|
|
|
|
|
|
|
public Guid? BlogId { get; set; } |
|
|
|
|
|
|
|
public Guid? AuthorId { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
@ -89,7 +89,8 @@ public class BlogPostAdminAppService : CmsKitAppServiceBase, IBlogPostAdminAppSe |
|
|
|
{ |
|
|
|
var blogs = (await BlogRepository.GetListAsync()).ToDictionary(x => x.Id); |
|
|
|
|
|
|
|
var blogPosts = await BlogPostRepository.GetListAsync(input.Filter, input.BlogId, input.MaxResultCount, input.SkipCount, input.Sorting); |
|
|
|
var blogPosts = await BlogPostRepository.GetListAsync(input.Filter, input.BlogId, input.AuthorId, |
|
|
|
input.MaxResultCount, input.SkipCount, input.Sorting); |
|
|
|
|
|
|
|
var count = await BlogPostRepository.GetCountAsync(input.Filter); |
|
|
|
|
|
|
|
|
|
|
|
@ -16,6 +16,7 @@ public interface IBlogPostRepository : IBasicRepository<BlogPost, Guid> |
|
|
|
Task<List<BlogPost>> GetListAsync( |
|
|
|
string filter = null, |
|
|
|
Guid? blogId = null, |
|
|
|
Guid? authorId = null, |
|
|
|
int maxResultCount = int.MaxValue, |
|
|
|
int skipCount = 0, |
|
|
|
string sorting = null, |
|
|
|
@ -24,4 +25,4 @@ public interface IBlogPostRepository : IBasicRepository<BlogPost, Guid> |
|
|
|
Task<bool> SlugExistsAsync(Guid blogId, string slug, CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task<BlogPost> GetBySlugAsync(Guid blogId, string slug, CancellationToken cancellationToken = default); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -54,6 +54,7 @@ public class EfCoreBlogPostRepository : EfCoreRepository<CmsKitDbContext, BlogPo |
|
|
|
public virtual async Task<List<BlogPost>> GetListAsync( |
|
|
|
string filter = null, |
|
|
|
Guid? blogId = null, |
|
|
|
Guid? authorId = null, |
|
|
|
int maxResultCount = int.MaxValue, |
|
|
|
int skipCount = 0, |
|
|
|
string sorting = null, |
|
|
|
@ -66,7 +67,8 @@ public class EfCoreBlogPostRepository : EfCoreRepository<CmsKitDbContext, BlogPo |
|
|
|
|
|
|
|
var queryable = blogPostsDbSet |
|
|
|
.WhereIf(blogId.HasValue, x => x.BlogId == blogId) |
|
|
|
.WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); |
|
|
|
.WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)) |
|
|
|
.WhereIf(authorId.HasValue, x => x.AuthorId == authorId); |
|
|
|
|
|
|
|
queryable = queryable.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(BlogPost.CreationTime)} desc" : sorting); |
|
|
|
|
|
|
|
|
|
|
|
@ -55,6 +55,7 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B |
|
|
|
public virtual async Task<List<BlogPost>> GetListAsync( |
|
|
|
string filter = null, |
|
|
|
Guid? blogId = null, |
|
|
|
Guid? authorId = null, |
|
|
|
int maxResultCount = int.MaxValue, |
|
|
|
int skipCount = 0, |
|
|
|
string sorting = null, |
|
|
|
@ -68,7 +69,8 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B |
|
|
|
|
|
|
|
var queryable = blogPostQueryable |
|
|
|
.WhereIf(blogId.HasValue, x => x.BlogId == blogId) |
|
|
|
.WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)); |
|
|
|
.WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Title.Contains(filter) || x.Slug.Contains(filter)) |
|
|
|
.WhereIf(authorId.HasValue, x => x.AuthorId == authorId); |
|
|
|
|
|
|
|
queryable = queryable.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(BlogPost.CreationTime)} desc" : sorting); |
|
|
|
|
|
|
|
|
|
|
|
@ -0,0 +1,11 @@ |
|
|
|
using System; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
|
|
|
|
namespace Volo.CmsKit.Public.Blogs; |
|
|
|
|
|
|
|
public class BlogPostGetListInput : PagedAndSortedResultRequestDto |
|
|
|
{ |
|
|
|
public string BlogSlug { get; set; } |
|
|
|
|
|
|
|
public Guid? AuthorId { get; set; } |
|
|
|
} |
|
|
|
@ -7,7 +7,7 @@ namespace Volo.CmsKit.Public.Blogs; |
|
|
|
|
|
|
|
public interface IBlogPostPublicAppService : IApplicationService |
|
|
|
{ |
|
|
|
Task<PagedResultDto<BlogPostPublicDto>> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input); |
|
|
|
Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(BlogPostGetListInput input); |
|
|
|
|
|
|
|
Task<BlogPostPublicDto> GetAsync([NotNull] string blogSlug, [NotNull] string blogPostSlug); |
|
|
|
} |
|
|
|
|
|
|
|
@ -32,11 +32,12 @@ public class BlogPostPublicAppService : CmsKitPublicAppServiceBase, IBlogPostPub |
|
|
|
return ObjectMapper.Map<BlogPost, BlogPostPublicDto>(blogPost); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<PagedResultDto<BlogPostPublicDto>> GetListAsync([NotNull] string blogSlug, PagedAndSortedResultRequestDto input) |
|
|
|
public virtual async Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(BlogPostGetListInput input) |
|
|
|
{ |
|
|
|
var blog = await BlogRepository.GetBySlugAsync(blogSlug); |
|
|
|
var blog = await BlogRepository.GetBySlugAsync(input.BlogSlug); |
|
|
|
|
|
|
|
var blogPosts = await BlogPostRepository.GetListAsync(null, blog.Id, input.MaxResultCount, input.SkipCount, input.Sorting); |
|
|
|
var blogPosts = await BlogPostRepository.GetListAsync(null, blog.Id, input.AuthorId, input.MaxResultCount, |
|
|
|
input.SkipCount, input.Sorting); |
|
|
|
|
|
|
|
return new PagedResultDto<BlogPostPublicDto>( |
|
|
|
await BlogPostRepository.GetCountAsync(blogId: blog.Id), |
|
|
|
|
|
|
|
@ -30,9 +30,8 @@ public class BlogPostPublicController : CmsKitPublicControllerBase, IBlogPostPub |
|
|
|
} |
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
[Route("{blogSlug}")] |
|
|
|
public virtual Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(string blogSlug, PagedAndSortedResultRequestDto input) |
|
|
|
public virtual Task<PagedResultDto<BlogPostPublicDto>> GetListAsync(BlogPostGetListInput input) |
|
|
|
{ |
|
|
|
return BlogPostPublicAppService.GetListAsync(blogSlug, input); |
|
|
|
return BlogPostPublicAppService.GetListAsync(input); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -34,8 +34,7 @@ public class IndexModel : CmsKitPublicPageModelBase |
|
|
|
public async Task OnGetAsync() |
|
|
|
{ |
|
|
|
Blogs = await BlogPostPublicAppService.GetListAsync( |
|
|
|
BlogSlug, |
|
|
|
new PagedAndSortedResultRequestDto |
|
|
|
new BlogPostGetListInput |
|
|
|
{ |
|
|
|
SkipCount = PageSize * (CurrentPage - 1), |
|
|
|
MaxResultCount = PageSize |
|
|
|
|