ProjectModelDocService.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package com.dwl.mindoc.service;
  2. import com.alibaba.fastjson.JSON;
  3. import com.dwl.mindoc.wordutil.WordUtil;
  4. import org.springframework.core.io.ClassPathResource;
  5. import org.springframework.stereotype.Service;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8. import java.util.HashMap;
  9. import java.util.Map;
  10. @Service
  11. public class ProjectModelDocService {
  12. public void generDoc() throws IOException {
  13. ClassPathResource classPathResource = new ClassPathResource("json/mean.json");
  14. InputStream config = classPathResource.getInputStream();
  15. Map<String, Object> json = new HashMap();
  16. if (config == null) {
  17. throw new RuntimeException("读取文件失败");
  18. } else {
  19. json = JSON.parseObject(config, Map.class);
  20. System.out.println(json);
  21. }
  22. //文件路径
  23. String filePath = "D:\\project\\delivery_project\\工具\\数据库详细文档设计\\mysql-gen-doc\\doc";
  24. //文件名称
  25. String fileName = System.currentTimeMillis() + "mean.doc";
  26. /** 生成word */
  27. WordUtil.createWord(json, "softinfo.ftl", filePath, fileName);
  28. }
  29. }