Browse Source

添加服务间调用授权认证;修改了包的目录结构

tuonina 6 years ago
parent
commit
429cf253db
34 changed files with 406 additions and 191 deletions
  1. 4 0
      FRAMEWORK.md
  2. 2 2
      zen-api/src/main/java/cn/gygxzc/envir/test/dao/ITestLogDao.java
  3. 1 1
      zen-api/src/main/java/cn/gygxzc/envir/test/model/TestLog.java
  4. 1 1
      zen-core/src/main/java/cn/gygxzc/envir/core/base/BaseModel.java
  5. 126 0
      zen-core/src/main/java/cn/gygxzc/envir/core/redis/JedisConnectionConfiguration.java
  6. 68 0
      zen-core/src/main/java/cn/gygxzc/envir/core/redis/RedisAutoConfiguration.java
  7. 157 0
      zen-core/src/main/java/cn/gygxzc/envir/core/redis/RedisConnectionConfiguration.java
  8. 1 1
      zen-core/src/main/java/cn/gygxzc/envir/core/utils/HttpUtils.java
  9. 8 0
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/CoreConfiguration.kt
  10. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/caffeine/CaffeineConfiguration.kt
  11. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/caffeine/CaffeineProperties.kt
  12. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/Generator.kt
  13. 3 4
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/MybatisPlusConfig.kt
  14. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/base/IPhysicalMapper.kt
  15. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/handler/CustomMetaObjectHandler.kt
  16. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/LogicMoreSqlInjector.kt
  17. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/enums/SqlMethodCopy.kt
  18. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/Delete.kt
  19. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/DeleteBatchIds.kt
  20. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/DeleteById.kt
  21. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/DeleteByMap.kt
  22. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/SelectById.kt
  23. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/SelectList.kt
  24. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/SelectPage.kt
  25. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/Update.kt
  26. 2 2
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/UpdateById.kt
  27. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/envir/core/redis/RedisKeyGenerator.kt
  28. 0 46
      zen-core/src/main/kotlin/cn/gygxzc/tina/cache/redis/RedisConfig.kt
  29. 0 61
      zen-core/src/main/kotlin/cn/gygxzc/tina/cache/redis/TinaJedisConnectionConfiguration.kt
  30. 0 43
      zen-core/src/main/kotlin/cn/gygxzc/tina/cros/CrosWebFilter.kt
  31. 1 1
      zen-core/src/main/kotlin/com/gxzc/zen/common/base/BaseModel.kt
  32. 1 1
      zen-core/src/main/kotlin/com/gxzc/zen/common/util/RedisCacheUtil.kt
  33. 5 2
      zen-web/src/main/kotlin/cn/gygxzc/envir/MainApplication.kt
  34. 1 1
      zen-web/src/main/resources/bootstrap.yml

+ 4 - 0
FRAMEWORK.md

@@ -73,6 +73,10 @@ Jetty 更加轻量化,更符合Spring Cloud 分布式部署;当然,这个
 #### 2018/10/31
 - 文件上传已完成,请查看 fastdfs-client 查看上传案例写法。
 
+#### 2018/11/1
+- 调整了zen-core 包的目录结构,各位耐心改正一个引入包的路径
+- 给每个客户端添加跨域配置,方便调试
+
 ### 后期我的工作计划
 
 - 将继续精简shiro相关配置,直至完全移除;(已完成)

+ 2 - 2
zen-api/src/main/java/cn/gygxzc/envir/test/dao/ITestLogDao.java

@@ -1,7 +1,7 @@
 package cn.gygxzc.envir.test.dao;
 
 import cn.gygxzc.envir.test.model.TestLog;
-import cn.gygxzc.tina.orm.base.IPhysicalMapper;
+import cn.gygxzc.envir.core.orm.base.IPhysicalMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.springframework.stereotype.Repository;
 
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Repository;
  * Created by niantuo on 2018/9/30.
  * 数据库dao类
  *
