Browse Source
Merge pull request #17767 from abpframework/liangshiwei/cms-patch
Add pagination to Tag repository
pull/17773/head
Engincan VESKE
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
25 additions and
5 deletions
-
modules/cms-kit/src/Volo.CmsKit.Admin.Application/Volo/CmsKit/Admin/Tags/TagAdminAppService.cs
-
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/ITagRepository.cs
-
modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Tags/EfCoreTagRepository.cs
-
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Tags/MongoTagRepository.cs
|
|
|
@ -92,7 +92,7 @@ public class TagAdminAppService : CmsKitAppServiceBase, ITagAdminAppService |
|
|
|
[Authorize(CmsKitAdminPermissions.Tags.Default)] |
|
|
|
public virtual async Task<PagedResultDto<TagDto>> GetListAsync(TagGetListInput input) |
|
|
|
{ |
|
|
|
var tags = await Repository.GetListAsync(input.Filter); |
|
|
|
var tags = await Repository.GetListAsync(input.Filter, input.MaxResultCount, input.SkipCount, input.Sorting); |
|
|
|
var count = await Repository.GetCountAsync(input.Filter); |
|
|
|
|
|
|
|
return new PagedResultDto<TagDto>( |
|
|
|
|
|
|
|
@ -26,6 +26,9 @@ public interface ITagRepository : IBasicRepository<Tag, Guid> |
|
|
|
|
|
|
|
Task<List<Tag>> GetListAsync( |
|
|
|
string filter, |
|
|
|
int maxResultCount = int.MaxValue, |
|
|
|
int skipCount = 0, |
|
|
|
string sorting = null, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task<int> GetCountAsync( |
|
|
|
|
|
|
|
@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Dynamic.Core; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
@ -96,9 +97,16 @@ public class EfCoreTagRepository : EfCoreRepository<ICmsKitDbContext, Tag, Guid> |
|
|
|
.ToListAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<Tag>> GetListAsync(string filter, CancellationToken cancellationToken = default) |
|
|
|
public virtual async Task<List<Tag>> GetListAsync( |
|
|
|
string filter, |
|
|
|
int maxResultCount = int.MaxValue, |
|
|
|
int skipCount = 0, |
|
|
|
string sorting = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await (await GetQueryableByFilterAsync(filter)).ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
return await (await GetQueryableByFilterAsync(filter)) |
|
|
|
.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(Tag.CreationTime)}" : sorting) |
|
|
|
.PageBy(skipCount, maxResultCount).ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<int> GetCountAsync(string filter, CancellationToken cancellationToken = default) |
|
|
|
|
|
|
|
@ -4,6 +4,7 @@ using MongoDB.Driver.Linq; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Dynamic.Core; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
@ -107,9 +108,17 @@ public class MongoTagRepository : MongoDbRepository<ICmsKitMongoDbContext, Volo. |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<List<Tag>> GetListAsync(string filter, CancellationToken cancellationToken = default) |
|
|
|
public virtual async Task<List<Tag>> GetListAsync(string filter, |
|
|
|
int maxResultCount = int.MaxValue, |
|
|
|
int skipCount = 0, |
|
|
|
string sorting = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await (await GetQueryableByFilterAsync(filter, cancellationToken)).ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
return await (await GetQueryableByFilterAsync(filter, cancellationToken)) |
|
|
|
.OrderBy(sorting.IsNullOrEmpty() ? $"{nameof(Tag.CreationTime)}" : sorting) |
|
|
|
.As<IMongoQueryable<Tag>>() |
|
|
|
.PageBy<Tag, IMongoQueryable<Tag>>(skipCount, maxResultCount) |
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<int> GetCountAsync(string filter, CancellationToken cancellationToken = default) |
|
|
|
|