feat:generateReceiptImage接口增加图片自定义保存路径

This commit is contained in:
2025-01-20 14:31:21 +08:00
parent a8f13d72b9
commit 2986fa0c14
2 changed files with 29 additions and 19 deletions

View File

@@ -23,13 +23,19 @@ public class TemplateController {
@GetMapping("/template/{templateName}")
public Result<String> testTemplate(@RequestParam Integer width, @RequestParam Integer height, String jsonData, @PathVariable String templateName) {
this.templateService.generateReceiptImage(JSONObject.parseObject(jsonData), templateName, width, height);
public Result<String> testTemplate(@RequestParam String jsonData,
@RequestParam Integer width,
@RequestParam Integer height,
@PathVariable String templateName,
@RequestParam(defaultValue = "E:\\images") String saveDir) {
this.templateService.generateReceiptImage(JSONObject.parseObject(jsonData), templateName, width, height, saveDir);
return Result.ok("模板生成成功");
}
@GetMapping("/template")
public Result<String> testTemplate(String jsonData, @RequestParam Integer width, @RequestParam Integer height) {
public Result<String> testTemplate(@RequestParam String jsonData,
@RequestParam Integer width,
@RequestParam Integer height, @RequestParam(defaultValue = "E:\\images") String saveDir) {
String html = "<!DOCTYPE html>\n" +
"<html>\n" +
"<head><title>Test</title></head>\n" +
@@ -38,7 +44,7 @@ public class TemplateController {
"<h2><span th:text='${name}'> </span></h2>\n" +
"</body>\n" +
"</html>";
this.templateService.generateReceiptImage(JSONObject.parseObject(jsonData), html, width, height);
this.templateService.generateReceiptImage(JSONObject.parseObject(jsonData), html, width, height, saveDir);
return Result.ok("模板生成成功");
}