diff --git a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/CreateProjectDto.cs b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/CreateProjectDto.cs new file mode 100644 index 0000000000..cb02c579a3 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/CreateProjectDto.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace Volo.Docs.Projects +{ + public class CreateProjectDto + { + public string Name { get; set; } + + public string ShortName { get; set; } + + public string Format { get; set; } + + public string DefaultDocumentName { get; set; } + + public string NavigationDocumentName { get; set; } + + public string MinimumVersion { get; set; } + + public string MainWebsiteUrl { get; set; } + + public string LatestVersionBranchName { get; set; } + + public string DocumentStoreType { get; set; } + + public Dictionary ExtraProperties { get; set; } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs index 5bfc221e4d..8dba5fa3e1 100644 --- a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs +++ b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/IProjectAppService.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; @@ -9,6 +10,12 @@ namespace Volo.Docs.Projects Task> GetListAsync(); Task GetAsync(string shortName); + + Task CreateAsync(CreateProjectDto input); + + Task UpdateAsync(Guid id, UpdateProjectDto input); + + Task DeleteAsync(Guid id); Task> GetVersionsAsync(string shortName); } diff --git a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/ProjectDto.cs b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/ProjectDto.cs index a29ea840b3..91f5c63a22 100644 --- a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/ProjectDto.cs +++ b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/ProjectDto.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Volo.Abp.Application.Dtos; namespace Volo.Docs.Projects @@ -10,12 +11,20 @@ namespace Volo.Docs.Projects public string ShortName { get; set; } + public string Format { get; set; } + public string DefaultDocumentName { get; set; } + public string NavigationDocumentName { get; set; } + + public string MinimumVersion { get; set; } + public string MainWebsiteUrl { get; set; } - public virtual string DocumentStoreType { get; protected set; } + public string LatestVersionBranchName { get; set; } + + public string DocumentStoreType { get; set; } - public virtual string Format { get; protected set; } + public Dictionary ExtraProperties { get; set; } } } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/UpdateProjectDto.cs b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/UpdateProjectDto.cs new file mode 100644 index 0000000000..b16f1916e4 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Projects/UpdateProjectDto.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Application.Dtos; + +namespace Volo.Docs.Projects +{ + public class UpdateProjectDto + { + public string Name { get; set; } + + public string Format { get; set; } + + public string DefaultDocumentName { get; set; } + + public string NavigationDocumentName { get; set; } + + public string MinimumVersion { get; set; } + + public string MainWebsiteUrl { get; set; } + + public string LatestVersionBranchName { get; set; } + + public Dictionary ExtraProperties { get; set; } + } +} \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs index 7afefee4f1..6a7e8132fc 100644 --- a/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs +++ b/modules/docs/src/Volo.Docs.Application/Volo/Docs/Projects/ProjectAppService.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Caching.Distributed; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Caching; +using Volo.Abp.Guids; using Volo.Docs.Documents; namespace Volo.Docs.Projects @@ -15,15 +16,17 @@ namespace Volo.Docs.Projects private readonly IProjectRepository _projectRepository; private readonly IDistributedCache> _versionCache; private readonly IDocumentStoreFactory _documentStoreFactory; + private readonly IGuidGenerator _guidGenerator; public ProjectAppService( IProjectRepository projectRepository, IDistributedCache> versionCache, - IDocumentStoreFactory documentStoreFactory) + IDocumentStoreFactory documentStoreFactory, IGuidGenerator guidGenerator) { _projectRepository = projectRepository; _versionCache = versionCache; _documentStoreFactory = documentStoreFactory; + _guidGenerator = guidGenerator; } public async Task> GetListAsync() @@ -42,6 +45,60 @@ namespace Volo.Docs.Projects return ObjectMapper.Map(project); } + public async Task CreateAsync(CreateProjectDto input) + { + var project = new Project(_guidGenerator.Create(), + input.Name, + input.ShortName, + input.DocumentStoreType, + input.Format, + input.DefaultDocumentName, + input.NavigationDocumentName + ) + { + MinimumVersion = input.MinimumVersion, + MainWebsiteUrl = input.MainWebsiteUrl, + LatestVersionBranchName = input.LatestVersionBranchName + }; + + foreach (var extraProperty in input.ExtraProperties) + { + project.ExtraProperties.Add(extraProperty.Key,extraProperty.Value); + } + + project = await _projectRepository.InsertAsync(project); + + return ObjectMapper.Map(project); + } + + public async Task UpdateAsync(Guid id, UpdateProjectDto input) + { + var project = await _projectRepository.GetAsync(id); + + project.SetName(input.Name); + project.SetFormat(input.Format); + project.SetNavigationDocumentName(input.NavigationDocumentName); + project.SetDefaultDocumentName(input.DefaultDocumentName); + + project.MinimumVersion = input.MinimumVersion; + project.MainWebsiteUrl = input.MainWebsiteUrl; + project.LatestVersionBranchName = input.LatestVersionBranchName; + + foreach (var extraProperty in input.ExtraProperties) + { + project.ExtraProperties[extraProperty.Key] = extraProperty.Value; + } + + project = await _projectRepository.UpdateAsync(project); + + return ObjectMapper.Map(project); + } + + public async Task DeleteAsync(Guid id) + { + await _projectRepository.DeleteAsync(id); + } + public async Task> GetVersionsAsync(string shortName) { var project = await _projectRepository.GetByShortNameAsync(shortName); diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs index 7472ace4e3..2a98ea6cff 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Project.cs @@ -54,6 +54,8 @@ namespace Volo.Docs.Projects Guid id, [NotNull] string name, [NotNull] string shortName, + [NotNull] string documentStoreType, + [NotNull] string format, [NotNull] string defaultDocumentName, [NotNull] string navigationDocumentName) { @@ -61,10 +63,32 @@ namespace Volo.Docs.Projects Name = Check.NotNullOrWhiteSpace(name, nameof(name)); ShortName = Check.NotNullOrWhiteSpace(shortName, nameof(shortName)); + DocumentStoreType = Check.NotNullOrWhiteSpace(documentStoreType, nameof(documentStoreType)); + Format = Check.NotNullOrWhiteSpace(format, nameof(format)); DefaultDocumentName = Check.NotNullOrWhiteSpace(defaultDocumentName, nameof(defaultDocumentName)); NavigationDocumentName = Check.NotNullOrWhiteSpace(navigationDocumentName, nameof(navigationDocumentName)); ExtraProperties = new Dictionary(); } + + public void SetName(string name) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); + } + + public void SetFormat(string format) + { + Format = Check.NotNullOrWhiteSpace(format, nameof(format)); + } + + public void SetNavigationDocumentName(string navigationDocumentName) + { + NavigationDocumentName = Check.NotNullOrWhiteSpace(navigationDocumentName, nameof(navigationDocumentName)); + } + + public void SetDefaultDocumentName(string defaultDocumentName) + { + DefaultDocumentName = Check.NotNullOrWhiteSpace(defaultDocumentName, nameof(defaultDocumentName)); + } } } \ No newline at end of file