Merge pull request #9514 from abpframework/auto-merge/rel-4-4/469

pull/10896/head
maliming 4 years ago committed by GitHub
commit ba4e5585b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,19 +16,9 @@ namespace Volo.Docs.Admin.Documents
public virtual string LanguageCode { get; set; }
public virtual string FileName { get; set; }
public virtual string Content { get; set; }
public virtual string Format { get; set; }
public virtual string EditLink { get; set; }
public virtual string RootUrl { get; set; }
public virtual string RawRootUrl { get; set; }
public virtual string LocalDirectory { get; set; }
public virtual DateTime CreationTime { get; set; }
public virtual DateTime LastUpdatedTime { get; set; }

@ -0,0 +1,14 @@
using System;
using Volo.Abp.Application.Dtos;
namespace Volo.Docs.Admin.Documents
{
public class DocumentWithoutDetailsDto : EntityDto<Guid>
{
public virtual string Version { get; set; }
public virtual string LanguageCode { get; set; }
public virtual string Format { get; set; }
}
}

@ -12,6 +12,7 @@ namespace Volo.Docs.Admin
{
CreateMap<Project, ProjectDto>();
CreateMap<Document, DocumentDto>();
CreateMap<DocumentWithoutContent, DocumentDto>();
}
}
}

@ -188,7 +188,7 @@ namespace Volo.Docs.Admin.Documents
return new PagedResultDto<DocumentDto>
{
TotalCount = totalCount,
Items = ObjectMapper.Map<List<Document>, List<DocumentDto>>(docs)
Items = ObjectMapper.Map<List<DocumentWithoutContent>, List<DocumentDto>>(docs)
};
}

