Commit e3e3d842 authored by wdy's avatar wdy

定时任务

parent 0da67341
......@@ -9,6 +9,11 @@ import com.ruoyi.domain.vo.CaseResultVO;
import com.ruoyi.domain.vo.StepResultVO;
import com.ruoyi.mapper.TestRecordsMapper;
import com.ruoyi.service.TestRecordsService;
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Entities;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -88,6 +93,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
List<String> stepList = new ArrayList<>();
List<String> testDetailsList = new ArrayList<>();
int index = 1; // 序号从1开始
String testDetailsVO = "";
for (StepResultVO stepResultVO :stepResultVOS) {
// 测试方法
String stepName = stepResultVO.getName();
......@@ -100,10 +106,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// 测试详情
String testDetails = stepResultVO.getDescription();
testDetailsList.add(testDetails);
if (testDetails != null) {
convertMarkdownToHtml(testDetails);
}
testDetailsVO += testDetails + "`";
}
testDetailsVO = testDetailsVO.substring(0, testDetailsVO.length() - 1);
testRecords.setTestMethod(StringUtils.join(stepList,"`"));
testRecords.setTestDetails(StringUtils.join(testDetailsList,"\n"));
testRecords.setTestDetails(testDetailsVO);
}
list.add(testRecords);
......@@ -161,6 +171,7 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
List<String> stepList = new ArrayList<>();
List<String> testDetailsList = new ArrayList<>();
int index = 1; // 序号从1开始
String testDetailsVO = "";
for (StepResultVO stepResultVO :stepResultVOS) {
// 测试方法
String stepName = stepResultVO.getName();
......@@ -173,10 +184,14 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
// 测试详情
String testDetails = stepResultVO.getDescription();
testDetailsList.add(testDetails);
if (testDetails != null) {
convertMarkdownToHtml(testDetails);
}
testDetailsVO += testDetails + "`";
}
testDetailsVO = testDetailsVO.substring(0, testDetailsVO.length() - 1);
testRecords.setTestMethod(StringUtils.join(stepList,"`"));
testRecords.setTestDetails(StringUtils.join(testDetailsList,"\n"));
testRecords.setTestDetails(testDetailsVO);
}
list.add(testRecords);
......@@ -189,6 +204,25 @@ public class TestRecordsServiceImpl extends ServiceImpl<TestRecordsMapper, TestR
}
}
public static String convertMarkdownToHtml(String markdownContent) {
// 创建 Markdown 解析器
Parser parser = Parser.builder().build();
// 解析 Markdown
Node document = parser.parse(markdownContent);
// 创建 HTML 渲染器
HtmlRenderer renderer = HtmlRenderer.builder().build();
// 渲染 HTML
org.jsoup.nodes.Document doc = Jsoup.parse(renderer.render(document).replaceAll("\\\\n", "<br>"));
// jsoup标准化标签,生成闭合标签
doc.outputSettings().syntax(org.jsoup.nodes.Document.OutputSettings.Syntax.xml);
doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
return doc.html();
}
@Override
public List<TestRecords> findByTaskId(String id) {
return testRecordsMapper.findByTaskId(id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment