Browse Source

'修复mybatisplus物理删除问题'

tuonina 6 years ago
parent
commit
6b23cf5ce6
51 changed files with 829 additions and 591 deletions
  1. 1 1
      .gitignore
  2. 5 0
      c-docs/项目相关资料文档整理.md
  3. 0 0
      c-sql/archives_sys.sql
  4. 0 0
      c-sql/archives_xxl-job.sql
  5. 0 0
      docs/项目相关资料文档整理.md
  6. 16 0
      zen-api/src/main/java/cn/gygxzc/envir/test/dao/ITestLogDao.java
  7. 22 0
      zen-api/src/main/java/cn/gygxzc/envir/test/model/TestLog.java
  8. 39 0
      zen-api/src/main/java/cn/gygxzc/envir/test/service/ITestLogService.java
  9. 51 0
      zen-api/src/main/java/cn/gygxzc/envir/test/service/impl/TestLogService.java
  10. 0 40
      zen-api/src/main/kotlin/cn/gygxzc/envir/config/orm/MybatisPlusConfig.kt
  11. 0 81
      zen-api/src/main/kotlin/cn/gygxzc/envir/sys/model/SysUser.kt
  12. 18 0
      zen-api/src/main/resources/mapper/test/TestLogMapper.xml
  13. 23 23
      zen-core/src/main/kotlin/cn/gygxzc/tina/cache/caffeine/CaffeineConfiguration.kt
  14. 31 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/cache/caffeine/CaffeineProperties.kt
  15. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/tina/cros/CrosWebFilter.kt
  16. 1 1
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/Generator.kt
  17. 56 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/MybatisPlusConfig.kt
  18. 91 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/base/BaseModel.java
  19. 112 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/base/IPhysicalMapper.kt
  20. 4 1
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/handler/CustomMetaObjectHandler.kt
  21. 51 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/LogicMoreSqlInjector.kt
  22. 28 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/enums/SqlMethodCopy.kt
  23. 22 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/Delete.kt
  24. 23 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteBatchIds.kt
  25. 21 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteById.kt
  26. 20 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteByMap.kt
  27. 20 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectById.kt
  28. 20 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectList.kt
  29. 20 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectPage.kt
  30. 21 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/Update.kt
  31. 26 0
      zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/UpdateById.kt
  32. 1 1
      zen-core/src/main/kotlin/com/gxzc/zen/common/base/BaseController.kt
  33. 2 1
      zen-core/src/main/kotlin/com/gxzc/zen/common/base/BaseModel.kt
  34. 3 38
      zen-core/src/main/kotlin/com/gxzc/zen/common/base/IBaseMapper.kt
  35. 0 21
      zen-core/src/main/kotlin/com/gxzc/zen/common/config/FdfsConfig.kt
  36. 0 18
      zen-core/src/main/kotlin/com/gxzc/zen/common/config/cache/caffeine/CacheSpec.kt
  37. 1 4
      zen-core/src/main/kotlin/com/gxzc/zen/common/util/HttpUtil.kt
  38. 0 89
      zen-core/src/test/kotlin/com/gxzc/zen/TestFileChunks.kt
  39. 0 111
      zen-core/src/test/kotlin/com/gxzc/zen/TestTree.kt
  40. 0 39
      zen-core/src/test/kotlin/com/gxzc/zen/base/BaseTestKt.kt
  41. 0 70
      zen-core/src/test/kotlin/com/gxzc/zen/io/BufferedRandomAccessFileTest.kt
  42. 1 1
      zen-web/src/main/java/cn/gygxzc/envir/config/properties/SwaggerProperties.java
  43. 2 2
      zen-web/src/main/kotlin/cn/gygxzc/envir/MainApplication.kt
  44. 53 0
      zen-web/src/main/kotlin/cn/gygxzc/envir/api/test/controller/TestLogController.kt
  45. 1 1
      zen-web/src/main/kotlin/cn/gygxzc/envir/config/EnvirWebMvcConfiguration.kt
  46. 1 2
      zen-web/src/main/kotlin/cn/gygxzc/envir/config/SwaggerConfiguration.kt
  47. 0 14
      zen-web/src/main/kotlin/cn/gygxzc/envir/web/stomp/Stomp.kt
  48. 0 12
      zen-web/src/main/kotlin/cn/gygxzc/envir/web/websocket/Websocket.kt
  49. 15 15
      zen-web/src/main/resources/application-cache.yml
  50. 4 2
      zen-web/src/main/resources/application.yml
  51. 2 2
      zen-web/src/main/resources/bootstrap.yml

+ 1 - 1
.gitignore

@@ -137,7 +137,7 @@ log/
 logs/
 *.log
 *.log.*
-
+.log/
 
 # IntelliJ IDEA
 *.iml

+ 5 - 0
c-docs/项目相关资料文档整理.md

@@ -0,0 +1,5 @@
+# 基于Spring Cloud 的项目集成框架
+## 几个知识点
+### 服务注册中心Eureka
+### 服务配置中心 Spring Cloud Config Server
+### 消息总线 Spring Cloud Bus

+ 0 - 0
sql/archives_sys.sql → c-sql/archives_sys.sql


+ 0 - 0
sql/archives_xxl-job.sql → c-sql/archives_xxl-job.sql


+ 0 - 0
docs/项目相关资料文档整理.md


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

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

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

@@ -0,0 +1,22 @@
+package cn.gygxzc.envir.test.model;
+
+
+import cn.gygxzc.tina.orm.base.BaseModel;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+/**
+ * Created by niantuo on 2018/9/30.
+ * 测试用的数据库表模型
+ */
+@TableName(value = "test_log")
+public class TestLog extends BaseModel {
+    private String message;
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}

+ 39 - 0
zen-api/src/main/java/cn/gygxzc/envir/test/service/ITestLogService.java

@@ -0,0 +1,39 @@
+package cn.gygxzc.envir.test.service;
+
+import cn.gygxzc.envir.test.model.TestLog;
+
+/**
+ * Created by niantuo on 2018/9/30.
+ */
+
+public interface ITestLogService {
+
+    /**
+     * 添加数据
+     *
+     * @param log 添加数据
+     */
+    TestLog addLog(TestLog log);
+
+    /**
+     * 更新数据
+     *
+     * @param log 数据对象
+     */
+    void update(TestLog log);
+
+    /**
+     * 物理删除
+     *
+     * @param id 记录的id
+     */
+    void physicalDeleteById(long id);
+
+    /**
+     * 逻辑删除
+     *
+     * @param id 记录的id
+     */
+    void deleteById(long id);
+
+}

+ 51 - 0
zen-api/src/main/java/cn/gygxzc/envir/test/service/impl/TestLogService.java