- * @see cn.gygxzc.tina.orm.base.IPhysicalMapper  物理操作需要继承该类
+ * @see IPhysicalMapper  物理操作需要继承该类
  */
 @Repository
 public interface ITestLogDao extends BaseMapper<TestLog>, IPhysicalMapper<TestLog> {

+ 1 - 1
zen-api/src/main/java/cn/gygxzc/envir/test/model/TestLog.java

@@ -1,7 +1,7 @@
 package cn.gygxzc.envir.test.model;
 
 
-import cn.gygxzc.tina.orm.base.BaseModel;
+import cn.gygxzc.envir.core.base.BaseModel;
 import com.baomidou.mybatisplus.annotation.TableName;
 
 /**

+ 1 - 1
zen-core/src/main/java/cn/gygxzc/tina/orm/base/BaseModel.java → zen-core/src/main/java/cn/gygxzc/envir/core/base/BaseModel.java

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.orm.base;
+package cn.gygxzc.envir.core.base;
 
 import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonFormat;

+ 126 - 0
zen-core/src/main/java/cn/gygxzc/envir/core/redis/JedisConnectionConfiguration.java

@@ -0,0 +1,126 @@
+package cn.gygxzc.envir.core.redis;
+
+import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.data.redis.JedisClientConfigurationBuilderCustomizer;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.connection.RedisClusterConfiguration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.RedisSentinelConfiguration;
+import org.springframework.data.redis.connection.jedis.JedisClientConfiguration;
+import org.springframework.data.redis.connection.jedis.JedisConnection;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
+import org.springframework.util.StringUtils;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPoolConfig;
+
+import java.time.Duration;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Created by niantuo on 2018/11/1.
+ * Jedis 配置
+ */
+
+@Configuration
+@EnableConfigurationProperties(RedisProperties.class)
+@ConditionalOnClass({GenericObjectPool.class, JedisConnection.class, Jedis.class})
+public class JedisConnectionConfiguration extends RedisConnectionConfiguration {
+
+    private final RedisProperties properties;
+
+    private final List<JedisClientConfigurationBuilderCustomizer> builderCustomizers;
+
+    JedisConnectionConfiguration(RedisProperties properties,
+                                 ObjectProvider<RedisSentinelConfiguration> sentinelConfiguration,
+                                 ObjectProvider<RedisClusterConfiguration> clusterConfiguration,
+                                 ObjectProvider<List<JedisClientConfigurationBuilderCustomizer>> builderCustomizers) {
+        super(properties, sentinelConfiguration, clusterConfiguration);
+        this.properties = properties;
+        this.builderCustomizers = builderCustomizers
+                .getIfAvailable(Collections::emptyList);
+    }
+
+    @Bean
+    @Primary
+    public RedisConnectionFactory redisConnectionFactory() {
+        return createJedisConnectionFactory();
+    }
+
+    private JedisConnectionFactory createJedisConnectionFactory() {
+        JedisClientConfiguration clientConfiguration = getJedisClientConfiguration();
+        if (getSentinelConfig() != null) {
+            return new JedisConnectionFactory(getSentinelConfig(), clientConfiguration);
+        }
+        if (getClusterConfiguration() != null) {
+            return new JedisConnectionFactory(getClusterConfiguration(),
+                    clientConfiguration);
+        }
+        return new JedisConnectionFactory(getStandaloneConfig(), clientConfiguration);
+    }
+
+    private JedisClientConfiguration getJedisClientConfiguration() {
+        JedisClientConfiguration.JedisClientConfigurationBuilder builder = applyProperties(
+                JedisClientConfiguration.builder());
+        RedisProperties.Pool pool = this.properties.getJedis().getPool();
+        if (pool != null) {
+            applyPooling(pool, builder);
+        }
+        if (StringUtils.hasText(this.properties.getUrl())) {
+            customizeConfigurationFromUrl(builder);
+        }
+        customize(builder);
+        return builder.build();
+    }
+
+    private JedisClientConfiguration.JedisClientConfigurationBuilder applyProperties(
+            JedisClientConfiguration.JedisClientConfigurationBuilder builder) {
+        if (this.properties.isSsl()) {
+            builder.useSsl();
+        }
+        if (this.properties.getTimeout() != null) {
+            Duration timeout = this.properties.getTimeout();
+            builder.readTimeout(timeout).connectTimeout(timeout);
+        }
+        return builder;
+    }
+
+    private void applyPooling(RedisProperties.Pool pool,
+                              JedisClientConfiguration.JedisClientConfigurationBuilder builder) {
+        builder.usePooling().poolConfig(jedisPoolConfig(pool));
+    }
+
+    private JedisPoolConfig jedisPoolConfig(RedisProperties.Pool pool) {
+        JedisPoolConfig config = new JedisPoolConfig();
+        config.setMaxTotal(pool.getMaxActive());
+        config.setMaxIdle(pool.getMaxIdle());
+        config.setMinIdle(pool.getMinIdle());
+        if (pool.getMaxWait() != null) {
+            config.setMaxWaitMillis(pool.getMaxWait().toMillis());
+        }
+        return config;
+    }
+
+    private void customizeConfigurationFromUrl(
+            JedisClientConfiguration.JedisClientConfigurationBuilder builder) {
+        RedisConnectionConfiguration.ConnectionInfo connectionInfo = parseUrl(this.properties.getUrl());
+        if (connectionInfo.isUseSsl()) {
+            builder.useSsl();
+        }
+    }
+
+    private void customize(
+            JedisClientConfiguration.JedisClientConfigurationBuilder builder) {
+        for (JedisClientConfigurationBuilderCustomizer customizer : this.builderCustomizers) {
+            customizer.customize(builder);
+        }
+    }
+
+
+}

+ 68 - 0
zen-core/src/main/java/cn/gygxzc/envir/core/redis/RedisAutoConfiguration.java

@@ -0,0 +1,68 @@
+package cn.gygxzc.envir.core.redis;
+
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cache.CacheManager;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+import java.text.SimpleDateFormat;
+
+/**
+ * Created by niantuo on 2018/11/1.
+ * redis 缓存配置
+ */
+@Configuration
+@ConditionalOnClass(RedisOperations.class)
+@EnableConfigurationProperties(RedisProperties.class)
+public class RedisAutoConfiguration {
+
+
+    @Primary
+    @Bean("redisCacheManager")
+    public CacheManager cacheManager(RedisConnectionFactory connectionFactory) {
+        return RedisCacheManager.create(connectionFactory);
+
+    }
+
+    @Primary
+    @Bean("redisTemplate")
+    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+        RedisTemplate<Object, Object> template = new RedisTemplate<>();
+        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+        template.setKeySerializer(stringRedisSerializer);
+        template.setHashKeySerializer(stringRedisSerializer);
+
+
+        ObjectMapper objectMapper = new ObjectMapper();
+        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
+        objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
+
+        GenericJackson2JsonRedisSerializer jsonRedisSerializer = new GenericJackson2JsonRedisSerializer(objectMapper);
+        template.setValueSerializer(jsonRedisSerializer);
+        template.setHashValueSerializer(jsonRedisSerializer);
+        template.setConnectionFactory(redisConnectionFactory);
+        return template;
+    }
+
+    @Bean
+    @Primary
+    public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+        StringRedisTemplate template = new StringRedisTemplate();
+        template.setConnectionFactory(redisConnectionFactory);
+        return template;
+    }
+
+
+}

