介绍:小工具分享
框架:javaweb
AI账号:阿里云百炼
模型:qwen-plus
步骤一:配置api-key
步骤二:核心接口
文件上传
@PostMapping("/upload")
public Map<String, Object> uploadFiles(@RequestParam("files") MultipartFile[] files) throws Exception {
Map<String, Object> result = new HashMap<>();
List<Map<String, String>> uploadedFiles = new ArrayList<>();
for (MultipartFile file : files) {
if (!file.isEmpty()) {
String filename = file.getOriginalFilename();
Map<String, String> fileInfo = new HashMap<>();
fileInfo.put("name", filename);
fileInfo.put("type", file.getContentType());
assert filename != null;
if (filename.endsWith(".docx")) {
// docx转md
String markdownContent = convertDocxToMarkdown(file);
fileInfo.put("content", markdownContent);
} else {
// 非docx文件处理
fileInfo.put("content", new String(file.getBytes(), StandardCharsets.UTF_8));
}
fileInfo.put("size", String.valueOf(file.getSize()));
uploadedFiles.add(fileInfo);
}
}
// 将文件列表存入内存
String uuid = UUID.randomUUID().toString();
fileStorage.put(uuid, uploadedFiles);
result.put("message", "文件上传成功");
result.put("id", uuid);
return result;
}
下载文件
@PostMapping("/downloadXls")
public void downloadXls(@RequestParam("csvFile") MultipartFile csvFile, HttpServletResponse response) throws IOException {
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=代码审查报告.xls");
ExcelTemplateUpdater.handleCsvToXls(csvFile, response);
}
步骤三:启动
浏览器访问:http://localhost:port
步骤四:生成审查报告
生成内容展示
审查报告文件
步骤五:生成版本说明
生成内容展示
版本说明文件
步骤六:生成测试报告
生成内容展示
测试报告文件
至此,代码审查小工具分享到此结束!
资料已上传至技术群
本人正在打造技术交流群,欢迎志同道合的朋友一起探讨,一起努力,通过自己的努力,在技术岗位这条道路上走得更远。QQ群号:925317809 备注:技术交流 即可通过!
加入技术群可以获取资料,含AI资料、Spring AI中文文档等,等你加入~