publish 0.0.9

This commit is contained in:
曾文豪
2023-01-10 11:40:43 +08:00
parent abd5c2456b
commit 9e0d2ac571
19 changed files with 120 additions and 50 deletions

View File

@@ -6,7 +6,7 @@
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
<packaging>pom</packaging>
<name>tiesheng</name>
<description>杭州铁晟科技有限公司基础依赖</description>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-ademo</artifactId>
@@ -22,6 +22,12 @@
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
</dependencies>
<repositories>

View File

@@ -2,9 +2,10 @@ package com.tiesheng.demo.controller;
import cn.hutool.json.JSONUtil;
import com.tiesheng.annotation.token.TokenIgnore;
import com.tiesheng.demo.pojos.TestFile;
import com.tiesheng.message.config.aliyun.AliyunSmsConfig;
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.pojos.ApiResp;
import com.tiesheng.util.pojos.FileUploadPath;
@@ -54,14 +55,14 @@ public class TestController {
@TokenIgnore
public ApiResp<String> export() {
List<String> list = new ArrayList<>();
list.add("11111");
list.add("22222");
list.add("33333");
List<TestFile> list = new ArrayList<>();
list.add(new TestFile("11111"));
list.add(new TestFile("22222"));
list.add(new TestFile("33333"));
list.add(new TestFile("44444"));
FileUploadPath fileUploadPath = FileUploadPath.random();
PoiWriteBase.export(list, fileUploadPath.getAbsolutePath(), "hahah");
FileUploadPath fileUploadPath = FileUploadPath.random("xlsx");
PoiWriteUtil.export(list, TestFile.class, fileUploadPath.getAbsolutePath(), "hahah");
return ApiResp.respOK("");
}

View File

@@ -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;
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-annotation</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-db-migration</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-encrypt</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-login</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-message</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-platform</artifactId>

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-poi</artifactId>

View File

@@ -0,0 +1,8 @@
package com.tiesheng.poi.pojos;
/**
* @author hao
*/
public class PoiReadBase {
}

View File

@@ -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 {
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}

View File

@@ -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.annotation.write.style.*;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.tiesheng.poi.pojos.PoiWriteBase;
import java.util.List;
@@ -19,7 +19,7 @@ import java.util.List;
@ContentFontStyle(fontHeightInPoints = 12)
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
@ColumnWidth(20)
public class PoiWriteBase {
public class PoiWriteUtil {
/**
@@ -28,9 +28,8 @@ public class PoiWriteBase {
* @param list
* @return
*/
public static <T> boolean export(List<T> list, String absPath, String sheetName) {
Class<?> aClass = ClassUtil.getTypeArgument(list.getClass(), 0);
EasyExcel.write(absPath, aClass).excelType(ExcelTypeEnum.XLSX)
public static <T extends PoiWriteBase> boolean export(List<T> list, Class<T> tClass, String absPath, String sheetName) {
EasyExcel.write(absPath, tClass).excelType(ExcelTypeEnum.XLSX)
.sheet(sheetName)
.doWrite(list);
return true;

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-util</artifactId>

View File

@@ -37,6 +37,7 @@ public class FileUploadPath {
}
pathBean.setHttpPath(tempPath);
pathBean.setAbsolutePath(String.format("%s/static%s", System.getProperty("user.dir"), tempPath));
FileUtil.mkParentDirs(pathBean.getAbsolutePath());
return pathBean;
}
@@ -52,6 +53,16 @@ public class FileUploadPath {
}
/**
* 随机生成一个文件路径
*
* @return
*/
public static FileUploadPath random(String fileExt) {
return get(IdUtil.simpleUUID() + "." + fileExt);
}
/**
* 获取一个目录
*

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>com.tiesheng</groupId>
<artifactId>tiesheng-parent</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</parent>
<artifactId>tiesheng-web</artifactId>