@@ -0,0 +1,51 @@
+package cn.gygxzc.envir.test.service.impl;
+
+import cn.gygxzc.envir.test.dao.ITestLogDao;
+import cn.gygxzc.envir.test.model.TestLog;
+import cn.gygxzc.envir.test.service.ITestLogService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by niantuo on 2018/9/30.
+ */
+@Service
+public class TestLogService implements ITestLogService {
+    private final static Logger logger = LoggerFactory.getLogger(TestLogService.class);
+
+    private final ITestLogDao testLogDao;
+
+    @Autowired
+    public TestLogService(ITestLogDao testLogDao) {
+        this.testLogDao = testLogDao;
+    }
+
+
+    @Override
+    public TestLog addLog(TestLog log) {
+        int result = testLogDao.insert(log);
+        logger.info("add log  result:{},entity:{}", result, log);
+        return log;
+    }
+
+    @Override
+    public void update(TestLog log) {
+        int result = testLogDao.updateById(log);
+        logger.info("update result:{},entity:{}", result, log);
+    }
+
+    @Override
+    public void physicalDeleteById(long id) {
+        int result = testLogDao.physicalDeleteById(id);
+        logger.info("physicalDeleteById result:{}", result);
+
+    }
+
+    @Override
+    public void deleteById(long id) {
+        int result = testLogDao.deleteById(id);
+        logger.info("deleteById  result:{}", result);
+    }
+}

+ 0 - 40
zen-api/src/main/kotlin/cn/gygxzc/envir/config/orm/MybatisPlusConfig.kt

@@ -1,40 +0,0 @@
-package cn.gygxzc.envir.config.orm
-
-import cn.gygxzc.envir.config.orm.interceptor.CustomMetaObjectHandler
-import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
-import org.mybatis.spring.annotation.MapperScan
-import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
-
-/**
- *
- * @author NorthLan at 2018/1/30
- */
-@Configuration
-@MapperScan("com.gxzc.zen.api.*.mapper*")
-class MybatisPlusConfig {
-
-//    /**
-//     * 性能分析插件
-//     */
-//    @Bean
-//    @Profile("dev") // 开发环境开启
-//    fun performanceInterceptor(): PerformanceInterceptor {
-//        return PerformanceInterceptor().also { it.isFormat = true }
-//    }
-
-    /**
-     * 分页插件
-     */
-    @Bean
-    fun paginationInterceptor(): PaginationInterceptor {
-        return PaginationInterceptor()
-    }
-
-    @Bean
-    fun metaObjectHandler(): MetaObjectHandler {
-        return CustomMetaObjectHandler()
-    }
-
-}

+ 0 - 81
zen-api/src/main/kotlin/cn/gygxzc/envir/sys/model/SysUser.kt

@@ -1,81 +0,0 @@
-package cn.gygxzc.envir.sys.model
-
-import com.baomidou.mybatisplus.annotation.TableField
-import com.baomidou.mybatisplus.annotation.TableName
-import com.gxzc.zen.common.base.BaseModel
-
-/**
- * <p>
- * 用户管理
- * </p>
- *
- * @author NorthLan
- * @since 2018-04-27
- */
-@TableName("sys_user")
-open class SysUser : BaseModel() {
-    companion object {
-        private const val serialVersionUID = 1000000000000000002L
-    }
-
-    /**
-     * 登陆帐户
-     */
-    var account: String? = null
-    /**
-     * 姓名
-     */
-    var username: String? = null
-    /**
-     * 密码
-     */
-    var password: String? = null
-    /**
-     * 密码盐值
-     */
-    var salt: String? = null
-    /**
-     * 电话
-     */
-    var phone: String? = null
-    /**
-     * 邮箱
-     */
-    var email: String? = null
-    /**
-     * 职位
-     */
-    var position: String? = null
-    /**
-     * 详细地址
-     */
-    var address: String? = null
-    /**
-     * 工号
-     */
-    var staffNo: String? = null
-    /**
-     * 账号锁定(1.锁定;0.不锁定;)
-     */
-    var lock_: Boolean? = null
-    /**
-     * 备用字段
-     */
-    var ext1: String? = null
-    /**
-     * 备用字段
-     */
-    var ext2: String? = null
-    /**
-     * 备用字段
-     */
-    var ext3: String? = null
-    /**
-     * 备用字段
-     */
-    var ext4: String? = null
-    /**
-     * 性别,定义 1:男 0:女 -1:保密
-     */
-    var gender: Int? = null
-}

+ 18 - 0
zen-api/src/main/resources/mapper/test/TestLogMapper.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.gygxzc.envir.test.dao.ITestLogDao">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="cn.gygxzc.envir.test.model.TestLog">
+        <result column="id" property="id"/>
+        <result column="create_time" property="createTime"/>
+        <result column="create_by" property="createBy"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="update_by" property="updateBy"/>
+        <result column="enable" property="enable"/>
+        <result column="remark" property="remark"/>
+        <result column="message" property="message"/>
+    </resultMap>
+
+
+</mapper>

+ 23 - 23
zen-core/src/main/kotlin/com/gxzc/zen/common/config/cache/caffeine/CaffeineConfig.kt → zen-core/src/main/kotlin/cn/gygxzc/tina/cache/caffeine/CaffeineConfiguration.kt

@@ -1,28 +1,28 @@
-package com.gxzc.zen.common.config.cache.caffeine
+package cn.gygxzc.tina.cache.caffeine
 
 import com.github.benmanes.caffeine.cache.Caffeine
+import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
-import org.springframework.boot.context.properties.ConfigurationProperties
+import org.springframework.boot.context.properties.EnableConfigurationProperties
 import org.springframework.cache.CacheManager
-import org.springframework.cache.annotation.EnableCaching
 import org.springframework.cache.caffeine.CaffeineCache
 import org.springframework.cache.support.SimpleCacheManager
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
-import org.springframework.context.annotation.Primary
 import java.util.concurrent.TimeUnit
 
 /**
- * 缓存配置类
- * @author NorthLan at 2018/2/4
+ * Created by niantuo on 2018/9/29.
+ * caffeine 缓存配置
  */
+
 @Configuration
