fix(wiki):pages接口地址修正

This commit is contained in:
wanjia 2024-09-26 11:22:43 +08:00
parent dd9e2f7ae9
commit 553a9cd477
2 changed files with 9 additions and 8 deletions

View File

@ -63,7 +63,7 @@ public class WikiController {
String giteaToken = wikiService.getGiteaToken(request, projectId);
//未获取有效giteaToken时赋值内置giteaToken
giteaToken = giteaToken == null ? token : giteaToken;
HttpClientResult httpClientResult = wikiService.getWikiPages(owner, repo, giteaApiDomain, giteaToken);
HttpClientResult httpClientResult = wikiService.getWikiPages(owner, repo, giteaToken);
if (httpClientResult == null) {
throw new ServiceException("获取wiki数据异常");
}

View File

@ -37,8 +37,6 @@ import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
@Component
public class WikiService {
@ -58,6 +56,9 @@ public class WikiService {
@Value("${trustie_or_military_host}")
private String trustieOrMilitaryHost;
@Value("${gitea-wiki-api-domain}")
private String giteaApiDomain;
@Autowired
private UserService userService;
@ -74,13 +75,13 @@ public class WikiService {
return user.getGiteaToken();
}
public HttpClientResult getWikiPages(String owner, String repo, String URL, String giteaToken) throws Exception {
public HttpClientResult getWikiPages(String owner, String repo, String giteaToken) throws Exception {
String urlFormat = String.format("/api/hat/repos/%s/%s/wiki/page_names", owner, repo);
if (giteaToken != null) {
urlFormat += "?access_token=" + giteaToken;
}
String completeUrl = URL + urlFormat;
String completeUrl = giteaApiDomain + urlFormat;
logger.info("completeUrl:" + completeUrl);
HttpClientResult httpClientResult = HttpClientUtils.doGet(completeUrl, null);
logger.info("httpClientResultCode:" + httpClientResult.getCode());
@ -158,7 +159,7 @@ public class WikiService {
WrapperConfig wrapperConfig = new WrapperConfig(toPdfToolPath);
Pdf pdf = new Pdf(wrapperConfig);
// String wkhtmltopdfCommand = "D:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe";
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, URL, giteaToken);
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, giteaToken);
String content = httpClientResult.getContent();
List<WikiPage> wikiPages = FastJsonUtils.toList(content, WikiPage.class);
for (WikiPage wikiPage : wikiPages) {
@ -211,7 +212,7 @@ public class WikiService {
public void exportWikiToMd(HttpServletResponse response, String owner, String repoName, String URL,
String destPath, String giteaToken) throws Exception {
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, URL, giteaToken);
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, giteaToken);
String content = httpClientResult.getContent();
List<WikiPage> wikiPages = FastJsonUtils.toList(content, WikiPage.class);
String dirPath = destPath + File.separator + repoName;
@ -232,7 +233,7 @@ public class WikiService {
public void exportWikiToHtml(HttpServletResponse response, String owner, String repoName, String URL,
String destPath, String projectName, String giteaToken) throws Exception {
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, URL, giteaToken);
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, giteaToken);
String content = httpClientResult.getContent();
List<WikiPage> wikiPages = FastJsonUtils.toList(content, WikiPage.class);
String dirPath = destPath + File.separator + repoName;