From 394fc059ba0aa2275d5656c7bdfd4b3f43243b21 Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Tue, 13 Oct 2026 08:52:33 +1000 Subject: [PATCH] =?UTF-8?q?feat(api):=20HelpDocuments=20-=20=D1=81=D1=81?= =?UTF-8?q?=D1=8B=D0=BB=D0=BA=D0=B0=20=D0=BD=D0=B0=20=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V1/Responses/HelpDocumentResponse.cs | 2 ++ PARR.API/appsettings.json | 3 ++- .../Implementations/GitLabHelpProvider.cs | 18 +++++++++++++++++- .../DTOs/HelpDocument/HelpDocumentResult.cs | 2 ++ PARR.Domain/Settings/HelpDocumentSettings.cs | 5 +++++ 5 files changed, 28 insertions(+), 2 deletions(-) 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; } }