Browse Source

Merge pull request #9712 from abpframework/liangshiwei/docs

Add GetListAsync mehtod to IDocumentRepository
pull/9713/head
maliming 5 years ago
committed by GitHub
parent
commit
817519f123
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs
  2. 9
      modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs
  3. 10
      modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

8
modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs

@ -25,6 +25,12 @@ namespace Volo.Docs.Documents
string version, string version,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<List<Document>> GetListAsync(
Guid? projectId,
string version,
string name,
CancellationToken cancellationToken = default);
Task<List<DocumentWithoutContent>> GetAllAsync( Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId, Guid? projectId,
string name, string name,
@ -67,4 +73,4 @@ namespace Volo.Docs.Documents
Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default); Task<Document> GetAsync(Guid id, CancellationToken cancellationToken = default);
} }
} }

9
modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs

@ -38,6 +38,15 @@ namespace Volo.Docs.Documents
return await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken: cancellationToken); return await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken: cancellationToken);
} }
public async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.WhereIf(version != null, x => x.Version == version)
.WhereIf(name != null, x => x.Name == name)
.WhereIf(projectId.HasValue, x => x.ProjectId == projectId)
.ToListAsync(cancellationToken: cancellationToken);
}
public async Task<List<DocumentWithoutContent>> GetAllAsync( public async Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId, Guid? projectId,
string name, string name,

10
modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs

@ -57,6 +57,16 @@ namespace Volo.Docs.Documents
x.Version == version, cancellationToken: cancellationToken); x.Version == version, cancellationToken: cancellationToken);
} }
public async Task<List<Document>> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(version != null, x => x.Version == version)
.WhereIf(name != null, x => x.Name == name)
.WhereIf(projectId.HasValue, x => x.ProjectId == projectId)
.As<IMongoQueryable<Document>>()
.ToListAsync(cancellationToken);
}
public async Task<List<DocumentWithoutContent>> GetAllAsync( public async Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId, Guid? projectId,
string name, string name,

Loading…
Cancel
Save