韦二铭 hace 5 años
padre
commit
8ce5452a92
Se han modificado 36 ficheros con 344 adiciones y 265 borrados
  1. 5 0
      base-springframework-starter/pom.xml
  2. 0 6
      base-springframework/base-springframework-core/pom.xml
  3. 0 2
      base-springframework/base-springframework-core/src/main/resources/META-INF/spring.factories
  4. 0 0
      base-springframework/base-springframework-db/.gitignore
  5. 1 16
      base-springframework/base-springframework-db/pom.xml
  6. 2 2
      base-springframework/base-springframework-db/src/main/java/com/wei/base/springframework/db/env/InitializeCustomConfiguration.java
  7. 7 0
      base-springframework/base-springframework-db/src/main/resources/META-INF/spring.factories
  8. 4 0
      base-springframework/base-springframework-db/src/main/resources/application-db.yml
  9. 7 1
      base-springframework/base-springframework-easyexcel/pom.xml
  10. 0 16
      base-springframework/base-springframework-easyexcel/src/main/resources/application-redis.yml
  11. 65 0
      base-springframework/base-springframework-mybatis-plus/pom.xml
  12. 1 1
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/config/CustomMybatisPlusProperties.java
  13. 2 2
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/config/MybatisPlusConfig.java
  14. 1 1
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/constants/GeneratorParam.java
  15. 1 1
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/BaseIService.java
  16. 2 2
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/BaseMapper.java
  17. 2 2
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/BaseServiceImpl.java
  18. 1 1
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/injector/CustomSqlInjector.java
  19. 91 0
      base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/env/InitializeCustomConfiguration.java
  20. 7 0
      base-springframework/base-springframework-mybatis-plus/src/main/resources/META-INF/spring.factories
  21. 0 0
      base-springframework/base-springframework-mybatis-plus/src/main/resources/application-mybatis-plus.yml
  22. 0 0
      base-springframework/base-springframework-mybatis-plus/src/main/resources/spy.properties
  23. 0 0
      base-springframework/base-springframework-mybatis-plus/src/main/resources/templates/controller.java.ftl
  24. 0 0
      base-springframework/base-springframework-mybatis-plus/src/main/resources/templates/mapstruct.java.ftl
  25. 0 0
      base-springframework/base-springframework-mybatis-plus/src/main/resources/templates/serviceImpl.java.ftl
  26. 0 190
      base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/generator/Generator.java
  27. 0 7
      base-springframework/base-springframework-mysql/src/main/resources/META-INF/spring.factories
  28. 6 8
      base-springframework/base-springframework-redis/src/main/java/com/wei/base/springframework/redis/config/RedisConfig.java
  29. 44 0
      base-springframework/base-springframework-redis/src/main/java/com/wei/base/springframework/redis/utils/RedisUtil.java
  30. 2 1
      base-springframework/base-springframework-redis/src/main/resources/META-INF/spring.factories
  31. 63 0
      base-springframework/base-springframework-swagger/pom.xml
  32. 1 1
      base-springframework/base-springframework-swagger/src/main/java/com/wei/base/springframework/swagger/config/Swagger3Config.java
  33. 1 1
      base-springframework/base-springframework-swagger/src/main/java/com/wei/base/springframework/swagger/config/Swagger3ServiceModelToOpenApiMapperImpl.java
  34. 6 0
      base-springframework/base-springframework-swagger/src/main/resources/META-INF/spring.factories
  35. 3 1
      base-springframework/pom.xml
  36. 19 3
      wei-developer-platform/wei-developer-platform-app/src/main/java/com/wei/developer/platform/controller/UserController.java

+ 5 - 0
base-springframework-starter/pom.xml

@@ -36,6 +36,11 @@
             <artifactId>base-springframework-cloud</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>com.wei</groupId>
+            <artifactId>base-springframework-swagger</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 
     <dependencyManagement>

