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 石头人
* @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 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 testTemplate(@RequestParam String jsonData,
@RequestParam Integer width,
@RequestParam Integer height, @RequestParam(defaultValue = "E:\\images") String saveDir) {
String html = "\n" +
"\n" +
"Test\n" +
"\n" +
"你好,我是一个好的模板
\n" +
"
\n" +
"\n" +
"";
this.templateService.generateReceiptImage(JSONObject.parseObject(jsonData), html, width, height, saveDir);
return Result.ok("模板生成成功");
}
}