org.apache.poi
@@ -46,4 +53,88 @@
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+
+
+
+
+ master
+ scm:git:git://github.com/gnerv/gnerv-utils.git
+ scm:git:ssh://github.com/gnerv/gnerv-utils.git
+ https://github.com/gnerv/gnerv-utils/tree/master
+
+
+
+
+ Gnerv LiGen
+ ligendwow@126.com
+ https://github.com/gnerv
+
+
+
+
+
+ ossrh
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+ ossrh
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-clean-plugin
+ 3.1.0
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.1.0
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.1.0
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+
diff --git a/src/main/java/com/gnerv/boot/annotation/ESExcel.java b/src/main/java/com/gnerv/boot/annotation/ESExcel.java
new file mode 100644
index 0000000..80c8f40
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/annotation/ESExcel.java
@@ -0,0 +1,25 @@
+package com.gnerv.boot.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * excel 实体对象注解
+ *
+ *
+ * @author Gnerv LiGen
+ * @since 2019/8/28
+ */
+@Target({ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ESExcel {
+
+ int columnIndex() default 0;
+
+ String columnName() default "";
+}
diff --git a/src/main/java/com/gnerv/boot/annotation/EntityExtend.java b/src/main/java/com/gnerv/boot/annotation/EntityExtend.java
new file mode 100644
index 0000000..b9959ee
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/annotation/EntityExtend.java
@@ -0,0 +1,55 @@
+package com.gnerv.boot.annotation;
+
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * 扩展类 注解
+ * 对于使用mybatis-plus注解与数据库字段对应
+ * 并且mapper接口继承了mybatis-plus的baseMapper的扩展类
+ * 在不指定对应crud方法时
+ * 将尝试使用通用crud方法
+ * 否则必须指定对应crud方法
+ *
+ *
+ * @author Gnerv LiGen
+ * @since 2019/9/4
+ */
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface EntityExtend {
+
+ // 被注入的对象
+ Class clazz();
+
+ // mapper接口类
+ Class mapper();
+
+ // 插入方法名
+ String insert() default "";
+
+ // 删除方法名
+ String delete() default "";
+
+ // 更新方法名
+ String update() default "";
+
+ // 查询方法名
+ String select() default "";
+
+ // 参数名
+ String parameter() default "";
+
+ // 对应主表字段名
+ String mColumn() default "";
+
+ // 对应从表字段名
+ String sColumn() default "";
+
+}
diff --git a/src/main/java/com/gnerv/boot/annotation/ResultFilter.java b/src/main/java/com/gnerv/boot/annotation/ResultFilter.java
new file mode 100644
index 0000000..83ca160
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/annotation/ResultFilter.java
@@ -0,0 +1,24 @@
+package com.gnerv.boot.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * 返回参数过滤
+ *
+ *
+ * @author Gnerv LiGen
+ * @since 2019/8/13
+ */
+@Target({ElementType.TYPE, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ResultFilter {
+
+ String[] field() default {};
+
+}
diff --git a/src/main/java/com/gnerv/boot/common/EntityExtendBean.java b/src/main/java/com/gnerv/boot/common/EntityExtendBean.java
new file mode 100644
index 0000000..6a8bcdd
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/common/EntityExtendBean.java
@@ -0,0 +1,21 @@
+package com.gnerv.boot.common;
+
+import com.gnerv.boot.annotation.EntityExtend;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * 存储包含实体扩展类注解的类
+ *
+ *
+ * @author Gnerv LiGen
+ * @since 2019/9/4
+ */
+public class EntityExtendBean {
+
+ public static Map BEANS_MAP = new HashMap<>();
+
+
+}
diff --git a/src/main/java/com/gnerv/boot/config/EntityExtendConfig.java b/src/main/java/com/gnerv/boot/config/EntityExtendConfig.java
new file mode 100644
index 0000000..215ce3b
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/config/EntityExtendConfig.java
@@ -0,0 +1,23 @@
+package com.gnerv.boot.config;
+
+import com.gnerv.boot.interceptor.EntityExtendInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ *
+ * 实体扩展配置
+ *
+ *
+ * @author Gnerv LiGen
+ * @since 2019/9/4
+ */
+@Configuration
+public class EntityExtendConfig {
+
+ @Bean
+ public EntityExtendInterceptor getEntityExtendInterceptor(){
+ return new EntityExtendInterceptor();
+ }
+
+}
diff --git a/src/main/java/com/gnerv/boot/entity/BaseExtend.java b/src/main/java/com/gnerv/boot/entity/BaseExtend.java
new file mode 100644
index 0000000..8020a41
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/entity/BaseExtend.java
@@ -0,0 +1,39 @@
+package com.gnerv.boot.entity;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+
+import java.io.Serializable;
+
+/**
+ *
+ * 实体扩展类
+ *
+ *
+ * @author Gnerv LiGen
+ * @since 2019/9/4
+ */
+public class BaseExtend extends Model implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 扩展字段
+ */
+ @TableField(exist = false)
+ private Object extend;
+
+ public Object getExtend() {
+ return extend;
+ }
+
+ public void setExtend(Object extend) {
+ this.extend = extend;
+ }
+
+ @Override
+ public String toString() {
+ return JSON.toJSONString(this);
+ }
+}
diff --git a/src/main/java/com/gnerv/boot/interceptor/EntityExtendInterceptor.java b/src/main/java/com/gnerv/boot/interceptor/EntityExtendInterceptor.java
new file mode 100644
index 0000000..00b5d9f
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/interceptor/EntityExtendInterceptor.java
@@ -0,0 +1,64 @@
+package com.gnerv.boot.interceptor;
+
+import com.gnerv.boot.annotation.EntityExtend;
+import com.gnerv.boot.common.EntityExtendBean;
+import com.gnerv.boot.utils.mapper.MapperUtils;
+import org.apache.ibatis.executor.Executor;
+import org.apache.ibatis.executor.resultset.ResultSetHandler;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.ibatis.mapping.ResultMap;
+import org.apache.ibatis.mapping.ResultMapping;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.plugin.Intercepts;
+import org.apache.ibatis.plugin.Invocation;
+import org.apache.ibatis.plugin.Plugin;
+import org.apache.ibatis.plugin.Signature;
+import org.apache.ibatis.session.ResultHandler;
+import org.apache.ibatis.session.RowBounds;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+@Component
+@Intercepts({@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class}),
+ @Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
+public class EntityExtendInterceptor implements Interceptor {
+
+
+ @Override
+ public Object intercept(Invocation invocation) throws Throwable {
+ Object[] args = invocation.getArgs();
+ MappedStatement ms = (MappedStatement) args[0];
+ EntityExtend entityExtend = checkEntityExtend(ms);
+ if(StringUtils.isEmpty(entityExtend)){
+ return invocation.proceed();
+ }
+ MappedStatement mappedStatement = MapperUtils.buildMappedStatement(ms, entityExtend);
+ args[0] = mappedStatement;
+ return invocation.proceed();
+ }
+
+ @Override
+ public Object plugin(Object target) {
+ return target instanceof ResultSetHandler ? Plugin.wrap(target, this) : target;
+ }
+
+ @Override
+ public void setProperties(Properties properties) {
+
+ }
+
+ public EntityExtend checkEntityExtend(MappedStatement ms){
+ EntityExtend entityExtend = null;
+ List resultMaps = ms.getResultMaps();
+ for (ResultMap resultMap : resultMaps) {
+ Class> type = resultMap.getType();
+ entityExtend = EntityExtendBean.BEANS_MAP.get(type);
+ }
+ return entityExtend;
+ }
+
+}
diff --git a/src/main/java/com/gnerv/boot/listener/ContextRefreshedListener.java b/src/main/java/com/gnerv/boot/listener/ContextRefreshedListener.java
new file mode 100644
index 0000000..903b4d5
--- /dev/null
+++ b/src/main/java/com/gnerv/boot/listener/ContextRefreshedListener.java
@@ -0,0 +1,40 @@
+package com.gnerv.boot.listener;
+
+import com.gnerv.boot.annotation.EntityExtend;
+import com.gnerv.boot.common.EntityExtendBean;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * spring 容器内容 监听器
+ *
+ *
+ * @author Gnerv LiGen
+ * @since 2019/8/30
+ */
+@Component
+public class ContextRefreshedListener implements ApplicationListener {
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
+ saveEntityExtendBean(contextRefreshedEvent);
+ }
+
+ public void saveEntityExtendBean(ContextRefreshedEvent contextRefreshedEvent) {
+ Map map = new HashMap<>();
+ Map beans = contextRefreshedEvent.getApplicationContext().getBeansWithAnnotation(EntityExtend.class);
+ for (Object o : beans.values()) {
+ Class> clazz = o.getClass();
+ EntityExtend entityExtend = clazz.getAnnotation(EntityExtend.class);
+ map.put(clazz, entityExtend);
+ }
+ EntityExtendBean.BEANS_MAP = map;
+ }
+
+
+}
diff --git a/src/main/java/com/gnerv/boot/utils/ExcelUtil.java b/src/main/java/com/gnerv/boot/utils/excel/ExcelUtils.java
similarity index 94%
rename from src/main/java/com/gnerv/boot/utils/ExcelUtil.java
rename to src/main/java/com/gnerv/boot/utils/excel/ExcelUtils.java
index 9c8b0f0..c37b434 100644
--- a/src/main/java/com/gnerv/boot/utils/ExcelUtil.java
+++ b/src/main/java/com/gnerv/boot/utils/excel/ExcelUtils.java
@@ -1,4 +1,4 @@
-package com.gnerv.boot.utils;
+package com.gnerv.boot.utils.excel;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
@@ -15,29 +15,18 @@
import java.util.ArrayList;
import java.util.List;
-/**
- * @author Gnerv LiGen
- * @description Excel工具
- * @data 2019/6/13
- */
-public class ExcelUtil {
+public class ExcelUtils {
private final static String xls = "xls";
private final static String xlsx = "xlsx";
- /**
- * 读入excel文件,解析后返回
- *
- * @param file
- * @throws IOException
- */
public static List