publish 0.0.9
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>tiesheng</name>
|
<name>tiesheng</name>
|
||||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-ademo</artifactId>
|
<artifactId>tiesheng-ademo</artifactId>
|
||||||
@@ -22,6 +22,12 @@
|
|||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-web</artifactId>
|
<artifactId>tiesheng-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package com.tiesheng.demo.controller;
|
|||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.tiesheng.annotation.token.TokenIgnore;
|
import com.tiesheng.annotation.token.TokenIgnore;
|
||||||
|
import com.tiesheng.demo.pojos.TestFile;
|
||||||
import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
|
import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
|
||||||
import com.tiesheng.message.pojos.MessageReqResp;
|
import com.tiesheng.message.pojos.MessageReqResp;
|
||||||
import com.tiesheng.poi.write.PoiWriteBase;
|
import com.tiesheng.poi.util.PoiWriteUtil;
|
||||||
import com.tiesheng.util.config.GlobalConfig;
|
import com.tiesheng.util.config.GlobalConfig;
|
||||||
import com.tiesheng.util.pojos.ApiResp;
|
import com.tiesheng.util.pojos.ApiResp;
|
||||||
import com.tiesheng.util.pojos.FileUploadPath;
|
import com.tiesheng.util.pojos.FileUploadPath;
|
||||||
@@ -54,14 +55,14 @@ public class TestController {
|
|||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public ApiResp<String> export() {
|
public ApiResp<String> export() {
|
||||||
|
|
||||||
List<String> list = new ArrayList<>();
|
List<TestFile> list = new ArrayList<>();
|
||||||
list.add("11111");
|
list.add(new TestFile("11111"));
|
||||||
list.add("22222");
|
list.add(new TestFile("22222"));
|
||||||
list.add("33333");
|
list.add(new TestFile("33333"));
|
||||||
|
list.add(new TestFile("44444"));
|
||||||
|
|
||||||
FileUploadPath fileUploadPath = FileUploadPath.random();
|
FileUploadPath fileUploadPath = FileUploadPath.random("xlsx");
|
||||||
|
PoiWriteUtil.export(list, TestFile.class, fileUploadPath.getAbsolutePath(), "hahah");
|
||||||
PoiWriteBase.export(list, fileUploadPath.getAbsolutePath(), "hahah");
|
|
||||||
|
|
||||||
return ApiResp.respOK("");
|
return ApiResp.respOK("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.tiesheng.demo.pojos;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||||
|
import com.tiesheng.poi.util.PoiWriteUtil;
|
||||||
|
|
||||||
|
public class TestFile extends PoiWriteBase {
|
||||||
|
|
||||||
|
|
||||||
|
@ExcelProperty("测试")
|
||||||
|
private String test;
|
||||||
|
|
||||||
|
public TestFile(String test) {
|
||||||
|
this.test = test;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// setter、getter
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public String getTest() {
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTest(String test) {
|
||||||
|
this.test = test;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-annotation</artifactId>
|
<artifactId>tiesheng-annotation</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-db-migration</artifactId>
|
<artifactId>tiesheng-db-migration</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-encrypt</artifactId>
|
<artifactId>tiesheng-encrypt</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-login</artifactId>
|
<artifactId>tiesheng-login</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-message</artifactId>
|
<artifactId>tiesheng-message</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-platform</artifactId>
|
<artifactId>tiesheng-platform</artifactId>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-poi</artifactId>
|
<artifactId>tiesheng-poi</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.tiesheng.poi.pojos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
public class PoiReadBase {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.tiesheng.poi.pojos;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.write.style.*;
|
||||||
|
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
||||||
|
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hao
|
||||||
|
*/
|
||||||
|
@HeadRowHeight(24)
|
||||||
|
@HeadFontStyle(fontHeightInPoints = 13)
|
||||||
|
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.LEFT)
|
||||||
|
@ContentRowHeight(20)
|
||||||
|
@ContentFontStyle(fontHeightInPoints = 12)
|
||||||
|
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
|
||||||
|
@ColumnWidth(20)
|
||||||
|
public class PoiWriteBase {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.tiesheng.poi.read;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.alibaba.excel.read.listener.ReadListener;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class PoiReadBase {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取文件
|
|
||||||
*
|
|
||||||
* @param file
|
|
||||||
* @param readListener
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static <T> String read(File file, ReadListener<T> readListener) {
|
|
||||||
Class<?> aClass = ClassUtil.getTypeArgument(readListener.getClass(), 0);
|
|
||||||
EasyExcel.read(file, aClass, readListener).autoTrim(true).headRowNumber(1).sheet().doRead();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.tiesheng.poi.util;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.read.listener.ReadListener;
|
||||||
|
import com.tiesheng.poi.pojos.PoiReadBase;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class PoiReadUtil {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取文件
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @param readListener
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static <T extends PoiReadBase> void read(File file, Class<T> tClass, ReadListener<T> readListener) {
|
||||||
|
EasyExcel.read(file, tClass, readListener).autoTrim(true).headRowNumber(1).sheet().doRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.tiesheng.poi.write;
|
package com.tiesheng.poi.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import com.alibaba.excel.annotation.write.style.*;
|
import com.alibaba.excel.annotation.write.style.*;
|
||||||
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
|
||||||
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
|
||||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||||
|
import com.tiesheng.poi.pojos.PoiWriteBase;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
@ContentFontStyle(fontHeightInPoints = 12)
|
@ContentFontStyle(fontHeightInPoints = 12)
|
||||||
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
|
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
|
||||||
@ColumnWidth(20)
|
@ColumnWidth(20)
|
||||||
public class PoiWriteBase {
|
public class PoiWriteUtil {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,9 +28,8 @@ public class PoiWriteBase {
|
|||||||
* @param list
|
* @param list
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static <T> boolean export(List<T> list, String absPath, String sheetName) {
|
public static <T extends PoiWriteBase> boolean export(List<T> list, Class<T> tClass, String absPath, String sheetName) {
|
||||||
Class<?> aClass = ClassUtil.getTypeArgument(list.getClass(), 0);
|
EasyExcel.write(absPath, tClass).excelType(ExcelTypeEnum.XLSX)
|
||||||
EasyExcel.write(absPath, aClass).excelType(ExcelTypeEnum.XLSX)
|
|
||||||
.sheet(sheetName)
|
.sheet(sheetName)
|
||||||
.doWrite(list);
|
.doWrite(list);
|
||||||
return true;
|
return true;
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-util</artifactId>
|
<artifactId>tiesheng-util</artifactId>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public class FileUploadPath {
|
|||||||
}
|
}
|
||||||
pathBean.setHttpPath(tempPath);
|
pathBean.setHttpPath(tempPath);
|
||||||
pathBean.setAbsolutePath(String.format("%s/static%s", System.getProperty("user.dir"), tempPath));
|
pathBean.setAbsolutePath(String.format("%s/static%s", System.getProperty("user.dir"), tempPath));
|
||||||
|
FileUtil.mkParentDirs(pathBean.getAbsolutePath());
|
||||||
|
|
||||||
return pathBean;
|
return pathBean;
|
||||||
}
|
}
|
||||||
@@ -52,6 +53,16 @@ public class FileUploadPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 随机生成一个文件路径
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static FileUploadPath random(String fileExt) {
|
||||||
|
return get(IdUtil.simpleUUID() + "." + fileExt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取一个目录
|
* 获取一个目录
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.tiesheng</groupId>
|
<groupId>com.tiesheng</groupId>
|
||||||
<artifactId>tiesheng-parent</artifactId>
|
<artifactId>tiesheng-parent</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tiesheng-web</artifactId>
|
<artifactId>tiesheng-web</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user