+ 157 - 0
zen-core/src/main/java/cn/gygxzc/envir/core/redis/RedisConnectionConfiguration.java

@@ -0,0 +1,157 @@
+package cn.gygxzc.envir.core.redis;
+
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.data.redis.connection.*;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by niantuo on 2018/11/1.
+ * 完全的抄袭源代码
+ */
+
+public class RedisConnectionConfiguration {
+
+    private final RedisProperties properties;
+
+    private final RedisSentinelConfiguration sentinelConfiguration;
+
+    private final RedisClusterConfiguration clusterConfiguration;
+
+    protected RedisConnectionConfiguration(RedisProperties properties,
+                                           ObjectProvider<RedisSentinelConfiguration> sentinelConfigurationProvider,
+                                           ObjectProvider<RedisClusterConfiguration> clusterConfigurationProvider) {
+        this.properties = properties;
+        this.sentinelConfiguration = sentinelConfigurationProvider.getIfAvailable();
+        this.clusterConfiguration = clusterConfigurationProvider.getIfAvailable();
+    }
+
+    protected final RedisStandaloneConfiguration getStandaloneConfig() {
+        RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
+        if (StringUtils.hasText(this.properties.getUrl())) {
+            ConnectionInfo connectionInfo = parseUrl(this.properties.getUrl());
+            config.setHostName(connectionInfo.getHostName());
+            config.setPort(connectionInfo.getPort());
+            config.setPassword(RedisPassword.of(connectionInfo.getPassword()));
+        } else {
+            config.setHostName(this.properties.getHost());
+            config.setPort(this.properties.getPort());
+            config.setPassword(RedisPassword.of(this.properties.getPassword()));
+        }
+        config.setDatabase(this.properties.getDatabase());
+        return config;
+    }
+
+    protected final RedisSentinelConfiguration getSentinelConfig() {
+        if (this.sentinelConfiguration != null) {
+            return this.sentinelConfiguration;
+        }
+        RedisProperties.Sentinel sentinelProperties = this.properties.getSentinel();
+        if (sentinelProperties != null) {
+            RedisSentinelConfiguration config = new RedisSentinelConfiguration();
+            config.master(sentinelProperties.getMaster());
+            config.setSentinels(createSentinels(sentinelProperties));
+            if (this.properties.getPassword() != null) {
+                config.setPassword(RedisPassword.of(this.properties.getPassword()));
+            }
+            config.setDatabase(this.properties.getDatabase());
+            return config;
+        }
+        return null;
+    }
+
+    /**
+     * Create a {@link RedisClusterConfiguration} if necessary.
+     *
+     * @return {@literal null} if no cluster settings are set.
+     */
+    protected final RedisClusterConfiguration getClusterConfiguration() {
+        if (this.clusterConfiguration != null) {
+            return this.clusterConfiguration;
+        }
+        if (this.properties.getCluster() == null) {
+            return null;
+        }
+        RedisProperties.Cluster clusterProperties = this.properties.getCluster();
+        RedisClusterConfiguration config = new RedisClusterConfiguration(
+                clusterProperties.getNodes());
+        if (clusterProperties.getMaxRedirects() != null) {
+            config.setMaxRedirects(clusterProperties.getMaxRedirects());
+        }
+        if (this.properties.getPassword() != null) {
+            config.setPassword(RedisPassword.of(this.properties.getPassword()));
+        }
+        return config;
+    }
+
+    private List<RedisNode> createSentinels(RedisProperties.Sentinel sentinel) {
+        List<RedisNode> nodes = new ArrayList<>();
+        for (String node : sentinel.getNodes()) {
+            try {
+                String[] parts = StringUtils.split(node, ":");
+                Assert.state(parts.length == 2, "Must be defined as 'host:port'");
+                nodes.add(new RedisNode(parts[0], Integer.valueOf(parts[1])));
+            } catch (RuntimeException ex) {
+                throw new IllegalStateException(
+                        "Invalid redis sentinel " + "property '" + node + "'", ex);
+            }
+        }
+        return nodes;
+    }
+
+    protected ConnectionInfo parseUrl(String url) {
+        try {
+            URI uri = new URI(url);
+            boolean useSsl = (url.startsWith("rediss://"));
+            String password = null;
+            if (uri.getUserInfo() != null) {
+                password = uri.getUserInfo();
+                int index = password.indexOf(':');
+                if (index >= 0) {
+                    password = password.substring(index + 1);
+                }
+            }
+            return new ConnectionInfo(uri, useSsl, password);
+        } catch (URISyntaxException ex) {
+            throw new IllegalArgumentException("Malformed url '" + url + "'", ex);
+        }
+    }
+
+    protected static class ConnectionInfo {
+
+        private final URI uri;
+
+        private final boolean useSsl;
+
+        private final String password;
+
+        public ConnectionInfo(URI uri, boolean useSsl, String password) {
+            this.uri = uri;
+            this.useSsl = useSsl;
+            this.password = password;
+        }
+
+        public boolean isUseSsl() {
+            return this.useSsl;
+        }
+
+        public String getHostName() {
+            return this.uri.getHost();
+        }
+
+        public int getPort() {
+            return this.uri.getPort();
+        }
+
+        public String getPassword() {
+            return this.password;
+        }
+
+    }
+}

