feat(file/poi): 新增 continew-starter-file-poi 模块(添加 ExcelImport 与 ExcelExport 注解)

1.将EasyExcel升级为FastExcel
2.新增 continew-starter-file-poi 模块(添加 ExcelImport 与 ExcelExport 注解,https://zyqok.blog.csdn.net/article/details/121994504)
This commit is contained in:
jiang4yu
2025-06-10 03:48:26 +00:00
committed by Charles7c
parent ad298930db
commit c843434720
12 changed files with 1235 additions and 27 deletions

View File

@@ -0,0 +1,39 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>top.continew</groupId>
<artifactId>continew-starter-file</artifactId>
<version>${revision}</version>
</parent>
<artifactId>continew-starter-file-poi</artifactId>
<description>ContiNew Starter 文件处理模块 - POI</description>
<dependencies>
<!-- 文件上传 -->
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<!-- JSON -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<!-- POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.4.1</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,35 @@
package top.continew.starter.file.poi.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author jiang4yu
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcelExport {
/**
* 字段名称
*/
String value();
/**
* 导出排序先后: 数字越小越靠前默认按Java类字段顺序导出
*/
int sort() default 0;
/**
* 导出映射格式如0-未知;1-男;2-女
*/
String kv() default "";
/**
* 导出模板示例值(有值的话,直接取该值,不做映射)
*/
String example() default "";
}

View File

@@ -0,0 +1,40 @@
package top.continew.starter.file.poi.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author jiang4yu
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcelImport {
/**
* 字段名称
*/
String value();
/**
* 导出映射格式如0-未知;1-男;2-女
*/
String kv() default "";
/**
* 是否为必填字段(默认为非必填)
*/
boolean required() default false;
/**
* 最大长度默认255
*/
int maxLength() default 255;
/**
* 导入唯一性验证(多个字段则取联合验证)
*/
boolean unique() default false;
}

View File

@@ -0,0 +1,88 @@
package top.continew.starter.file.poi.model;
import java.util.LinkedHashMap;
/**
* @author jiang4yu
*/
public class ExcelClassField {
/**
* 字段名称
*/
private String fieldName;
/**
* 表头名称
*/
private String name;
/**
* 映射关系
*/
private LinkedHashMap<String, String> kvMap;
/**
* 示例值
*/
private Object example;
/**
* 排序
*/
private int sort;
/**
* 是否为注解字段0-否1-是
*/
private int hasAnnotation;
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public LinkedHashMap<String, String> getKvMap() {
return kvMap;
}
public void setKvMap(LinkedHashMap<String, String> kvMap) {
this.kvMap = kvMap;
}
public Object getExample() {
return example;
}
public void setExample(Object example) {
this.example = example;
}
public int getSort() {
return sort;
}
public void setSort(int sort) {
this.sort = sort;
}
public int getHasAnnotation() {
return hasAnnotation;
}
public void setHasAnnotation(int hasAnnotation) {
this.hasAnnotation = hasAnnotation;
}
}