package com.ltkj.web.config.wordUtil; import com.ltkj.hosp.domain.Tables; import com.ltkj.web.config.wordUtil.mapper.TableMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.File; import java.text.ParseException; import java.util.Date; import java.util.List; /** *

实现类

* * @author : 赵佳豪 */ @Slf4j @Service public class TableService implements ITableService { @Resource private TableMapper tableMapper; @Resource private TableToWordUtil tableToWordUtil; @Override public String getTableInfo() { // 1、获取数据库所有表信息 List tables = tableMapper.getAllTables(Constants.DATABASE); // 2、生成文件名信息 - 年月日时分秒 String date = null; try { date = DateTimeUtils.dateFormat(new Date(), DateTimeUtils.PARSE_PATTERNS[12]); } catch (ParseException e) { e.printStackTrace(); } String docFileName = Constants.FILE_PATH + File.separator + Constants.FILE_NAME + ".doc"; // 3、调用工具类生成文件 tableToWordUtil.toWord(tables, docFileName, Constants.FILE_NAME); // 4、返回文件地址 String filePath = docFileName.replaceAll("\\\\", "/"); return filePath; } }