+ 1 - 1
zen-core/src/main/java/cn/gygxzc/tina/mvc/utils/HttpUtils.java → zen-core/src/main/java/cn/gygxzc/envir/core/utils/HttpUtils.java

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.mvc.utils;
+package cn.gygxzc.envir.core.utils;
 
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;

+ 8 - 0
zen-core/src/main/kotlin/cn/gygxzc/envir/core/CoreConfiguration.kt

@@ -0,0 +1,8 @@
+package cn.gygxzc.envir.core
+
+/**
+ * Created by niantuo on 2018/11/1.
+ */
+
+class CoreConfiguration {
+}

+ 1 - 1
zen-core/src/main/kotlin/cn/gygxzc/tina/cache/caffeine/CaffeineConfiguration.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/caffeine/CaffeineConfiguration.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.cache.caffeine
+package cn.gygxzc.envir.core.caffeine
 
 import com.github.benmanes.caffeine.cache.Caffeine
 import org.springframework.beans.factory.annotation.Autowired

+ 1 - 1
zen-core/src/main/kotlin/cn/gygxzc/tina/cache/caffeine/CaffeineProperties.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/caffeine/CaffeineProperties.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.cache.caffeine
+package cn.gygxzc.envir.core.caffeine
 
 import org.springframework.boot.context.properties.ConfigurationProperties
 import java.util.*

