Move document store to domain layer

pull/625/head
Halil ibrahim Kalkan 7 years ago
parent 187a8ae486
commit 7f5365b585

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Docs.Documents;
namespace Volo.Docs.Projects
{

@ -1,12 +1,9 @@
using System;
namespace Volo.Docs.Documents
namespace Volo.Docs.Projects
{
[Serializable]
public class VersionInfoDto
{
public string DisplayName { get; set; }
public string Name { get; set; }
}
}
}

@ -16,8 +16,4 @@
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Caching\Volo.Abp.Caching.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Octokit" Version="0.29.0" />
</ItemGroup>
</Project>

@ -10,6 +10,7 @@ namespace Volo.Docs
public DocsApplicationAutoMapperProfile()
{
CreateMap<Project, ProjectDto>();
CreateMap<VersionInfo, VersionInfoDto>();
CreateMap<Document, DocumentWithDetailsDto>()
.Ignore(x => x.Project);
}

@ -53,7 +53,7 @@ namespace Volo.Docs.Documents
string version)
{
var documentStore = _documentStoreFactory.Create(project.DocumentStoreType);
var document = await documentStore.Find(project, documentName, version);
var document = await documentStore.FindDocument(project, documentName, version);
var dto = ObjectMapper.Map<Document, DocumentWithDetailsDto>(document);
dto.Project = ObjectMapper.Map<Project, ProjectDto>(project);

@ -13,12 +13,12 @@ namespace Volo.Docs.Projects
public class ProjectAppService : ApplicationService, IProjectAppService
{
private readonly IProjectRepository _projectRepository;
private readonly IDistributedCache<List<VersionInfoDto>> _distributedCache;
private readonly IDistributedCache<List<VersionInfo>> _distributedCache;
private readonly IDocumentStoreFactory _documentStoreFactory;
public ProjectAppService(
IProjectRepository projectRepository,
IDistributedCache<List<VersionInfoDto>> distributedCache,
IDistributedCache<List<VersionInfo>> distributedCache,
IDocumentStoreFactory documentStoreFactory)
{
_projectRepository = projectRepository;
@ -71,15 +71,15 @@ namespace Volo.Docs.Projects
versions.First().Name = project.LatestVersionBranchName;
}
return versions;
return ObjectMapper.Map<List<VersionInfo>, List<VersionInfoDto>>(versions);
}
private async Task<List<VersionInfoDto>> GetVersionsFromCache(string projectShortName)
private async Task<List<VersionInfo>> GetVersionsFromCache(string projectShortName)
{
return await _distributedCache.GetAsync(projectShortName);
}
private async Task SetVersionsToCache(string projectShortName, List<VersionInfoDto> versions)
private async Task SetVersionsToCache(string projectShortName, List<VersionInfo> versions)
{
await _distributedCache.SetAsync(
projectShortName,

@ -17,6 +17,10 @@
<Content Remove="Volo\Docs\Localization\Domain\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Octokit" Version="0.29.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Docs.Domain.Shared\Volo.Docs.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" />

@ -7,6 +7,7 @@ using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Volo.Abp.Domain.Services;
using Volo.Docs.Projects;
using ProductHeaderValue = Octokit.ProductHeaderValue;
namespace Volo.Docs.Documents
@ -15,7 +16,7 @@ namespace Volo.Docs.Documents
{
public const string Type = "Github"; //TODO: Convert to "github"
public Task<Document> Find(
public Task<Document> FindDocument(
Projects.Project project,
string documentName,
string version)
@ -81,7 +82,7 @@ namespace Volo.Docs.Documents
}
}
public async Task<List<VersionInfoDto>> GetVersions(Volo.Docs.Projects.Project project)
public async Task<List<VersionInfo>> GetVersions(Volo.Docs.Projects.Project project)
{
try
{
@ -97,12 +98,12 @@ namespace Volo.Docs.Documents
GetGithubRepositoryNameFromUrl(url)
);
return releases.OrderByDescending(r => r.PublishedAt).Select(r => new VersionInfoDto { Name = r.TagName, DisplayName = r.TagName }).ToList();
return releases.OrderByDescending(r => r.PublishedAt).Select(r => new VersionInfo { Name = r.TagName, DisplayName = r.TagName }).ToList();
}
catch (Exception ex)
{
Logger.LogError(ex.Message, ex);
return new List<VersionInfoDto>();
return new List<VersionInfo>();
}
}

@ -7,14 +7,8 @@ namespace Volo.Docs.Documents
{
public interface IDocumentStore : IDomainService
{
Task<Document> Find(
Project project,
string documentName,
string version
);
Task<Document> FindDocument(Project project, string documentName, string version);
Task<List<VersionInfoDto>> GetVersions(
Project project
);
Task<List<VersionInfo>> GetVersions(Project project);
}
}

@ -0,0 +1,12 @@
using System;
namespace Volo.Docs.Projects
{
[Serializable] //Serialization needed because this object is stored in cache
public class VersionInfo
{
public string DisplayName { get; set; }
public string Name { get; set; }
}
}
Loading…
Cancel
Save