模板生成 简化代码
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -98,6 +98,12 @@
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<!-- Hutool 工具包 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.18</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.example.ts_obj.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.deepoove.poi.XWPFTemplate;
|
||||
import com.example.ts_obj.bean.ReturnCodeAndMsgEnum;
|
||||
import com.example.ts_obj.bean.ReturnValue;
|
||||
@@ -44,11 +45,7 @@ public class DataapiController {
|
||||
try {
|
||||
Date date = new Date();
|
||||
String dirpath = BASE_DIR + new SimpleDateFormat("yyyyMMdd").format(date);
|
||||
//如果不存在,创建文件夹
|
||||
File f = new File(dirpath);
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
FileUtil.mkdir(new File(dirpath));
|
||||
String goFileName = System.currentTimeMillis() + ".docx";
|
||||
template.writeAndClose(new FileOutputStream(dirpath + "/" + goFileName));
|
||||
logger.info("创建成功 fileName = {}", goFileName);
|
||||
|
||||
Reference in New Issue
Block a user