-@EnableCaching
-@ConfigurationProperties(prefix = "cache.caffeine")
-@ConditionalOnProperty(prefix = "cache.caffeine", name = ["enable"], havingValue = "true")
-class CaffeineConfig {
+@EnableConfigurationProperties(CaffeineProperties::class)
+@ConditionalOnProperty(prefix = "cache.caffeine", name = arrayOf("enable"), havingValue = "true")
+class CaffeineConfiguration {
 
-    var cacheSpecs: Map<String, CacheSpec>? = null
+    @Autowired
+    private lateinit var properties: CaffeineProperties
 
     @Bean("caffeineCacheManager")
     fun caffeineCacheManager(): CacheManager {
@@ -33,37 +33,37 @@ class CaffeineConfig {
 
     fun buildCache(): MutableCollection<CaffeineCache> {
         val collection = mutableListOf<CaffeineCache>()
-        cacheSpecs?.forEach { name, spec ->
+        properties.cacheSpec.forEach { name, spec ->
             run {
                 val builder = Caffeine.newBuilder().also {
-                    if (spec.initialCapacity >= 0) {
+                    if (spec.initialCapacity > 0) {
                         it.initialCapacity(spec.initialCapacity)
                     }
-                    if (spec.maximumSize >= 0) {
+                    if (spec.maximumSize > 0) {
                         it.maximumSize(spec.maximumSize)
                     }
-                    if (spec.maximumWeight >= 0) {
+                    if (spec.maximumWeight > 0) {
                         it.maximumWeight(spec.maximumWeight)
                     }
-                    if (spec.expireAfterAccess >= 0) {
+                    if (spec.expireAfterAccess > 0) {
                         it.expireAfterAccess(spec.expireAfterAccess, TimeUnit.SECONDS)
                     }
-                    if (spec.expireAfterWrite >= 0) {
+                    if (spec.expireAfterWrite > 0) {
                         it.expireAfterWrite(spec.expireAfterWrite, TimeUnit.SECONDS)
                     }
-                    if (spec.refreshAfterWrite >= 0) {
+                    if (spec.refreshAfterWrite > 0) {
                         it.refreshAfterWrite(spec.refreshAfterWrite, TimeUnit.SECONDS)
                     }
-                    if (spec.weakKeys) {
+                    if (spec.isWeakKeys) {
                         it.weakKeys()
                     }
-                    if (spec.weakValues) {
+                    if (spec.isWeakValues) {
                         it.weakValues()
                     }
-                    if (spec.softValues) {
+                    if (spec.isSoftValues) {
                         it.softValues()
                     }
-                    if (spec.recordStats) {
+                    if (spec.isRecordStats) {
                         it.recordStats()
                     }
                 }
@@ -72,4 +72,4 @@ class CaffeineConfig {
         }
         return collection
     }
-}
+}

+ 31 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/cache/caffeine/CaffeineProperties.kt

@@ -0,0 +1,31 @@
+package cn.gygxzc.tina.cache.caffeine
+
+import org.springframework.boot.context.properties.ConfigurationProperties
+import java.util.*
+
+/**
+ * Created by niantuo on 2018/9/29.
+ * caffeine 内存缓存配置
+ */
+@ConfigurationProperties(prefix = "cache.caffeine")
+class CaffeineProperties {
+
+    var enable = true
+    var cacheSpec = HashMap<String, CacheSpec>()
+
+    /**
+     * 缓存配置
+     */
+    class CacheSpec {
+        var initialCapacity: Int = 0
+        var maximumSize: Long = 0
+        var maximumWeight: Long = 0
+        var expireAfterAccess: Long = 0
+        var expireAfterWrite: Long = 0
+        var refreshAfterWrite: Long = 0
+        var isWeakKeys: Boolean = false
+        var isWeakValues: Boolean = false
+        var isSoftValues: Boolean = false
+        var isRecordStats: Boolean = false
+    }
+}

+ 1 - 1
zen-api/src/main/kotlin/cn/gygxzc/envir/config/filter/CrosWebFilter.kt → zen-core/src/main/kotlin/cn/gygxzc/tina/cros/CrosWebFilter.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.envir.config.filter
+package cn.gygxzc.tina.cros
 
 import org.slf4j.LoggerFactory
 import org.springframework.http.HttpMethod

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

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

+ 56 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/MybatisPlusConfig.kt

@@ -0,0 +1,56 @@
+package cn.gygxzc.tina.orm
+
+import cn.gygxzc.tina.orm.handler.CustomMetaObjectHandler
+import cn.gygxzc.tina.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
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Profile
+import org.springframework.transaction.annotation.EnableTransactionManagement
+
+/**
+ *
+ * @author NorthLan at 2018/1/30
+ * mybatis plus 配置
+ */
+@Configuration
+@EnableTransactionManagement
+class MybatisPlusConfig {
+
+
+    /**
+     * 并不会自动注入
+     */
+    @Bean
+    fun physicalSqlInjector(): ISqlInjector {
+        return LogicMoreSqlInjector()
+    }
+
+
+    /**
+     * 性能分析插件
+     */
+    @Bean
+    @Profile("dev") // 开发环境开启
+    fun performanceInterceptor(): PerformanceInterceptor {
+        return PerformanceInterceptor().also { it.isFormat = true }
+    }
+
+    /**
+     * 分页插件
+     */
+    @Bean
+    fun paginationInterceptor(): PaginationInterceptor {
+        return PaginationInterceptor()
+    }
+
+    @Bean
+    fun metaObjectHandler(): MetaObjectHandler {
+        return CustomMetaObjectHandler()
+    }
+
+}

+ 91 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/base/BaseModel.java

@@ -0,0 +1,91 @@
+package cn.gygxzc.tina.orm.base;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by niantuo on 2018/9/30.
+ * 数据库类的基类
+ */
+
+public class BaseModel implements Serializable {
+
+    public static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.ID_WORKER)
+    private Long id;
+    @TableLogic
+    private Boolean enable;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+    @TableField(fill = FieldFill.INSERT)
+    private String createBy;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @TableField(fill = FieldFill.UPDATE)
+    private Date updateTime;
+    @TableField(fill = FieldFill.UPDATE)
+    private String updateBy;
+
+    private String remark;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getCreateBy() {
+        return createBy;
+    }
+
+    public void setCreateBy(String createBy) {
+        this.createBy = createBy;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(String updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 112 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/base/IPhysicalMapper.kt

@@ -0,0 +1,112 @@
+package cn.gygxzc.tina.orm.base
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper
+import com.baomidou.mybatisplus.core.metadata.IPage
+import com.baomidou.mybatisplus.core.toolkit.Constants
+import org.apache.ibatis.annotations.Param
+import java.io.Serializable
+
+/**
+ * Created by niantuo on 2018/9/29.
+ * 实现物理操作的mapper基类
+ */
+
+interface IPhysicalMapper<T> {
+
+
+    /**
+     *
+     *
+     * 根据 entity 条件,删除记录
+     *
+     *
+     * @param queryWrapper 实体对象封装操作类(可以为 null)
+     */
+    fun physicalDelete(@Param(Constants.WRAPPER) queryWrapper: Wrapper<T>): Int
+
+    /**
+     *
+     *
+     * 根据 ID 删除
+     *
+     *
+     * @param id 主键ID
+     */
+    fun physicalDeleteById(id: Serializable): Int
+
+    /**
+     *
+     *
+     * 根据 columnMap 条件,删除记录
+     *
+     *
+     * @param columnMap 表字段 map 对象
+     */
+    fun physicalDeleteByMap(@Param(Constants.COLUMN_MAP) columnMap: Map<String, Any>): Int
+
+
+
+    /**
+     *
+     *
+     * 删除(根据ID 批量删除)
+     *
+     *
+     * @param idList 主键ID列表(不能为 null 以及 empty)
+     */
+    fun physicalDeleteBatchIds(@Param(Constants.COLLECTION) idList: Collection<Serializable>): Int
+
+    /**
+     *
+     *
+     * 根据 ID 修改
+     *
+     *
+     * @param entity 实体对象
+     */
+    fun physicalUpdateById(@Param(Constants.ENTITY) entity: T): Int
+
+    /**
+     *
+     *
+     * 根据 whereEntity 条件,更新记录
+     *
+     *
+     * @param entity        实体对象 (set 条件值,不能为 null)
+     * @param updateWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句)
+     */
+    fun physicalUpdate(@Param(Constants.ENTITY) entity: T, @Param(Constants.WRAPPER) updateWrapper: Wrapper<T>): Int
+
+    /**
+     *
+     *
+     * 根据 ID 查询
+     * 物理查询,忽略逻辑删除配置
+     *
+     * @param id 主键ID
+     */
+    fun physicalSelectById(id: Serializable): T
+
+
+    /**
+     *
+     *
+     * 根据 entity 条件,查询全部记录
+     *
+     *
+     * @param queryWrapper 实体对象封装操作类(可以为 null)
+     */
+    fun physicalsSelectList(@Param(Constants.WRAPPER) queryWrapper: Wrapper<T>): List<T>
+
+
+    /**
+     *
+     *
+     * 根据 entity 条件,查询全部记录(并翻页)
+     *
+     *
+     * @param page         分页查询条件(可以为 RowBounds.DEFAULT)
+     * @param queryWrapper 实体对象封装操作类(可以为 null)
+     */
+    fun physicalSelectPage(page: IPage<T>, @Param(Constants.WRAPPER) queryWrapper: Wrapper<T>): IPage<T>
+}

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

@@ -1,4 +1,4 @@
-package cn.gygxzc.envir.config.orm.interceptor
+package cn.gygxzc.tina.orm.handler
 
 import cn.gygxzc.tina.cloud.jwt.session.utils.SessionUtils
 import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
@@ -18,6 +18,9 @@ class CustomMetaObjectHandler : MetaObjectHandler {
         val logger = LoggerFactory.getLogger(CustomMetaObjectHandler::class.java)!!
     }
 
+    /**
+     * 公告字段插入的时候填充数据
+     */
     override fun insertFill(metaObject: MetaObject?) {
         try {
             if (getFieldValByName("createBy", metaObject) == null) {

+ 51 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/LogicMoreSqlInjector.kt

@@ -0,0 +1,51 @@
+package cn.gygxzc.tina.orm.injector
+
+import cn.gygxzc.tina.orm.injector.method.*
+import com.baomidou.mybatisplus.core.injector.AbstractMethod
+import com.baomidou.mybatisplus.core.injector.AbstractSqlInjector
+import com.baomidou.mybatisplus.core.injector.SqlRunnerInjector
+import com.baomidou.mybatisplus.core.injector.methods.Insert
+import com.baomidou.mybatisplus.extension.injector.methods.*
+import org.apache.ibatis.session.Configuration
+
+/**
+ * Created by niantuo on 2018/9/29.
+ * 注入器
+ */
+
+class LogicMoreSqlInjector : AbstractSqlInjector() {
+
+    override fun getMethodList(): MutableList<AbstractMethod> {
+        return mutableListOf(
+                Insert(),
+                LogicDelete(),
+                LogicDeleteByMap(),
+                LogicDeleteById(),
+                LogicDeleteBatchByIds(),
+                LogicUpdate(),
+                LogicUpdateById(),
+                LogicSelectById(),
+                LogicSelectBatchByIds(),
+                LogicSelectByMap(),
+                LogicSelectOne(),
+                LogicSelectCount(),
+                LogicSelectMaps(),
+                LogicSelectMapsPage(),
+                LogicSelectObjs(),
+                LogicSelectList(),
+                LogicSelectPage(),
+                Delete(),
+                DeleteBatchIds(),
+                DeleteById(),
+                DeleteByMap(),
+                SelectById(),
+                SelectList(),
+                SelectPage(),
+                Update(),
+                UpdateById())
+    }
+
+    override fun injectSqlRunner(configuration: Configuration?) {
+        SqlRunnerInjector().inject(configuration)
+    }
+}

+ 28 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/enums/SqlMethodCopy.kt

@@ -0,0 +1,28 @@
+package cn.gygxzc.tina.orm.injector.enums
+
+/**
+ * Created by niantuo on 2018/9/29.
+ * 所以实际上这个是从mybatis-plus复制过来的,好尴尬呀
+ * @see com.baomidou.mybatisplus.core.enums.SqlMethod
+ */
+
+enum class SqlMethodCopy(val method:String,val desc:String,val sql:String) {
+
+    /**
+     * 删除
+     */
+    DELETE_BY_ID("physicalDeleteById", "根据ID 删除一条数据", "<script>\nDELETE FROM %s WHERE %s=#{%s}\n</script>"),
+    DELETE_BY_MAP("physicalDeleteByMap", "根据columnMap 条件删除记录", "<script>\nDELETE FROM %s %s\n</script>"),
+    DELETE("physicalDelete", "根据 entity 条件删除记录", "<script>\nDELETE FROM %s %s\n</script>"),
+    DELETE_BATCH_BY_IDS("physicalDeleteBatchIds", "根据ID集合,批量删除数据", "<script>\nDELETE FROM %s WHERE %s IN (%s)\n</script>"),
+
+    SELECT_BY_ID("physicalSelectById", "根据ID 查询一条数据", "SELECT %s FROM %s WHERE %s=#{%s}"),
+    SELECT_PAGE("physicalSelectPage", "查询满足条件所有数据(并翻页)", "<script>\nSELECT %s FROM %s %s\n</script>"),
+    SELECT_LIST("physicalsSelectList", "查询满足条件所有数据", "<script>\nSELECT %s FROM %s %s\n</script>"),
+
+    /**
+     * 修改
+     */
+    UPDATE_BY_ID("physicalUpdateById", "根据ID 选择修改数据", "<script>\nUPDATE %s %s WHERE %s=#{%s} %s\n</script>"),
+    UPDATE("physicalUpdate", "根据 whereEntity 条件,更新记录", "<script>\nUPDATE %s %s %s\n</script>"),
+}

+ 22 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/Delete.kt

@@ -0,0 +1,22 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import com.baomidou.mybatisplus.core.injector.AbstractMethod
+import com.baomidou.mybatisplus.core.metadata.TableInfo
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ * 在逻辑删除的大环境下实现物理删除
+ */
+
+class Delete : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.DELETE
+        val sql = String.format(sqlMethod.sql, tableInfo.tableName,
+                sqlWhereEntityWrapper(tableInfo))
+        val sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass)
+        return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.method, sqlSource)
+    }
+
+}

+ 23 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteBatchIds.kt

@@ -0,0 +1,23 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.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
+import com.baomidou.mybatisplus.core.toolkit.StringPool
+import com.baomidou.mybatisplus.core.toolkit.sql.SqlScriptUtils
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class DeleteBatchIds : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.DELETE_BATCH_BY_IDS
+        val sql = String.format(sqlMethod.sql, tableInfo.tableName, tableInfo.keyColumn,
+                SqlScriptUtils.convertForeach("#{item}", Constants.COLLECTION, null, "item", StringPool.COMMA))
+        val sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass)
+        return this.addDeleteMappedStatement(mapperClass, sqlMethod.method, sqlSource)
+    }
+}

+ 21 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteById.kt

@@ -0,0 +1,21 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import com.baomidou.mybatisplus.core.injector.AbstractMethod
+import com.baomidou.mybatisplus.core.metadata.TableInfo
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class DeleteById : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.DELETE_BY_ID
+        val sqlSource = languageDriver.createSqlSource(configuration, String.format(sqlMethod.sql,
+                tableInfo.tableName, tableInfo.keyColumn, tableInfo.keyProperty), modelClass)
+        return this.addDeleteMappedStatement(mapperClass, sqlMethod.method, sqlSource)
+    }
+
+
+}

+ 20 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/DeleteByMap.kt

@@ -0,0 +1,20 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import com.baomidou.mybatisplus.core.injector.AbstractMethod
+import com.baomidou.mybatisplus.core.metadata.TableInfo
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class DeleteByMap : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.DELETE_BY_MAP
+        val sqlSource = languageDriver.createSqlSource(configuration, String.format(sqlMethod.sql,
+                tableInfo.tableName, this.sqlWhereByMap(tableInfo)), modelClass)
+        return this.addDeleteMappedStatement(mapperClass, sqlMethod.method, sqlSource)
+    }
+
+}

+ 20 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectById.kt

@@ -0,0 +1,20 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import com.baomidou.mybatisplus.core.injector.AbstractMethod
+import com.baomidou.mybatisplus.core.metadata.TableInfo
+import org.apache.ibatis.mapping.MappedStatement
+import org.apache.ibatis.scripting.defaults.RawSqlSource
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class SelectById : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.SELECT_BY_ID
+        val sqlSource = RawSqlSource(configuration, String.format(sqlMethod.sql, this.sqlSelectColumns(tableInfo, false),
+                tableInfo.tableName, tableInfo.keyColumn, tableInfo.keyProperty), Any::class.java)
+        return this.addSelectMappedStatement(mapperClass, sqlMethod.method, sqlSource, modelClass, tableInfo)
+    }
+}

+ 20 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectList.kt

@@ -0,0 +1,20 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import com.baomidou.mybatisplus.core.injector.AbstractMethod
+import com.baomidou.mybatisplus.core.metadata.TableInfo
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class SelectList : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.SELECT_LIST
+        val sql = String.format(sqlMethod.sql, sqlSelectColumns(tableInfo, true),
+                tableInfo.tableName, this.sqlWhereEntityWrapper(tableInfo))
+        val sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass)
+        return this.addSelectMappedStatement(mapperClass, sqlMethod.method, sqlSource, modelClass, tableInfo)
+    }
+}

+ 20 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/SelectPage.kt

@@ -0,0 +1,20 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.orm.injector.enums.SqlMethodCopy
+import com.baomidou.mybatisplus.core.injector.AbstractMethod
+import com.baomidou.mybatisplus.core.metadata.TableInfo
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class SelectPage : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.SELECT_PAGE
+        val sql = String.format(sqlMethod.sql, sqlSelectColumns(tableInfo, true),
+                tableInfo.tableName, this.sqlWhereEntityWrapper(tableInfo))
+        val sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass)
+        return this.addSelectMappedStatement(mapperClass, sqlMethod.method, sqlSource, modelClass, tableInfo)
+    }
+}

+ 21 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/Update.kt

@@ -0,0 +1,21 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.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
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class Update : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.UPDATE
+        val sql = String.format(sqlMethod.sql, tableInfo.tableName,
+                sqlSet(false, true, tableInfo, Constants.ENTITY_SPOT), sqlWhereEntityWrapper(tableInfo))
+        val sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass)
+        return this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.method, sqlSource)
+    }
+}