+ 1 - 1
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/Generator.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/Generator.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.orm
+package cn.gygxzc.envir.core.orm
 
 import com.baomidou.mybatisplus.annotation.DbType
 import com.baomidou.mybatisplus.generator.AutoGenerator

+ 3 - 4
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/MybatisPlusConfig.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/MybatisPlusConfig.kt

@@ -1,10 +1,9 @@
-package cn.gygxzc.tina.orm
+package cn.gygxzc.envir.core.orm
 
-import cn.gygxzc.tina.orm.handler.CustomMetaObjectHandler
-import cn.gygxzc.tina.orm.injector.LogicMoreSqlInjector
+import cn.gygxzc.envir.core.orm.handler.CustomMetaObjectHandler
+import cn.gygxzc.envir.core.orm.injector.LogicMoreSqlInjector
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
 import com.baomidou.mybatisplus.core.injector.ISqlInjector
-import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector
 import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
 import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor
 import org.springframework.context.annotation.Bean

+ 1 - 1
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/base/IPhysicalMapper.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/base/IPhysicalMapper.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.orm.base
+package cn.gygxzc.envir.core.orm.base
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper
 import com.baomidou.mybatisplus.core.metadata.IPage

+ 1 - 1
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/handler/CustomMetaObjectHandler.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/handler/CustomMetaObjectHandler.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.orm.handler
+package cn.gygxzc.envir.core.orm.handler
 
 import cn.gygxzc.tina.cloud.jwt.session.utils.SessionUtils
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/LogicMoreSqlInjector.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/LogicMoreSqlInjector.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector
+package cn.gygxzc.envir.core.orm.injector
 
-import cn.gygxzc.tina.orm.injector.method.*
+import cn.gygxzc.envir.core.orm.injector.method.*
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.injector.AbstractSqlInjector
 import com.baomidou.mybatisplus.core.injector.SqlRunnerInjector

+ 1 - 1
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/enums/SqlMethodCopy.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/enums/SqlMethodCopy.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.orm.injector.enums
+package cn.gygxzc.envir.core.orm.injector.enums
 
 /**
  * Created by niantuo on 2018/9/29.

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/Delete.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/Delete.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import org.apache.ibatis.mapping.MappedStatement

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteBatchIds.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/DeleteBatchIds.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import com.baomidou.mybatisplus.core.toolkit.Constants

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteById.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/DeleteById.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import org.apache.ibatis.mapping.MappedStatement

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteByMap.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/DeleteByMap.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import org.apache.ibatis.mapping.MappedStatement

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectById.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/SelectById.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import org.apache.ibatis.mapping.MappedStatement

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectList.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/SelectList.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import org.apache.ibatis.mapping.MappedStatement

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectPage.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/SelectPage.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import org.apache.ibatis.mapping.MappedStatement

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/Update.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/Update.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import com.baomidou.mybatisplus.core.toolkit.Constants

+ 2 - 2
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/UpdateById.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/orm/injector/method/UpdateById.kt

@@ -1,6 +1,6 @@
-package cn.gygxzc.tina.orm.injector.method
+package cn.gygxzc.envir.core.orm.injector.method
 
-import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import cn.gygxzc.envir.core.orm.injector.enums.SqlMethodCopy
 import com.baomidou.mybatisplus.core.injector.AbstractMethod
 import com.baomidou.mybatisplus.core.metadata.TableInfo
 import com.baomidou.mybatisplus.core.toolkit.Constants

+ 1 - 1
zen-core/src/main/kotlin/cn/gygxzc/tina/cache/redis/RedisKeyGenerator.kt → zen-core/src/main/kotlin/cn/gygxzc/envir/core/redis/RedisKeyGenerator.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.tina.cache.redis
+package cn.gygxzc.envir.core.redis
 
 /**
  * Redis key 生成器

+ 0 - 46
zen-core/src/main/kotlin/cn/gygxzc/tina/cache/redis/RedisConfig.kt

@@ -1,46 +0,0 @@
-package cn.gygxzc.tina.cache.redis
-
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
-import org.springframework.boot.autoconfigure.data.redis.RedisProperties
-import org.springframework.boot.context.properties.EnableConfigurationProperties
-import org.springframework.cache.CacheManager
-import org.springframework.cache.annotation.EnableCaching
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
-import org.springframework.context.annotation.Primary
-import org.springframework.data.redis.cache.RedisCacheManager
-import org.springframework.data.redis.connection.RedisConnectionFactory
-import org.springframework.data.redis.connection.RedisPassword
-import org.springframework.data.redis.connection.RedisStandaloneConfiguration
-import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
-
-/**
- * Redis 缓存配置
- * 缓存管理器
- * @author NorthLan
- * @date 2018/3/29
- * @url https://noahlan.com
- */
-@Configuration
-@EnableCaching
-@ConditionalOnProperty(prefix = "spring.cache", name = ["type"], havingValue = "redis")
-@EnableConfigurationProperties(RedisProperties::class)
-class RedisConfig {
-
-    @Bean
-    @Primary
-    fun connectFactory(properties: RedisProperties): LettuceConnectionFactory {
-        val configuration = RedisStandaloneConfiguration(properties.host, properties.port)
-        configuration.database = properties.database
-        configuration.password = RedisPassword.of(properties.password)
-        return LettuceConnectionFactory(configuration)
-    }
-
-
-    @Bean("redisCacheManager")
-    @Primary
-    fun cacheManager(redisConnectionFactory: RedisConnectionFactory): CacheManager {
-        return RedisCacheManager.create(redisConnectionFactory)
-    }
-
-}