@ -205,9 +205,9 @@ namespace Volo.Docs.Documents
foreach (var project in projects)
{
var documents = await _documentRepository.GetListByProjectId(project.Id);
var documentWithoutDetailsList = await _documentRepository.GetListWithoutDetailsByProjectId(project.Id);
foreach (var document in documents)
foreach (var document in documentWithoutDetailsList)
{
try
{
@ -223,7 +223,7 @@ namespace Volo.Docs.Documents
return documentUrls;
}
private async Task AddDocumentToUrls(string prefix, Project project, Document document,
private async Task AddDocumentToUrls(string prefix, Project project, DocumentWithoutDetails document,
List<string> documentUrls)
{
var navigationNodes = await GetNavigationNodesAsync(prefix, project, document);
@ -234,7 +234,7 @@ namespace Volo.Docs.Documents
List<NavigationNode> navigationNodes,
List<string> documentUrls,
Project project,
Document document)
DocumentWithoutDetails document)
{
navigationNodes?.ForEach(node =>
{
@ -245,7 +245,7 @@ namespace Volo.Docs.Documents
}
private async Task<List<NavigationNode>> GetNavigationNodesAsync(string prefix, Project project,
Document document)
DocumentWithoutDetails document)
{
var version = GetProjectVersionPrefixIfExist(project) + document.Version;
var navigationDocument = await GetDocumentWithDetailsDtoAsync(
@ -266,7 +266,7 @@ namespace Volo.Docs.Documents
}
private List<string> GetDocumentLinks(NavigationNode node, List<string> documentUrls, string prefix,
string shortName, Document document)
string shortName, DocumentWithoutDetails document)
{
if (!IsExternalLink(node.Path))
{
@ -283,7 +283,7 @@ namespace Volo.Docs.Documents
return documentUrls;
}
private string NormalizePath(string prefix, string path, string shortName, Document document)
private string NormalizePath(string prefix, string path, string shortName, DocumentWithoutDetails document)
{
var pathWithoutFileExtension = RemoveFileExtensionFromPath(path, document.Format);
var normalizedPath = prefix + document.LanguageCode + "/" + shortName + "/" + document.Version + "/" +

@ -0,0 +1,29 @@
using System;
namespace Volo.Docs.Documents
{
public class DocumentWithoutContent
{
public Guid Id { get; set; }
public virtual Guid ProjectId { get; set; }
public virtual string Name { get; set; }
public virtual string Version { get; set; }
public virtual string LanguageCode { get; set; }
public virtual string FileName { get; set; }
public virtual string Format { get; set; }
public virtual DateTime CreationTime { get; set; }
public virtual DateTime LastUpdatedTime { get; set; }
public virtual DateTime? LastSignificantUpdateTime { get; set; }
public virtual DateTime LastCachedTime { get; set; }
}
}

@ -0,0 +1,15 @@
using System;
namespace Volo.Docs.Documents
{
public class DocumentWithoutDetails
{
public Guid Id { get; set; }
public virtual string Version { get; set; }
public virtual string LanguageCode { get; set; }
public virtual string Format { get; set; }
}
}

@ -8,6 +8,8 @@ namespace Volo.Docs.Documents
{
public interface IDocumentRepository : IBasicRepository<Document>
{
Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default);
Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default);
Task<Document> FindAsync(Guid projectId,
@ -23,7 +25,7 @@ namespace Volo.Docs.Documents
string version,
CancellationToken cancellationToken = default);
Task<List<Document>> GetAllAsync(
Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId,
string name,
string version,

@ -18,13 +18,27 @@ namespace Volo.Docs.Documents
{
}
public async Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(d => d.ProjectId == projectId)
.Select(x => new DocumentWithoutDetails
{
Id = x.Id,
Version = x.Version,
LanguageCode = x.LanguageCode,
Format = x.Format,
})
.ToListAsync(cancellationToken: cancellationToken);
}
public async Task<List<Document>> GetListByProjectId(Guid projectId,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken: cancellationToken);
}
public async Task<List<Document>> GetAllAsync(
public async Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId,
string name,
string version,
@ -130,7 +144,7 @@ namespace Volo.Docs.Documents
return await (await GetDbSetAsync()).Where(x => x.Id == id).SingleAsync(cancellationToken: cancellationToken);
}
protected virtual IQueryable<Document> ApplyFilterForGetAll(
protected virtual IQueryable<DocumentWithoutContent> ApplyFilterForGetAll(
IQueryable<Document> query,
Guid? projectId,
string name,
@ -176,7 +190,21 @@ namespace Volo.Docs.Documents
.WhereIf(lastCachedTimeMin.HasValue,
d => d.LastCachedTime.Date >= lastCachedTimeMin.Value.Date)
.WhereIf(lastCachedTimeMax.HasValue,
d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date);
d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date)
.Select(x => new DocumentWithoutContent
{
Id = x.Id,
ProjectId = x.ProjectId,
Name = x.Name,
Version = x.Version,
LanguageCode = x.LanguageCode,
FileName = x.FileName,
Format = x.Format,
CreationTime = x.CreationTime,
LastUpdatedTime = x.LastUpdatedTime,
LastSignificantUpdateTime = x.LastSignificantUpdateTime,
LastCachedTime = x.LastCachedTime
});
}
}
}

@ -20,6 +20,20 @@ namespace Volo.Docs.Documents
{
}
public async Task<List<DocumentWithoutDetails>> GetListWithoutDetailsByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.Where(d => d.ProjectId == projectId)
.Select(x => new DocumentWithoutDetails
{
Id = x.Id,
Version = x.Version,
LanguageCode = x.LanguageCode,
Format = x.Format
})
.ToListAsync(cancellationToken);
}
public async Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken);
@ -43,7 +57,7 @@ namespace Volo.Docs.Documents
x.Version == version, cancellationToken: cancellationToken);
}
public async Task<List<Document>> GetAllAsync(
public async Task<List<DocumentWithoutContent>> GetAllAsync(
Guid? projectId,
string name,
string version,
@ -81,8 +95,8 @@ namespace Volo.Docs.Documents
lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax,
lastCachedTimeMin: lastCachedTimeMin,
lastCachedTimeMax: lastCachedTimeMax)
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As<IMongoQueryable<Document>>()
.PageBy<Document, IMongoQueryable<Document>>(skipCount, maxResultCount)
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As<IMongoQueryable<DocumentWithoutContent>>()
.PageBy<DocumentWithoutContent, IMongoQueryable<DocumentWithoutContent>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
@ -135,7 +149,7 @@ namespace Volo.Docs.Documents
return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(cancellationToken);
}
protected virtual IMongoQueryable<Document> ApplyFilterForGetAll(
protected virtual IMongoQueryable<DocumentWithoutContent> ApplyFilterForGetAll(
IMongoQueryable<Document> query,
Guid? projectId,
string name,
@ -218,7 +232,20 @@ namespace Volo.Docs.Documents
query = query.Where(d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date);
}
return query;
return query.Select(x => new DocumentWithoutContent
{
Id = x.Id,
ProjectId = x.ProjectId,
Name = x.Name,
Version = x.Version,
LanguageCode = x.LanguageCode,
FileName = x.FileName,
Format = x.Format,
CreationTime = x.CreationTime,
LastUpdatedTime = x.LastUpdatedTime,
LastSignificantUpdateTime = x.LastSignificantUpdateTime,
LastCachedTime = x.LastCachedTime
});
}
}
}

Loading…
Cancel
Save