+ 26 - 0
zen-core/src/main/kotlin/cn/gygxzc/tina/orm/injector/method/UpdateById.kt

@@ -0,0 +1,26 @@
+package cn.gygxzc.tina.orm.injector.method
+
+import cn.gygxzc.tina.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
+import org.apache.ibatis.mapping.MappedStatement
+
+/**
+ * Created by niantuo on 2018/9/29.
+ */
+
+class UpdateById : AbstractMethod() {
+    override fun injectMappedStatement(mapperClass: Class<*>, modelClass: Class<*>, tableInfo: TableInfo): MappedStatement {
+        val sqlMethod = SqlMethodCopy.UPDATE_BY_ID
+        val sql = String.format(sqlMethod.sql, tableInfo.tableName,
+                sqlSet(false, false, tableInfo, Constants.ENTITY_SPOT),
+                tableInfo.keyColumn, Constants.ENTITY_SPOT + tableInfo.keyProperty,
+                StringBuilder("<if test=\"et instanceof java.util.Map\">")
+                        .append("<if test=\"et.MP_OPTLOCK_VERSION_ORIGINAL!=null\">")
+                        .append(" AND \${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}")
+                        .append("</if></if>"))
+        val sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass)
+        return addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.method, sqlSource)
+    }
+}

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

