diff --git a/PARR.API/Contracts/V1/Responses/HelpDocumentResponse.cs b/PARR.API/Contracts/V1/Responses/HelpDocumentResponse.cs index 341e87ea..ea812467 100644 --- a/PARR.API/Contracts/V1/Responses/HelpDocumentResponse.cs +++ b/PARR.API/Contracts/V1/Responses/HelpDocumentResponse.cs @@ -27,5 +27,7 @@ /// ИД для перехода вперед /// public string? NextId { get; init; } + + public string? EditUrl { get; init; } } } diff --git a/PARR.API/appsettings.json b/PARR.API/appsettings.json index 6062378b..5dad9a14 100644 --- a/PARR.API/appsettings.json +++ b/PARR.API/appsettings.json @@ -124,7 +124,8 @@ "BaseUrl": "http://gitlab.dvgd.oao.rzd/api/v4/", "ProjectId": "1343", "Token": "glpat-2PBp1c9hryQHUJnoZn3S", - "DefaultBranch": "main" + "DefaultBranch": "main", + "RepositoryPath": "http://gitlab.dvgd.oao.rzd/devptk/parr/parr_help_docs" }, "CacheTTL": "23:59:00", "ShortTTL": "00:10:00", diff --git a/PARR.Core/Services/HelpDocument/Implementations/GitLabHelpProvider.cs b/PARR.Core/Services/HelpDocument/Implementations/GitLabHelpProvider.cs index 6382bb24..704f330f 100644 --- a/PARR.Core/Services/HelpDocument/Implementations/GitLabHelpProvider.cs +++ b/PARR.Core/Services/HelpDocument/Implementations/GitLabHelpProvider.cs @@ -76,7 +76,12 @@ namespace PARR.Core.Services.HelpDocument.Implementations _logger.LogDebug("Документ справки успешно загружен и распарсен. HelpId: {HelpId}, Title: '{Title}'", helpId, result.Title); - return result; + var editUrl = GenerateEditUrl(helpId); + + return result with + { + EditUrl = editUrl + }; } catch (Exception ex) @@ -86,6 +91,17 @@ namespace PARR.Core.Services.HelpDocument.Implementations } } + private string? GenerateEditUrl(string helpId) + { + if (_helpDocumentSettings.GitLabSettings == null) + return null; + + var repoPath = _helpDocumentSettings.GitLabSettings.RepositoryPath; + var branch = _helpDocumentSettings.GitLabSettings.DefaultBranch ?? "main"; + + return $"{repoPath}/-/edit/{branch}/{helpId}.md"; + } + private HelpDocumentResult ParseMarkdownFile(string helpId, string rawContent) { _logger.LogDebug("Начало парсинга структуры Markdown для HelpId: {HelpId}", helpId); diff --git a/PARR.Domain/DTOs/HelpDocument/HelpDocumentResult.cs b/PARR.Domain/DTOs/HelpDocument/HelpDocumentResult.cs index efc5d030..85af133b 100644 --- a/PARR.Domain/DTOs/HelpDocument/HelpDocumentResult.cs +++ b/PARR.Domain/DTOs/HelpDocument/HelpDocumentResult.cs @@ -22,5 +22,7 @@ /// // Чистый Markdown-текст (все, что идет после метаданных) /// public string Content { get; init; } = string.Empty; + + public string? EditUrl { get; init; } } } diff --git a/PARR.Domain/Settings/HelpDocumentSettings.cs b/PARR.Domain/Settings/HelpDocumentSettings.cs index 76b093a2..31aff669 100644 --- a/PARR.Domain/Settings/HelpDocumentSettings.cs +++ b/PARR.Domain/Settings/HelpDocumentSettings.cs @@ -29,5 +29,10 @@ public string ProjectId { get; init; } = string.Empty; public string Token { get; init; } = string.Empty; public string DefaultBranch { get; init; } = string.Empty; + + /// + /// Путь к репозиторию, для формирования ссылки для редактирования документа + /// + public string RepositoryPath { get; init; } = string.Empty; } }