From 15fc720dd329c9a791c82d698089f3f447e64508 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 13 Feb 2020 20:42:26 +0800 Subject: [PATCH] Document contributors. --- .../Docs/Documents/IDocumentRepository.cs | 5 +++- .../Documents/EFCoreDocumentRepository.cs | 12 ++++++-- .../DocsEfCoreQueryableExtensions.cs | 14 +++++++++ .../Docs/Documents/MongoDocumentRepository.cs | 7 +++-- .../Pages/Documents/Project/Index.cshtml | 29 ++++++++++--------- 5 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsEfCoreQueryableExtensions.cs diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs index b9e0edaee5..aaabb2d8c7 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; @@ -8,6 +9,8 @@ namespace Volo.Docs.Documents { public interface IDocumentRepository : IBasicRepository { - Task FindAsync(Guid projectId, string name, string languageCode, string version); + Task FindAsync(Guid projectId, string name, string languageCode, string version, + bool includeDetails = true, + CancellationToken cancellationToken = default); } } diff --git a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs index e965bd11a6..d9a96e6c4f 100644 --- a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; @@ -14,10 +15,15 @@ namespace Volo.Docs.Documents { } - public async Task FindAsync(Guid projectId, string name, string languageCode, string version) + public async Task FindAsync(Guid projectId, string name, string languageCode, string version, + bool includeDetails = true, + CancellationToken cancellationToken = default) { - return await DbSet.FirstOrDefaultAsync(x => - x.ProjectId == projectId && x.Name == name && x.LanguageCode == languageCode && x.Version == version); + return await DbSet.IncludeDetails(includeDetails) + .FirstOrDefaultAsync(x => + x.ProjectId == projectId && x.Name == name && x.LanguageCode == languageCode && + x.Version == version, + cancellationToken); } } } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsEfCoreQueryableExtensions.cs b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsEfCoreQueryableExtensions.cs new file mode 100644 index 0000000000..0bd2e4fff8 --- /dev/null +++ b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/EntityFrameworkCore/DocsEfCoreQueryableExtensions.cs @@ -0,0 +1,14 @@ +using System.Linq; +using Microsoft.EntityFrameworkCore; +using Volo.Docs.Documents; + +namespace Volo.Docs.EntityFrameworkCore +{ + public static class DocsEfCoreQueryableExtensions + { + public static IQueryable IncludeDetails(this IQueryable queryable, bool include = true) + { + return !include ? queryable : queryable.Include(x => x.Contributors); + } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs index 5e7cc5871a..548b89e246 100644 --- a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; using MongoDB.Driver.Linq; using Volo.Abp.Domain.Repositories.MongoDB; @@ -14,12 +15,14 @@ namespace Volo.Docs.Documents { } - public async Task FindAsync(Guid projectId, string name, string languageCode, string version) + public async Task FindAsync(Guid projectId, string name, string languageCode, string version, + bool includeDetails = true, + CancellationToken cancellationToken = default) { return await GetMongoQueryable().FirstOrDefaultAsync(x => x.ProjectId == projectId && x.Name == name && x.LanguageCode == languageCode && - x.Version == version); + x.Version == version, cancellationToken); } } } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml index a8d950b1ce..3430503f7d 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml @@ -190,25 +190,26 @@ @(L["Edit"]) (@L["LastEditTime"]: @Model.Document.LastUpdatedTime.ToShortDateString()) } + +
+ @if (Model.Document.Contributors != null && Model.Document.Contributors.Count > 0) + { + @(L["Contributors"].Value + " :") + @foreach (var contributor in Model.Document.Contributors) + { + + + + } + } +
+
- @if (Model.Document.Contributors != null && Model.Document.Contributors.Count > 0) - { -
- @(L["Contributors"].Value + " :") - @foreach (var contributor in Model.Document.Contributors) - { - - - - } -
- } - @if (Model.DocumentPreferences != null && Model.DocumentPreferences.Parameters != null && Model.DocumentPreferences.Parameters.Any()) {