@@ -19,7 +19,7 @@ open class BaseController {
         return HttpUtil.getRequest()
     }
 
-    fun getResponse(): HttpServletResponse {
+    fun getResponse(): HttpServletResponse? {
         return HttpUtil.getResponse()
     }
 }

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

@@ -10,6 +10,7 @@ import java.util.*
  * 通用实体 包含通用字段
  * @author NorthLan at 2017/12/8
  */
+@Deprecated("移到另一个包下,cn.gygxzc.tina.orm.base")
 @JsonInclude(JsonInclude.Include.ALWAYS) // jackson 所有
 open class BaseModel : Serializable {
     companion object {
@@ -17,7 +18,7 @@ open class BaseModel : Serializable {
     }
 
     // 主键
-    @TableId(type = IdType.AUTO)
+    @TableId(type = IdType.ID_WORKER)
     var id: Long? = null
 
     // 创建时间

+ 3 - 38
zen-core/src/main/kotlin/com/gxzc/zen/common/base/IBaseMapper.kt

@@ -1,10 +1,6 @@
 package com.gxzc.zen.common.base
 
-import com.baomidou.mybatisplus.core.conditions.Wrapper
 import com.baomidou.mybatisplus.core.mapper.BaseMapper
-import org.apache.ibatis.annotations.Param
-import org.apache.ibatis.session.RowBounds
-import java.io.Serializable
 
 /**
  * 通用的DAO
@@ -12,38 +8,7 @@ import java.io.Serializable
  * @author NorthLan
  * @date 2018/1/24
  * @url https://noahlan.com
+ * @see cn.gygxzc.tina.orm.base.IPhysicalMapper
  */
-interface IBaseMapper<T> : BaseMapper<T> {
-
-
-    /**
-     * 通过自定义SQL查询
-     * 忽略 全局 逻辑删除
-     */
-    fun selectWOLogic(@Param("ew") wrapper: Wrapper<T>?): MutableList<T>
-
-    /**
-     * 自定义SQL查询 分页
-     * 忽略 全局 逻辑删除
-     */
-    fun selectWOLogicPage(rowBounds: RowBounds, @Param("ew") wrapper: Wrapper<T>?): MutableList<T>
-
-    /**
-     * 自定义更新逻辑 更新enable字段时使用
-     * 忽略 全局 逻辑删除
-     * 自动生成sql,无需在xml中写入sql
-     */
-    fun updateWOLogic(@Param("et") entity: T, @Param("ew") wrapper: Wrapper<T>): Long
-
-    /**
-     * 物理删除
-     * 自动生成sql,无需在xml中写入sql
-     */
-    fun physicalDelete(@Param("ew") wrapper: Wrapper<T>): Long
-
-    /**
-     * 物理删除 By ID
-     * 自动生成sql,无需在xml中写入sql
-     */
-    fun physicalDeleteById(id: Serializable): Long
-}
+@Deprecated("该类已启用,请直接继续BaseMapper,如果需要物理删除")
+interface IBaseMapper<T> : BaseMapper<T>

+ 0 - 21
zen-core/src/main/kotlin/com/gxzc/zen/common/config/FdfsConfig.kt

@@ -1,21 +0,0 @@
-package com.gxzc.zen.common.config
-
-import com.github.tobato.fastdfs.FdfsClientConfig
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
-import org.springframework.context.annotation.Configuration
-import org.springframework.context.annotation.EnableMBeanExport
-import org.springframework.context.annotation.Import
-import org.springframework.jmx.support.RegistrationPolicy
-
-/**
- *
- * @author NorthLan
- * @date 2018/8/29
- * @url https://noahlan.com
- */
-@Configuration
-@Import(FdfsClientConfig::class)
-@ConditionalOnProperty(prefix = "fdfs", name = ["enabled"], havingValue = "true")
-@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
-class FdfsConfig {
-}

+ 0 - 18
zen-core/src/main/kotlin/com/gxzc/zen/common/config/cache/caffeine/CacheSpec.kt

@@ -1,18 +0,0 @@
-package com.gxzc.zen.common.config.cache.caffeine
-
-/**
- * 缓存配置数据类
- * @author NorthLan at 2018/2/4
- */
-data class CacheSpec(
-        var initialCapacity: Int = -1,
-        var maximumSize: Long = -1,
-        var maximumWeight: Long = -1,
-        var expireAfterAccess: Long = -1,
-        var expireAfterWrite: Long = -1,
-        var refreshAfterWrite: Long = -1,
-        var weakKeys: Boolean = false,
-        var weakValues: Boolean = false,
-        var softValues: Boolean = false,
-        var recordStats: Boolean = false
-)

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

@@ -1,6 +1,5 @@
 package com.gxzc.zen.common.util
 
-import org.slf4j.LoggerFactory
 import org.springframework.web.context.request.RequestContextHolder
 import org.springframework.web.context.request.ServletRequestAttributes
 import javax.servlet.http.HttpServletRequest
@@ -11,13 +10,11 @@ import javax.servlet.http.HttpServletResponse
  * @author NorthLan at 2018/2/8
  */
 object HttpUtil {
-    private val logger = LoggerFactory.getLogger(HttpUtil::class.java)
-
     fun getRequest(): HttpServletRequest {
         return (RequestContextHolder.getRequestAttributes() as ServletRequestAttributes).request
     }
 
-    fun getResponse(): HttpServletResponse {
+    fun getResponse(): HttpServletResponse? {
         return (RequestContextHolder.getRequestAttributes() as ServletRequestAttributes).response
     }
 

+ 0 - 89
zen-core/src/test/kotlin/com/gxzc/zen/TestFileChunks.kt

@@ -1,89 +0,0 @@
-package com.gxzc.zen
-
-import com.gxzc.zen.common.util.FileUtil
-import org.apache.commons.io.FilenameUtils
-import org.junit.Test
-import java.nio.ByteBuffer
-
-
-/**
- *
- * @author NorthLan
- * @date 2018/5/24
- * @url https://noahlan.com
- */
-class TestFileChunks {
-
-    /**
-     * 测试文件md5生成
-     * 选取文件 头尾chunk 和 最后修改日期 结合生成md5
-     * chunkSize = 10 * 1024 * 1024 = 10MB
-     */
-    @Test
-    fun testFileChunkMd5() {
-        val chunkSize = 10 * 1024 * 1024
-        val path = "D:\\data\\HBuilder.8.9.1.windows.zip"
-        println(FileUtil.md5HeadTail(path, chunkSize))
-    }
-
-    @Test
-    fun longLength() {
-        println(java.lang.Long.SIZE / 8)
-    }
-
-    @Test
-    fun longToBytes() {
-        val buffer = ByteBuffer.allocate(8)
-        buffer.putLong(1501841794418L)
-//        buffer.flip()
-        val byteArray = buffer.array()
-        byteArray.reverse()
-        buffer.clear()
-    }
-
-    @Test
-    fun testRegex() {
-        val a = "C:\\Users\\Test\\a"
-        val b = "\\Users\\Test\\b"
-        val c = "/Users/Test/c"
-        val d = "//Users/Test/d"
-
-        val regex = "^[\\\\/]+"
-
-        println(a.replace(Regex(regex), ""))
-        println(b.replace(Regex(regex), ""))
-        println(c.replace(Regex(regex), ""))
-        println(d.replace(Regex(regex), ""))
-
-        println(getDestFilePath("niubi.pdf", "niubi.pdf", null))
-
-        val e = "D:\\data\\\\a.exe"
-        println(FilenameUtils.normalize(e))
-    }
-
-    /**
-     * 生成 文件夹结构
-     */
-    fun getDestFilePath(filename: String, relativePath: String, repath: String?): String {
-        return repath?.replace(Regex("^[\\\\/]+"), "")?.replace("/", FILE_SEPARATOR)?.replace("\\", FILE_SEPARATOR)
-                ?: relativePath.replace(filename, "").replace("/", FILE_SEPARATOR).replace("\\", FILE_SEPARATOR)
-    }
-
-    private val FILE_SEPARATOR = System.getProperty("file.separator") // 适配操作系统的文件路径
-
-    @Test
-    fun testFor() {
-        for (i in 1..10) {
-            println(i)
-        }
-    }
-
-    @Test
-    fun testExt() {
-        println(FilenameUtils.normalize("/d/d.exe"))
-        println(FilenameUtils.normalize("d/d.exe"))
-        println(FilenameUtils.normalize("/d.exe"))
-        println(FilenameUtils.normalize("//d.exe"))
-        println(FilenameUtils.normalize("d.exe"))
-    }
-}

+ 0 - 111
zen-core/src/test/kotlin/com/gxzc/zen/TestTree.kt

@@ -1,111 +0,0 @@
-package com.gxzc.zen
-
-import com.fasterxml.jackson.databind.ObjectMapper
-import com.gxzc.zen.common.util.TreeUtil
-import com.gxzc.zen.common.util.common.TreeNode
-import org.junit.Test
-
-/**
- *
- * @author NorthLan
- * @date 2018/4/28
- * @url https://noahlan.com
- */
-class TestTree {
-
-    private fun buildData(): MutableList<TreeNode> {
-        return mutableListOf<TreeNode>().apply {
-            add(TreeNode().apply {
-                id = 1
-                parentId = 0
-            })
-            add(TreeNode().apply {
-                id = 2
-                parentId = 1
-            })
-            add(TreeNode().apply {
-                id = 3
-                parentId = 1
-            })
-            add(TreeNode().apply {
-                id = 4
-                parentId = 2
-            })
-            add(TreeNode().apply {
-                id = 5
-                parentId = 4
-            })
-            add(TreeNode().apply {
-                id = 6
-                parentId = 4
-            })
-            add(TreeNode().apply {
-                id = 7
-                parentId = 4
-            })
-            add(TreeNode().apply {
-                id = 8
-                parentId = 4
-            })
-            add(TreeNode().apply {
-                id = 9
-                parentId = 4
-            })
-            add(TreeNode().apply {
-                id = 10
-                parentId = 4
-            })
-        }
-    }
-
-    @Test
-    fun testTree() {
-        val data = buildData()
-
-        // 时间
-        val now = System.currentTimeMillis()
-
-        val tree = TreeUtil.build(data, 0)
-
-        val n = System.currentTimeMillis()
-        println("循环时间: ${n - now}")
-
-        val tree2 = TreeUtil.buildByRecursive(data, 0)
-
-        println("递归时间: ${System.currentTimeMillis() - n}")
-
-        println(ObjectMapper().writeValueAsString(tree))
-
-        println(ObjectMapper().writeValueAsString(tree2))
-
-        // 数据量小的情况 循环时间>递归时间
-    }
-
-    @Test
-    fun testTreeFind() {
-        val data = buildData()
-        val tree = TreeUtil.buildByRecursive(data, 0)
-
-        println(ObjectMapper().writeValueAsString(tree))
-
-
-        var now = System.currentTimeMillis()
-        val find = TreeUtil.findBFS(tree) {
-            it.id == 4L && it.parentId == 2L
-        }
-
-        println("BFS: ${System.currentTimeMillis() - now}")
-
-        println(ObjectMapper().writeValueAsString(find))
-
-        now = System.currentTimeMillis()
-        val find2 = TreeUtil.findDFS(tree) {
-            it.id == 4L && it.parentId == 2L
-        }
-
-        println("DFS: ${System.currentTimeMillis() - now}")
-
-
-        println(ObjectMapper().writeValueAsString(find2))
-    }
-}

+ 0 - 39
zen-core/src/test/kotlin/com/gxzc/zen/base/BaseTestKt.kt

@@ -1,39 +0,0 @@
-package com.gxzc.zen.base
-
-import org.junit.Before
-import org.junit.runner.RunWith
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.boot.test.context.SpringBootTest
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
-import org.springframework.test.context.web.WebAppConfiguration
-import org.springframework.test.web.servlet.MockMvc
-import org.springframework.test.web.servlet.setup.MockMvcBuilders
-import org.springframework.web.context.WebApplicationContext
-
-/**
- * Spring单元测试基类
- * @author NorthLan
- * @date 2018/1/26
- * @url https://noahlan.com
- */
-@RunWith(SpringJUnit4ClassRunner::class)
-@SpringBootTest
-@WebAppConfiguration
-//@Transactional  // 事物支持
-class BaseTestKt {
-
-    @Autowired
-    lateinit var webApplicationContext: WebApplicationContext
-
-    lateinit var mockMvc: MockMvc
-
-    @Before
-    fun setupMockMvc() {
-        mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build()
-    }
-
-    @Before
-    fun initDataBase() {
-        // Nothing
-    }
-}

+ 0 - 70
zen-core/src/test/kotlin/com/gxzc/zen/io/BufferedRandomAccessFileTest.kt

@@ -1,70 +0,0 @@
-package com.gxzc.zen.io
-
-import com.gxzc.zen.common.util.io.BufferedRandomAccessFile
-import org.junit.Test
-
-/**
- *
- * @author NorthLan
- * @date 2018/9/1
- * @url https://noahlan.com
- */
-class BufferedRandomAccessFileTest {
-
-    @Test
-    fun test() {
-        val readfilelen: Long
-        val brafReadFile = BufferedRandomAccessFile("D:\\gradle-4.9-bin.zip")
-        val brafWriteFile = BufferedRandomAccessFile("D:\\gradle-4.9-bin-bak.zip", "rw", 10)
-
-        readfilelen = brafReadFile.initfilelen
-
-        val buf = ByteArray(4096)
-        var readcount: Int = brafReadFile.read(buf)
-
-        var start = System.currentTimeMillis()
-
-        while (readcount != -1) {
-            brafWriteFile.write(buf, 0, readcount)
-            readcount = brafReadFile.read(buf)
-        }
-
-        brafWriteFile.close()
-        brafReadFile.close()
-
-        println("BufferedRandomAccessFile Copy & Write File: "
-                + brafReadFile.filename
-                + "    FileSize: "
-                + java.lang.Integer.toString(readfilelen.toInt() shr 4096)
-                + " (KB)    "
-                + "Spend: "
-                + (System.currentTimeMillis() - start).toDouble() / 1000
-                + "(s)")
-
-        val fdin = java.io.FileInputStream("D:\\gradle-4.9-bin.zip")
-        val bis = java.io.BufferedInputStream(fdin, 4096)
-        val dis = java.io.DataInputStream(bis)
-
-        val fdout = java.io.FileOutputStream("D:\\gradle-4.9-bin-bak2.zip")
-        val bos = java.io.BufferedOutputStream(fdout, 4096)
-        val dos = java.io.DataOutputStream(bos)
-
-        start = System.currentTimeMillis()
-
-        for (i in 0 until readfilelen) {
-            dos.write(dis.readByte().toInt())
-        }
-
-        dos.close()
-        dis.close()
-
-        println("DataBufferedios Copy & Write File: "
-                + brafReadFile.filename
-                + "    FileSize: "
-                + java.lang.Integer.toString(readfilelen.toInt() shr 4096)
-                + " (KB)    "
-                + "Spend: "
-                + (System.currentTimeMillis() - start).toDouble() / 1000
-                + "(s)")
-    }
-}

+ 1 - 1
zen-web/src/main/java/cn/gygxzc/config/properties/SwaggerProperties.java → zen-web/src/main/java/cn/gygxzc/envir/config/properties/SwaggerProperties.java

@@ -1,4 +1,4 @@
-package cn.gygxzc.config.properties;
+package cn.gygxzc.envir.config.properties;
 
 import org.springframework.boot.context.properties.ConfigurationProperties;
 

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

@@ -13,8 +13,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients
  */
 @EnableDiscoveryClient
 @EnableFeignClients
-@SpringBootApplication(scanBasePackages = ["com.gxzc", "cn.gygxzc"])
-@MapperScan(basePackages = ["cn.gygxzc.**.dao","cn.gygxzc.**.mapper"])
+@SpringBootApplication(scanBasePackages = ["cn.gygxzc", "com.gxzc"])
+@MapperScan(basePackages = ["cn.gygxzc.**.dao", "cn.gygxzc.**.mapper"])
 class MainApplication : SpringBootServletInitializer() {
 
 

+ 53 - 0
zen-web/src/main/kotlin/cn/gygxzc/envir/api/test/controller/TestLogController.kt

@@ -0,0 +1,53 @@
+package cn.gygxzc.envir.api.test.controller
+
+import cn.gygxzc.envir.test.model.TestLog
+import cn.gygxzc.envir.test.service.ITestLogService
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.web.bind.annotation.*
+
+/**
+ * Created by niantuo on 2018/9/30.
+ * 测试用的,正式打包将其注释掉
+ */
+@RestController
+@RequestMapping("/test/log")
+class TestLogController {
+
+    companion object {
+        private val logger = LoggerFactory.getLogger(TestLogController::class.java)
+    }
+
+    @Autowired
+    private lateinit var testLogService: ITestLogService
+
+    /**
+     * 添加数据
+     */
+    @PostMapping
+    fun add(@RequestBody log: TestLog) {
+        val result = testLogService.addLog(log)
+        logger.info("add result:{}", result)
+    }
+
+    /**
+     * 修改数据
+     */
+    @PutMapping
+    fun update(@RequestBody log: TestLog) {
+        val result = testLogService.update(log)
+        logger.info("add result:{}", result)
+    }
+
+    @DeleteMapping("/{id}")
+    fun deleteById(@PathVariable("id") id: Long) {
+        testLogService.deleteById(id)
+    }
+
+    @DeleteMapping("/physical/{id}")
+    fun physicalDeleteById(@PathVariable("id") id: Long) {
+        testLogService.physicalDeleteById(id)
+    }
+
+
+}

+ 1 - 1
zen-web/src/main/kotlin/cn/gygxzc/envir/web/config/EnvirWebMvcConfiguration.kt → zen-web/src/main/kotlin/cn/gygxzc/envir/config/EnvirWebMvcConfiguration.kt

@@ -1,4 +1,4 @@
-package cn.gygxzc.envir.web.config
+package cn.gygxzc.envir.config
 
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer
 import org.springframework.context.annotation.Bean

+ 1 - 2
zen-web/src/main/kotlin/cn/gygxzc/envir/web/config/SwaggerConfiguration.kt → zen-web/src/main/kotlin/cn/gygxzc/envir/config/SwaggerConfiguration.kt

@@ -1,10 +1,9 @@
-package cn.gygxzc.envir.web.config
+package cn.gygxzc.envir.config
 
 import io.swagger.annotations.ApiOperation
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
-import org.springframework.web.bind.annotation.RestController
 import springfox.documentation.builders.ApiInfoBuilder
 import springfox.documentation.builders.RequestHandlerSelectors
 import springfox.documentation.service.ApiInfo

+ 0 - 14
zen-web/src/main/kotlin/cn/gygxzc/envir/web/stomp/Stomp.kt

@@ -1,14 +0,0 @@
-package cn.gygxzc.envir.web.stomp
-
-/**
- * @program: Zen-Framework
- *
- * @description: ${description}
- *
- * @author: tuonina
- *
- * @create: 2018-09-20 22:32
- *
- * 一般与前端给基于stomp协议,这样的话更方便些
- *
- **/

+ 0 - 12
zen-web/src/main/kotlin/cn/gygxzc/envir/web/websocket/Websocket.kt

@@ -1,12 +0,0 @@
-package cn.gygxzc.envir.web.websocket
-
-/**
- * @program: Zen-Framework
- *
- * @description: ${description}
- *
- * @author: tuonina
- *
- * @create: 2018-09-20 22:33
- * 同时也支持websocket协议吧,都配置起来
- **/

+ 15 - 15
zen-web/src/main/resources/application-cache.yml

@@ -1,19 +1,19 @@
 cache:
   caffeine:
-  ################ cache配置说明 以下配置均为默认值(不填即默认) #######################
-  # initialCapacity: -1 # 初始化容量 默认-1
-  # maximumSize: -1 # 最大容量 默认-1 超出部分TinyLfu移除
-  # maximumWeight: -1 # 最大权重,与maximumSize冲突
-  # expireAfterAccess: -1 # 最后一次写入或访问后经过固定时间过期 以expireAfterWrite为准
-  # expireAfterWrite: -1 # 最后一次写入后经过固定时间过期
-  # refreshAfterWrite: -1 # 创建缓存或者最近一次更新缓存后经过固定的时间间隔刷新缓存
-  # recordStats: false # 开发统计功能
-  # weakKeys: false # 该key是否为弱引用
-  # weakValues: false # 该key对应的values是否为弱引用 与softValues冲突
-  # softValues: false # 该key对应的values是否为软引用
-  #################################################################################
-    enable: false
-    cache-specs: # see also {CaffeineSpec}
+    ################ cache配置说明 以下配置均为默认值(不填即默认) #######################
+    # initialCapacity: -1 # 初始化容量 默认-1
+    # maximumSize: -1 # 最大容量 默认-1 超出部分TinyLfu移除
+    # maximumWeight: -1 # 最大权重,与maximumSize冲突
+    # expireAfterAccess: -1 # 最后一次写入或访问后经过固定时间过期 以expireAfterWrite为准
+    # expireAfterWrite: -1 # 最后一次写入后经过固定时间过期
+    # refreshAfterWrite: -1 # 创建缓存或者最近一次更新缓存后经过固定的时间间隔刷新缓存
+    # recordStats: false # 开发统计功能
+    # weakKeys: false # 该key是否为弱引用
+    # weakValues: false # 该key对应的values是否为弱引用 与softValues冲突
+    # softValues: false # 该key对应的values是否为软引用
+    #################################################################################
+    enable: true
+    cache-spec: # see also {CaffeineSpec}
       user: # cache name
         initialCapacity: -1 # 初始化容量 默认-1
         maximumSize: 100 # 最大容量
@@ -25,4 +25,4 @@ cache:
         maximumSize: 100 # 最大容量
       sys: # cache name
         initialCapacity: -1 # 初始化容量 默认-1
-        maximumSize: 128 # 最大容量]
+        maximumSize: 128 # 最大容量]

+ 4 - 2
zen-web/src/main/resources/application.yml

@@ -1,11 +1,13 @@
 
+# 数据库配置暂时卸载项目中,后期会全部移到配置中心去。
+
 ---
 spring:
   profiles: dev
   datasource:
     username: root
     password: tuonina
-    url: jdbc:mysql://192.168.1.206:3307/envir_sys?useInformationSchema=true&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
+    url: jdbc:mysql://192.168.1.206:3307/envir_test?useInformationSchema=true&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
 # &useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
 
 swagger:
@@ -17,7 +19,7 @@ spring:
   datasource:
     username: root
     password: tuonina
-    url: jdbc:mysql://192.168.1.206:3307/archives_sys?useInformationSchema=true&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
+    url: jdbc:mysql://192.168.1.206:3307/envir_test?useInformationSchema=true&autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
 # &useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
 
 swagger:

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

@@ -7,14 +7,14 @@ spring:
     name: framework
   profiles:
     active: dev
-    include:  orm,cache,msg
+    include: cache
   cloud:
     config:
       profile: dev
       discovery:
         enabled: true
         service-id: messager
-      allow-override: false
+      allow-override: true