44 lines
1.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 文件预览工程拆解分析
## 功能描述
- 维护生成Word文件的模板。
- 生成PDF文件。
## 代码运行截图
![输入图片说明](/imgs/2024-02-27/zpHvCHwJ5GU4esVw.png)
## 接口设计
| HTTP 请求路径 | 类名 | 方法名 | 接口说明 |
| ------------------------------------------- | ------------------ | ---------------- | --------------------------- |
| POST /contract/upload | ContractController | contractUpload | 上传模板文件,文件名即为模板名。上传后放入指定文件夹。 |
| POST /contract/list/template | ContractController | listTemplate | 列出已有模板。 |
| POST /contract/gen/{templateName} | ContractController | contractGen | 生成Word文件返回其预览地址。 |
| POST /contract/excel/{templateName} | ContractController | excel | 生成Excel文件返回预览地址。 |
| POST /contract/download/{templateName} | ContractController | downloadcontract | 生成PDF文件并下载。 |
| POST /contract/downloadWord/{templateName} | ContractController | downloadWord | 生成Word文件并下载。 |
| POST /contract/downloadExcel/{templateName} | ContractController | downloadExcel | 生成Excel文件并下载。 |
## 核心业务逻辑
### 生成Word/Excel
将参数以 Map 的形式传入,[Poi-tl](https://deepoove.com/poi-tl/) 按规则将参数渲染到模板。
### 生成PDF
调用 kkfile底层是 LibreOffice将 Word/Excel 转换为 PDF。
<!--stackedit_data:
eyJoaXN0b3J5IjpbLTY5MTI3NjUyNCwxNjIxMzQzODM3XX0=
-->