feat(api): HelpDocuments - ссылка на редактирование документации

This commit is contained in:
Mikhail Trubnikov
2026-10-13 08:52:33 +10:00
parent 1b02bf63bf
commit 394fc059ba
5 changed files with 28 additions and 2 deletions

View File

@@ -27,5 +27,7 @@
/// ИД для перехода вперед
/// </summary>
public string? NextId { get; init; }
public string? EditUrl { get; init; }
}
}

View File

@@ -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",

View File

@@ -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);

View File

@@ -22,5 +22,7 @@
/// // Чистый Markdown-текст (все, что идет после метаданных)
/// </summary>
public string Content { get; init; } = string.Empty;
public string? EditUrl { get; init; }
}
}

View File

@@ -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;
/// <summary>
/// Путь к репозиторию, для формирования ссылки для редактирования документа
/// </summary>
public string RepositoryPath { get; init; } = string.Empty;
}
}