+ 0 - 61
zen-core/src/main/kotlin/cn/gygxzc/tina/cache/redis/TinaJedisConnectionConfiguration.kt

@@ -1,61 +0,0 @@
-package cn.gygxzc.tina.cache.redis
-
-import com.fasterxml.jackson.annotation.JsonTypeInfo
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.springframework.beans.factory.annotation.Qualifier
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
-import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
-import org.springframework.boot.autoconfigure.data.redis.RedisProperties
-import org.springframework.boot.context.properties.EnableConfigurationProperties
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
-import org.springframework.data.redis.connection.RedisConnectionFactory
-import org.springframework.data.redis.core.RedisOperations
-import org.springframework.data.redis.core.RedisTemplate
-import org.springframework.data.redis.core.StringRedisTemplate
-import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
-import org.springframework.data.redis.serializer.StringRedisSerializer
-import org.springframework.util.StringUtils
-import java.text.SimpleDateFormat
-
-
-/**
- * Created by niantuo on 2018/9/20.
- */
-@Configuration
-@ConditionalOnClass(RedisOperations::class)
-@EnableConfigurationProperties(RedisProperties::class)
-class TinaJedisConnectionConfiguration {
-
-
-    @Bean
-    @ConditionalOnMissingBean(name = ["redisTemplate"])
-    fun redisTemplate(redisConnectionFactory: RedisConnectionFactory): RedisTemplate<Any, Any> {
-        val template = RedisTemplate<Any, Any>()
-        val stringRedisSerializer = StringRedisSerializer()
-        template.keySerializer = stringRedisSerializer
-        template.hashKeySerializer = stringRedisSerializer
-        // mapper
-        val classPropertyTypeName: String? = null
-        template.valueSerializer = GenericJackson2JsonRedisSerializer(ObjectMapper().apply {
-            dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
-            if (StringUtils.hasText(classPropertyTypeName)) {
-                enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.NON_FINAL, classPropertyTypeName)
-            } else {
-                enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY)
-            }
-        })
-        template.connectionFactory = redisConnectionFactory
-        return template
-    }
-
-    @Bean
-    @ConditionalOnMissingBean(StringRedisTemplate::class)
-    fun stringRedisTemplate(redisConnectionFactory: RedisConnectionFactory): StringRedisTemplate {
-        val template = StringRedisTemplate()
-        template.connectionFactory = redisConnectionFactory
-        return template
-    }
-
-}

+ 0 - 43
zen-core/src/main/kotlin/cn/gygxzc/tina/cros/CrosWebFilter.kt

