feat:增加模板相关接口

This commit is contained in:
2025-01-19 16:00:40 +08:00
parent 1474746864
commit 9073fd9180
9 changed files with 11473 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package com.dpkj.modules.autoReplyPrint.controller;
import com.alibaba.fastjson.JSONObject;
import com.dpkj.common.vo.Result;
import com.dpkj.modules.autoReplyPrint.service.impl.TemplateService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* 打印模板控制层
*
* @author <a href="https://gitee.com/shi-chongli">石头人</a>
* @version 1.0
* @since 2025-01-17 15:25:03
*/
@RestController
@RequestMapping("/autoReplyPrint")
public class TemplateController {
@Resource
private TemplateService templateService;
@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);
return Result.ok("模板生成成功");
}
@GetMapping("/template")
public Result<String> testTemplate(String jsonData, @RequestParam Integer width, @RequestParam Integer height) {
String html = "<!DOCTYPE html>\n" +
"<html>\n" +
"<head><title>Test</title></head>\n" +
"<body>\n" +
"<h1>你好,我是一个好的模板</h1>\n" +
"<h2><span th:text='${name}'> </span></h2>\n" +
"</body>\n" +
"</html>";
this.templateService.generateReceiptImage(JSONObject.parseObject(jsonData), html, width, height);
return Result.ok("模板生成成功");
}
}