123456789101112131415161718192021222324252627282930313233343536 |
- package com.dwl.mindoc.service;
- import com.alibaba.fastjson.JSON;
- import com.dwl.mindoc.wordutil.WordUtil;
- import org.springframework.core.io.ClassPathResource;
- import org.springframework.stereotype.Service;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.HashMap;
- import java.util.Map;
- @Service
- public class ProjectModelDocService {
- public void generDoc() throws IOException {
- ClassPathResource classPathResource = new ClassPathResource("json/mean.json");
- InputStream config = classPathResource.getInputStream();
- Map<String, Object> json = new HashMap();
- if (config == null) {
- throw new RuntimeException("读取文件失败");
- } else {
- json = JSON.parseObject(config, Map.class);
- System.out.println(json);
- }
- //文件路径
- String filePath = "D:\\project\\delivery_project\\工具\\数据库详细文档设计\\mysql-gen-doc\\doc";
- //文件名称
- String fileName = System.currentTimeMillis() + "mean.doc";
- /** 生成word */
- WordUtil.createWord(json, "softinfo.ftl", filePath, fileName);
- }
- }
|