@@ -1,43 +0,0 @@
-package cn.gygxzc.tina.cros
-
-import org.slf4j.LoggerFactory
-import org.springframework.http.HttpMethod
-import org.springframework.http.HttpStatus
-import org.springframework.stereotype.Component
-import org.springframework.web.server.ServerWebExchange
-import org.springframework.web.server.WebFilter
-import org.springframework.web.server.WebFilterChain
-import reactor.core.publisher.Mono
-
-/**
- * Created by niantuo on 2018/9/29.
- * 管理跨域问题的filter,正式项目中是不需要的,
- * 因为到业务子系统不会出现options请求了
- */
-@Component
-class CrosWebFilter : WebFilter {
-    private val logger = LoggerFactory.getLogger(CrosWebFilter::class.java)
-
-    override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
-
-        val httpRequest = exchange.request
-        val httpResponse = exchange.response
-        httpResponse.headers
-        httpResponse.headers.apply {
-            set("Access-control-Allow-Origin", httpRequest.headers["Origin"])
-            set("Access-Control-Allow-Methods", "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH")
-            set("Access-Control-Allow-Credentials", "true")
-            set("Access-Control-Allow-Headers", httpRequest.headers["Access-Control-Request-Headers"])
-            val method = httpRequest.method
-            if (method == HttpMethod.POST || method == HttpMethod.PUT) {
-                set("Access-Control-Expose-Headers", "Location")
-            } else if (method == HttpMethod.OPTIONS) {
-                httpResponse.statusCode = HttpStatus.OK
-                logger.info("options cros allow {}", httpRequest.path)
-                return httpResponse.setComplete()
-            }
-        }
-        logger.info("cros allow {}", httpRequest.path)
-        return chain.filter(exchange)
-    }
-}

+ 1 - 1
zen-core/src/main/kotlin/com/gxzc/zen/common/base/BaseModel.kt

@@ -1,6 +1,6 @@
 package com.gxzc.zen.common.base
 
-import cn.gygxzc.tina.orm.base.BaseModel
+import cn.gygxzc.envir.core.base.BaseModel
 import com.baomidou.mybatisplus.annotation.*
 import com.fasterxml.jackson.annotation.JsonInclude
 import io.swagger.annotations.ApiModelProperty

+ 1 - 1
zen-core/src/main/kotlin/com/gxzc/zen/common/util/RedisCacheUtil.kt

@@ -1,6 +1,6 @@
 package com.gxzc.zen.common.util
 
-import cn.gygxzc.tina.cache.redis.RedisKeyGenerator
+import cn.gygxzc.envir.core.redis.RedisKeyGenerator
 import org.springframework.cache.Cache
 import org.springframework.cache.CacheManager
 import kotlin.reflect.KClass

+ 5 - 2
zen-web/src/main/kotlin/cn/gygxzc/envir/MainApplication.kt

@@ -1,11 +1,13 @@
 package cn.gygxzc.envir
 
+import cn.gygxzc.cloud.tina.auth.EnableTinaAuth
 import cn.gygxzc.cloud.tina.fastdfs.client.EnableFastDFSClient
 import cn.gygxzc.tina.cloud.bus.EnableRabbitMessage
 import cn.gygxzc.tina.cloud.jwt.session.EnableJwtSpringRedisSession
 import org.mybatis.spring.annotation.MapperScan
 import org.springframework.boot.SpringApplication
 import org.springframework.boot.autoconfigure.SpringBootApplication
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
 import org.springframework.boot.builder.SpringApplicationBuilder
 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient
@@ -14,12 +16,13 @@ import org.springframework.cloud.openfeign.EnableFeignClients
 /**
  * 注解配置
  */
-@EnableDiscoveryClient
+@EnableTinaAuth
 @EnableFeignClients
 @EnableFastDFSClient
 @EnableRabbitMessage
+@EnableDiscoveryClient
 @EnableJwtSpringRedisSession
-@SpringBootApplication(scanBasePackages = ["cn.gygxzc.envir", "com.gxzc"])
+@SpringBootApplication(scanBasePackages = ["cn.gygxzc.envir", "com.gxzc"], exclude = [RedisAutoConfiguration::class])
 @MapperScan(basePackages = ["cn.gygxzc.**.dao", "cn.gygxzc.**.mapper"])
 class MainApplication : SpringBootServletInitializer() {
 

+ 1 - 1
zen-web/src/main/resources/bootstrap.yml

@@ -7,7 +7,7 @@ spring:
     name: framework
   profiles:
     active: dev
-    include: orm,cache,msg,fdfs
+    include: orm,cache,msg
   cloud:
     config:
       profile: dev