|
|
|
@ -1,10 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
|
using Volo.Abp.Guids; |
|
|
|
using Volo.Docs.Documents; |
|
|
|
using Volo.Docs.Documents.FullSearch.Elastic; |
|
|
|
using Volo.Docs.Localization; |
|
|
|
using Volo.Docs.Projects; |
|
|
|
|
|
|
|
@ -14,15 +17,22 @@ namespace Volo.Docs.Admin.Projects |
|
|
|
public class ProjectAdminAppService : ApplicationService, IProjectAdminAppService |
|
|
|
{ |
|
|
|
private readonly IProjectRepository _projectRepository; |
|
|
|
private readonly IDocumentRepository _documentRepository; |
|
|
|
private readonly IDocumentFullSearch _documentFullSearch; |
|
|
|
private readonly IGuidGenerator _guidGenerator; |
|
|
|
|
|
|
|
public ProjectAdminAppService( |
|
|
|
IProjectRepository projectRepository, IGuidGenerator guidGenerator) |
|
|
|
IProjectRepository projectRepository, |
|
|
|
IDocumentRepository documentRepository, |
|
|
|
IDocumentFullSearch documentFullSearch, |
|
|
|
IGuidGenerator guidGenerator) |
|
|
|
{ |
|
|
|
ObjectMapperContext = typeof(DocsAdminApplicationModule); |
|
|
|
LocalizationResource = typeof(DocsResource); |
|
|
|
|
|
|
|
_projectRepository = projectRepository; |
|
|
|
_documentRepository = documentRepository; |
|
|
|
_documentFullSearch = documentFullSearch; |
|
|
|
_guidGenerator = guidGenerator; |
|
|
|
} |
|
|
|
|
|
|
|
@ -51,7 +61,7 @@ namespace Volo.Docs.Admin.Projects |
|
|
|
{ |
|
|
|
throw new ProjectShortNameAlreadyExistsException(input.ShortName); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var project = new Project(_guidGenerator.Create(), |
|
|
|
input.Name, |
|
|
|
input.ShortName, |
|
|
|
@ -71,7 +81,7 @@ namespace Volo.Docs.Admin.Projects |
|
|
|
{ |
|
|
|
project.ExtraProperties.Add(extraProperty.Key, extraProperty.Value); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
project = await _projectRepository.InsertAsync(project); |
|
|
|
|
|
|
|
return ObjectMapper.Map<Project, ProjectDto>(project); |
|
|
|
@ -106,6 +116,57 @@ namespace Volo.Docs.Admin.Projects |
|
|
|
{ |
|
|
|
await _projectRepository.DeleteAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task ReindexAsync(ReindexInput input) |
|
|
|
{ |
|
|
|
var project = await _projectRepository.GetAsync(input.ProjectId); |
|
|
|
|
|
|
|
await _documentFullSearch.DeleteAllByProjectIdAsync(project.Id); |
|
|
|
|
|
|
|
var docs = await _documentRepository.GetListByProjectId(project.Id); |
|
|
|
|
|
|
|
foreach (var doc in docs) |
|
|
|
{ |
|
|
|
if (doc.FileName == project.NavigationDocumentName) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (doc.FileName == project.ParametersDocumentName) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
await _documentFullSearch.AddOrUpdateAsync(doc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public async Task ReindexAllAsync() |
|
|
|
{ |
|
|
|
await _documentFullSearch.DeleteAllAsync(); |
|
|
|
|
|
|
|
var docs = await _documentRepository.GetListAsync(); |
|
|
|
var projects = await _projectRepository.GetListAsync(); |
|
|
|
foreach (var doc in docs) |
|
|
|
{ |
|
|
|
var project = projects.FirstOrDefault(x => x.Id == doc.ProjectId); |
|
|
|
if (project == null) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (doc.FileName == project.NavigationDocumentName) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (doc.FileName == project.ParametersDocumentName) |
|
|
|
{ |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
await _documentFullSearch.AddOrUpdateAsync(doc); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|