+ 0 - 6
base-springframework/base-springframework-core/pom.xml

@@ -38,12 +38,6 @@
         </dependency>
 
         <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-boot-starter</artifactId>
-            <version>${springfox-boot-starter.version}</version>
-        </dependency>
-
-        <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
             <version>${spring-boot-starter.version}</version>

+ 0 - 2
base-springframework/base-springframework-core/src/main/resources/META-INF/spring.factories

@@ -1,6 +1,4 @@
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-  com.wei.base.springframework.core.swagger.Swagger3Config,\
-  com.wei.base.springframework.core.swagger.Swagger3ServiceModelToOpenApiMapperImpl,\
   com.wei.base.springframework.core.web.config.ResponseHandlerConfigure,\
   com.wei.base.springframework.core.web.handler.BaseExceptionHandler,\
   com.wei.base.springframework.core.web.handler.ResponseHandler,\

+ 0 - 0
base-springframework/base-springframework-mysql/.gitignore → base-springframework/base-springframework-db/.gitignore


+ 1 - 16
base-springframework/base-springframework-mysql/pom.xml → base-springframework/base-springframework-db/pom.xml

@@ -10,7 +10,7 @@
         <version>0.0.1-SNAPSHOT</version>
     </parent>
 
-    <artifactId>base-springframework-mysql</artifactId>
+    <artifactId>base-springframework-db</artifactId>
 
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -40,21 +40,6 @@
             <version>${mysql-connector-java.version}</version>
         </dependency>
         <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>${mybatis-plus.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-generator</artifactId>
-            <version>${mybatis-plus.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.freemarker</groupId>
-            <artifactId>freemarker</artifactId>
-            <version>${freemarker.version}</version>
-        </dependency>
-        <dependency>
             <groupId>p6spy</groupId>
             <artifactId>p6spy</artifactId>
             <version>${p6spy.version}</version>

+ 2 - 2
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/env/InitializeCustomConfiguration.java → base-springframework/base-springframework-db/src/main/java/com/wei/base/springframework/db/env/InitializeCustomConfiguration.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.mysql.env;
+package com.wei.base.springframework.db.env;
 
 import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
@@ -26,7 +26,7 @@ import java.util.Properties;
 public class InitializeCustomConfiguration implements EnvironmentPostProcessor, Ordered {
 
     //自定义配置文件地址
-    private static final List<String> PROFILES = Lists.newArrayList("application-mysql.yml");
+    private static final List<String> PROFILES = Lists.newArrayList("application-db.yml");
 
     @Override
     public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {

+ 7 - 0
base-springframework/base-springframework-db/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,7 @@
+#org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+#  com.wei.base.springframework.mysql.mybatisplus.config.MybatisPlusConfig,\
+#  com.wei.base.springframework.mysql.mybatisplus.core.injector.CustomSqlInjector,\
+#  com.wei.base.springframework.mysql.mybatisplus.config.CustomMybatisPlusProperties
+
+org.springframework.boot.env.EnvironmentPostProcessor=\
+  com.wei.base.springframework.db.env.InitializeCustomConfiguration

+ 4 - 0
base-springframework/base-springframework-db/src/main/resources/application-db.yml

@@ -0,0 +1,4 @@
+#公共配置 减少各个项目中的配置
+spring:
+  datasource:
+    driver-class-name: com.p6spy.engine.spy.P6SpyDriver

+ 7 - 1
base-springframework/base-springframework-easyexcel/pom.xml

@@ -29,7 +29,13 @@
 
         <dependency>
             <groupId>com.wei</groupId>
-            <artifactId>base-springframework-mysql</artifactId>
+            <artifactId>base-springframework-swagger</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.wei</groupId>
+            <artifactId>base-springframework-mybatis-plus</artifactId>
             <version>${project.version}</version>
         </dependency>
 

+ 0 - 16
base-springframework/base-springframework-easyexcel/src/main/resources/application-redis.yml

@@ -1,16 +0,0 @@
-spring:
-  redis:
-    #默认端口
-    port: 6379
-    jedis:
-      pool:
-        # 连接池最大连接数(使用负值表示没有限制)
-        max-active: 200
-        # 连接池最大阻塞等待时间(使用负值表示没有限制)
-        max-wait: -1
-        # 连接池中的最小空闲连接
-        min-idle: 0
-        # 连接池中的最大空闲连接
-        max-idle: 10
-    # 连接超时时间(毫秒)
-    timeout: 3000

+ 65 - 0
base-springframework/base-springframework-mybatis-plus/pom.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>com.wei</groupId>
+        <artifactId>base-springframework</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>base-springframework-mybatis-plus</artifactId>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <spring-boot-maven-plugin.version>2.3.4.RELEASE</spring-boot-maven-plugin.version>
+        <mybatis-plus.version>3.3.2</mybatis-plus.version>
+        <freemarker.version>2.3.30</freemarker.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.wei</groupId>
+            <artifactId>base-springframework-util</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>${mybatis-plus.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>${mybatis-plus.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+            <version>${freemarker.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-maven-plugin</artifactId>
+                    <version>${spring-boot-maven-plugin.version}</version>
+                    <executions>
+                        <execution>
+                            <goals>
+                                <goal>repackage</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>

+ 1 - 1
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/mybatisplus/config/CustomMybatisPlusProperties.java → base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/config/CustomMybatisPlusProperties.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.mysql.mybatisplus.config;
+package com.wei.base.springframework.mybatisplus.config;
 
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import lombok.Data;

+ 2 - 2
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/mybatisplus/config/MybatisPlusConfig.java → base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/config/MybatisPlusConfig.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.mysql.mybatisplus.config;
+package com.wei.base.springframework.mybatisplus.config;
 
 import com.baomidou.mybatisplus.annotation.DbType;
 import com.baomidou.mybatisplus.core.parser.ISqlParser;
@@ -15,7 +15,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 import java.util.List;
 
 @EnableTransactionManagement
-@MapperScan("com.wei.**.mapper")
+@MapperScan("com.**.mapper")
 @Configuration
 public class MybatisPlusConfig {
 

+ 1 - 1
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/constants/GeneratorParam.java → base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/constants/GeneratorParam.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.mysql.constants;
+package com.wei.base.springframework.mybatisplus.constants;
 
 import lombok.Data;
 

+ 1 - 1
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/mybatisplus/core/BaseIService.java → base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/BaseIService.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.mysql.mybatisplus.core;
+package com.wei.base.springframework.mybatisplus.core;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 

+ 2 - 2
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/mybatisplus/core/BaseMapper.java → base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/BaseMapper.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.mysql.mybatisplus.core;
+package com.wei.base.springframework.mybatisplus.core;
 
 import java.util.List;
 
@@ -11,7 +11,7 @@ public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.Base
      * @return
      */
     int insertBatchSomeColumn(List<T> entityList);
-    
+
     /**
      * 逻辑删除 需要在实体里逻辑删除的字段上添加@TableLogic注解
      * 根据 id 逻辑删除数据,并带字段填充功能

+ 2 - 2
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/mybatisplus/core/BaseServiceImpl.java → base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/BaseServiceImpl.java

@@ -1,8 +1,8 @@
-package com.wei.base.springframework.mysql.mybatisplus.core;
+package com.wei.base.springframework.mybatisplus.core;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.google.common.collect.Lists;
-import com.wei.base.springframework.mysql.mybatisplus.config.CustomMybatisPlusProperties;
+import com.wei.base.springframework.mybatisplus.config.CustomMybatisPlusProperties;
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.List;

+ 1 - 1
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/mybatisplus/core/injector/CustomSqlInjector.java → base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/core/injector/CustomSqlInjector.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.mysql.mybatisplus.core.injector;
+package com.wei.base.springframework.mybatisplus.core.injector;
 
 import com.baomidou.mybatisplus.core.injector.AbstractMethod;
 import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;

+ 91 - 0
base-springframework/base-springframework-mybatis-plus/src/main/java/com/wei/base/springframework/mybatisplus/env/InitializeCustomConfiguration.java

@@ -0,0 +1,91 @@
+package com.wei.base.springframework.mybatisplus.env;
+
+import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.boot.env.YamlPropertySourceLoader;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertiesPropertySource;
+import org.springframework.core.env.PropertySource;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * 加载自定义配置文件
+ *
+ * @author : weierming
+ * @date : 2020/7/13
+ */
+public class InitializeCustomConfiguration implements EnvironmentPostProcessor, Ordered {
+
+    //自定义配置文件地址
+    private static final List<String> PROFILES = Lists.newArrayList("application-mybatis-plus.yml");
+
+    @Override
+    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
+        PROFILES.stream().forEach(profile -> {
+            //从classpath路径下面查找文件
+            Resource resource = new ClassPathResource(profile);
+            if (resource == null || !resource.exists()) {
+                throw new IllegalArgumentException("资源" + resource + "不存在");
+            }
+
+            MutablePropertySources mutablePropertySources = environment.getPropertySources();
+            //加载成PropertySource对象,并添加到Environment环境中
+            switch (StringUtils.substringAfterLast(profile, ".")) {
+                case "yml":
+                    List<PropertySource<?>> propertySources = loadYmlProfiles(resource);
+                    propertySources.stream().forEach(propertySource -> {
+                        mutablePropertySources.addLast(propertySource);
+                    });
+                    break;
+                default:
+                    mutablePropertySources.addLast(loadProfiles(resource));
+                    break;
+            }
+        });
+    }
+
+    /**
+     * 加载单个配置文件
+     *
+     * @param resource
+     * @return
+     */
+    private PropertiesPropertySource loadProfiles(Resource resource) {
+        try {
+            Properties properties = new Properties();
+            properties.load(resource.getInputStream());
+            return new PropertiesPropertySource(resource.getFilename(), properties);
+        } catch (IOException ex) {
+            throw new IllegalStateException("加载配置文件失败" + resource, ex);
+        }
+    }
+
+    /**
+     * 加载yml格式配置文件
+     *
+     * @param resource
+     * @return
+     */
+    private List<PropertySource<?>> loadYmlProfiles(Resource resource) {
+        try {
+            YamlPropertySourceLoader yamlPropertySourceLoader = new YamlPropertySourceLoader();
+            return yamlPropertySourceLoader.load(resource.getFilename(), resource);
+        } catch (IOException ex) {
+            throw new IllegalStateException("加载配置文件失败" + resource, ex);
+        }
+    }
+
+    @Override
+    public int getOrder() {
+        return -1;
+    }
+}

+ 7 - 0
base-springframework/base-springframework-mybatis-plus/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,7 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+  com.wei.base.springframework.mybatisplus.config.MybatisPlusConfig,\
+  com.wei.base.springframework.mybatisplus.core.injector.CustomSqlInjector,\
+  com.wei.base.springframework.mybatisplus.config.CustomMybatisPlusProperties
+
+org.springframework.boot.env.EnvironmentPostProcessor=\
+  com.wei.base.springframework.mybatisplus.env.InitializeCustomConfiguration

+ 0 - 0
base-springframework/base-springframework-mysql/src/main/resources/application-mysql.yml → base-springframework/base-springframework-mybatis-plus/src/main/resources/application-mybatis-plus.yml


+ 0 - 0
base-springframework/base-springframework-mysql/src/main/resources/spy.properties → base-springframework/base-springframework-mybatis-plus/src/main/resources/spy.properties


+ 0 - 0
base-springframework/base-springframework-mysql/src/main/resources/templates/controller.java.ftl → base-springframework/base-springframework-mybatis-plus/src/main/resources/templates/controller.java.ftl


+ 0 - 0
base-springframework/base-springframework-mysql/src/main/resources/templates/mapstruct.java.ftl → base-springframework/base-springframework-mybatis-plus/src/main/resources/templates/mapstruct.java.ftl


+ 0 - 0
base-springframework/base-springframework-mysql/src/main/resources/templates/serviceImpl.java.ftl → base-springframework/base-springframework-mybatis-plus/src/main/resources/templates/serviceImpl.java.ftl


+ 0 - 190
base-springframework/base-springframework-mysql/src/main/java/com/wei/base/springframework/mysql/generator/Generator.java

@@ -1,190 +0,0 @@
-package com.wei.base.springframework.mysql.generator;
-
-import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.generator.config.rules.DateType;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.wei.base.springframework.mysql.constants.GeneratorParam;
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * 代码生成器演示
- * </p>
- */
-public class Generator {
-
-    private static final GeneratorParam param = new GeneratorParam();
-
-    /**
-     * 当前项目地址
-     */
-    private static final String PROJECT_PATH = System.getProperty("user.dir");
-
-    /**
-     * <p>
-     * MySQL 生成演示
-     * </p>
-     */
-    public static void main(String[] args) {
-        AutoGenerator mpg = new AutoGenerator();
-        // 选择 freemarker 引擎,默认 Veloctiy
-        mpg.setTemplateEngine(new FreemarkerTemplateEngine());
-
-        // 全局配置
-        GlobalConfig gc = getGlobalConfig();
-        mpg.setGlobalConfig(gc);
-
-        // 数据源配置
-        DataSourceConfig dsc = getDataSourceConfig(gc);
-        mpg.setDataSource(dsc);
-
-        // 策略配置
-        StrategyConfig strategy = getStrategyConfig();
-        mpg.setStrategy(strategy);
-
-        // 包配置
-        PackageConfig pc = getPackageConfig();
-        mpg.setPackageInfo(pc);
-
-        String mapstructPageName = pc.getParent() + ".mapstruct";
-        String mapstructPath = StringUtils.replace(mapstructPageName, ".", "/");
-
-        // 自定义配置
-        List<FileOutConfig> focList = getFileOutConfig(mapstructPath);
-        InjectionConfig cfg = new InjectionConfig() {
-            @Override
-            public void initMap() {
-                Map<String, Object> map = Maps.newHashMap();
-                map.put("mapstructPageName", mapstructPageName);
-                setMap(map);
-            }
-        };
-
-        cfg.setFileOutConfigList(focList);
-        mpg.setCfg(cfg);
-
-//        // 关闭默认 xml 生成,调整生成 至 根目录
-//        TemplateConfig tc = new TemplateConfig();
-//        tc.setXml(null);
-//        mpg.setTemplate(tc);
-
-        // 自定义模板配置,可以 copy 源码 mybatis-plus/src/main/resources/templates 下面内容修改,
-        // 放置自己项目的 src/main/resources/templates 目录下, 默认名称一下可以不配置,也可以自定义模板名称
-        // TemplateConfig tc = new TemplateConfig();
-        // tc.setController("...");
-        // tc.setEntity("...");
-        // tc.setMapper("...");
-        // tc.setXml("...");
-        // tc.setService("...");
-        // tc.setServiceImpl("...");
-        // 如上任何一个模块如果设置 空 OR Null 将不生成该模块。
-        // mpg.setTemplate(tc);
-
-        // 执行生成
-        mpg.execute();
-
-        // 打印注入设置【可无】
-//        System.err.println(mpg.getCfg().getMap().get("abc"));
-    }
-
-    private static GlobalConfig getGlobalConfig() {
-        GlobalConfig gc = new GlobalConfig();
-        gc.setAuthor(param.getAuthor());
-        gc.setOutputDir(PROJECT_PATH + param.getOutputDir());
-        gc.setFileOverride(false);// 是否覆盖同名文件,默认是false
-        gc.setActiveRecord(Boolean.FALSE);// 不需要ActiveRecord特性的请改为false
-        gc.setEnableCache(false);// XML 二级缓存
-        gc.setBaseResultMap(true);// XML ResultMap
-        gc.setBaseColumnList(false);// XML columList
-        //设置日期类型
-        gc.setDateType(DateType.TIME_PACK);
-        gc.setServiceName("%sService");
-
-        return gc;
-    }
-
-    private static DataSourceConfig getDataSourceConfig(GlobalConfig globalConfig) {
-        DataSourceConfig dsc = new DataSourceConfig();
-        dsc.setDbType(DbType.MYSQL);
-//        dsc.setTypeConvert(new MySqlTypeConvert() {
-//            // 自定义数据库表字段类型转换【可选】
-//            public IColumnType processTypeConvert(String fieldType) {
-//                System.out.println("Model转换类型:" + fieldType);
-//                // 注意!!processTypeConvert 存在默认类型转换,如果不是你要的效果请自定义返回、非如下直接返回。
-//                return super.processTypeConvert(globalConfig, fieldType);
-//            }
-//        });
-
-        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
-        dsc.setUsername(param.getDataSourceUserName());
-        dsc.setPassword(param.getDataSourcePassWord());
-        dsc.setUrl(param.getDataSourceUrl());
-        return dsc;
-    }
-
-    private static StrategyConfig getStrategyConfig() {
-        StrategyConfig strategy = new StrategyConfig();
-        // strategy.setCapitalMode(true);// 全局大写命名 ORACLE 注意
-//        strategy.setTablePrefix(new String[]{"user_"});// 此处可以修改为您的表前缀
-        strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(param.getInclude()); // 需要生成的表
-        strategy.setExclude(param.getExclude()); // 排除生成的表
-        strategy.setEntityLombokModel(Boolean.TRUE);
-        strategy.setRestControllerStyle(Boolean.TRUE);
-        // 自定义实体父类
-        // strategy.setSuperEntityClass("com.baomidou.demo.TestEntity");
-        // 自定义实体,公共字段
-        // strategy.setSuperEntityColumns(new String[] { "test_id", "age" });
-        // 自定义 mapper 父类
-        // strategy.setSuperMapperClass("com.baomidou.demo.TestMapper");
-        // 自定义 service 父类
-        // strategy.setSuperServiceClass("com.baomidou.demo.TestService");
-        // 自定义 service 实现类父类
-        // strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl");
-        // 自定义 controller 父类
-        // strategy.setSuperControllerClass("com.baomidou.demo.TestController");
-        // 【实体】是否生成字段常量(默认 false)
-        // public static final String ID = "test_id";
-        // strategy.setEntityColumnConstant(true);
-        // 【实体】是否为构建者模型(默认 false)
-        // public User setName(String name) {this.name = name; return this;}
-        // strategy.setEntityBuilderModel(true);
-        return strategy;
-    }
-
-    private static PackageConfig getPackageConfig() {
-        PackageConfig pc = new PackageConfig();
-        pc.setParent(param.getParent());
-//        pc.setModuleName("test");
-        return pc;
-    }
-
-    /**
-     * 设置自定义模板
-     *
-     * @param mapstructPath
-     * @return
-     */
-    private static List<FileOutConfig> getFileOutConfig(String mapstructPath) {
-        List<FileOutConfig> list = Lists.newArrayList();
-        list.add(new FileOutConfig("/templates/mapstruct.java.ftl") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                //输出的位置
-                return PROJECT_PATH + param.getOutputDir() + mapstructPath + "/" + tableInfo.getEntityName() + "Mapstruct.java";
-            }
-        });
-
-        return list;
-    }
-}

+ 0 - 7
base-springframework/base-springframework-mysql/src/main/resources/META-INF/spring.factories

@@ -1,7 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-  com.wei.base.springframework.mysql.mybatisplus.config.MybatisPlusConfig,\
-  com.wei.base.springframework.mysql.mybatisplus.core.injector.CustomSqlInjector,\
-  com.wei.base.springframework.mysql.mybatisplus.config.CustomMybatisPlusProperties
-
-org.springframework.boot.env.EnvironmentPostProcessor=\
-  com.wei.base.springframework.mysql.env.InitializeCustomConfiguration

+ 6 - 8
base-springframework/base-springframework-redis/src/main/java/com/wei/base/springframework/redis/config/RedisConfig.java

@@ -1,8 +1,10 @@
 package com.wei.base.springframework.redis.config;
 
 import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.PropertyAccessor;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
@@ -12,20 +14,18 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
 
 @Configuration
 public class RedisConfig {
-    
+
     @Bean
     public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
         RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
-
         redisTemplate.setConnectionFactory(factory);
 
-        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
-
         ObjectMapper objectMapper = new ObjectMapper();
-
         objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
         jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
-
         StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
 
         // key采用String的序列化方式
@@ -35,10 +35,8 @@ public class RedisConfig {
 
         // value序列化方式采用jackson
         redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
-
         // hash的value序列化方式采用jackson
         redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
-
         redisTemplate.afterPropertiesSet();
         return redisTemplate;
     }

+ 44 - 0
base-springframework/base-springframework-redis/src/main/java/com/wei/base/springframework/redis/utils/RedisUtil.java

@@ -0,0 +1,44 @@
+package com.wei.base.springframework.redis.utils;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class RedisUtil {
+
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+
+    private ObjectMapper objectMapper = new ObjectMapper();
+
+    public <T> T get(String key, Class<T> t) {
+        Object object = redisTemplate.opsForValue().get(key);
+        return objectMapper.convertValue(object, t);
+    }
+
+    public void set(String key, Object o) {
+        redisTemplate.opsForValue().set(key, o);
+    }
+
+    public void set(String key, Object o, Long timeOut) {
+        if (timeOut > 0) {
+            redisTemplate.opsForValue().set(key, o, timeOut, TimeUnit.SECONDS);
+            return;
+        }
+
+        redisTemplate.opsForValue().set(key, o);
+    }
+
+    public Boolean hasKey(String key) {
+        return redisTemplate.hasKey(key);
+    }
+
+    public Map<String, Object> get(String key, String hashKey) {
+        return (Map<String, Object>) redisTemplate.opsForHash().get(key, hashKey);
+    }
+}

+ 2 - 1
base-springframework/base-springframework-redis/src/main/resources/META-INF/spring.factories

@@ -1,6 +1,7 @@
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
   com.wei.base.springframework.redis.config.RedisConfig,\
-  com.wei.base.springframework.redis.utils.RedisLock
+  com.wei.base.springframework.redis.utils.RedisLock,\
+  com.wei.base.springframework.redis.utils.RedisUtil
 
 org.springframework.boot.env.EnvironmentPostProcessor=\
   com.wei.base.springframework.redis.env.InitializeCustomConfiguration

+ 63 - 0
base-springframework/base-springframework-swagger/pom.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>com.wei</groupId>
+        <artifactId>base-springframework</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>base-springframework-swagger</artifactId>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <springfox-boot-starter.version>3.0.0</springfox-boot-starter.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>${springfox-boot-starter.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.wei</groupId>
+            <artifactId>base-springframework-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-maven-plugin</artifactId>
+                    <version>${spring-boot-maven-plugin.version}</version>
+                    <executions>
+                        <execution>
+                            <goals>
+                                <goal>repackage</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>build-info</id>
+                            <goals>
+                                <goal>build-info</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+</project>

+ 1 - 1
base-springframework/base-springframework-core/src/main/java/com/wei/base/springframework/core/swagger/Swagger3Config.java → base-springframework/base-springframework-swagger/src/main/java/com/wei/base/springframework/swagger/config/Swagger3Config.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.core.swagger;
+package com.wei.base.springframework.swagger.config;
 
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
base-springframework/base-springframework-core/src/main/java/com/wei/base/springframework/core/swagger/Swagger3ServiceModelToOpenApiMapperImpl.java → base-springframework/base-springframework-swagger/src/main/java/com/wei/base/springframework/swagger/config/Swagger3ServiceModelToOpenApiMapperImpl.java

@@ -1,4 +1,4 @@
-package com.wei.base.springframework.core.swagger;
+package com.wei.base.springframework.swagger.config;
 
 import com.google.common.collect.Maps;
 import com.wei.base.springframework.core.web.config.ResponseHandlerConfigure;

+ 6 - 0
base-springframework/base-springframework-swagger/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,6 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+  com.wei.base.springframework.swagger.config.Swagger3Config,\
+  com.wei.base.springframework.swagger.config.Swagger3ServiceModelToOpenApiMapperImpl
+
+org.springframework.boot.env.EnvironmentPostProcessor=\
+  com.wei.base.springframework.core.env.InitializeCustomConfiguration

+ 3 - 1
base-springframework/pom.xml

@@ -11,10 +11,12 @@
         <module>base-springframework-constant</module>
         <module>base-springframework-util</module>
         <module>base-springframework-core</module>
-        <module>base-springframework-mysql</module>
+        <module>base-springframework-db</module>
         <module>base-springframework-redis</module>
         <module>base-springframework-cloud</module>
         <module>base-springframework-easyexcel</module>
+        <module>base-springframework-swagger</module>
+        <module>base-springframework-mybatis-plus</module>
     </modules>
 
     <properties>

+ 19 - 3
wei-developer-platform/wei-developer-platform-app/src/main/java/com/wei/developer/platform/controller/UserController.java

@@ -1,16 +1,19 @@
 package com.wei.developer.platform.controller;
 
+import com.wei.base.springframework.redis.utils.RedisUtil;
 import com.wei.base.springframework.util.VerifyImageUtil;
 import com.wei.base.springframework.util.kaptcha.vo.CharVerifyImage;
 import com.wei.base.springframework.util.kaptcha.vo.OperatorVerifyImage;
 import com.wei.base.springframework.util.kaptcha.vo.SlideVerifyImage;
 import com.wei.base.springframework.util.kaptcha.vo.TextSelectionVerifyImage;
+import com.wei.developer.platform.entity.User;
 import com.wei.developer.platform.service.UserService;
 import com.wei.developer.platform.vo.request.CheckVerifyImageRequest;
 import com.wei.developer.platform.vo.respon.VerifyImageResp;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.v3.oas.annotations.Parameter;
+import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
@@ -35,7 +38,13 @@ public class UserController {
     private UserService userService;
 
     @Autowired
-    private RedisTemplate redisTemplate;
+    private RedisTemplate<String, Object> redisTemplate;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Autowired
+    private RedissonClient redissonClient;
 
     @ApiOperation("生成验证码图片")
     @GetMapping("generateVerifyImage")
@@ -53,8 +62,15 @@ public class UserController {
 
     @ApiOperation("分页查询所有数据")
     @PostMapping("test")
-    public CharVerifyImage getCharVerifyImage(@RequestBody CharVerifyImage verifyImage) throws IOException {
-        return VerifyImageUtil.getCharVerifyImage();
+    public Object getCharVerifyImage(@RequestBody CharVerifyImage verifyImage) throws IOException {
+        User user = new User();
+        user.setId(1L);
+        user.setName("222");
+
+        redisTemplate.opsForValue().set("test", user);
+        user = redisUtil.get("test", User.class);
+        System.err.println(user.toString());
+        return redisTemplate.opsForValue().get("test");
     }
 
     @ApiOperation("分页查询所有数据1")