Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	zen-admin/src/main/kotlin/com/gxzc/zen/ExampleController.kt
#	zen-admin/src/main/kotlin/com/gxzc/zen/MainApplication.kt
#	zen-admin/src/main/resources/application.yml
#	zen-api/src/main/kotlin/com/gxzc/zen/sys/dao/TSysUserMapper.kt
#	zen-api/src/main/kotlin/com/gxzc/zen/sys/model/TSysUser.kt
#	zen-api/src/main/kotlin/com/gxzc/zen/sys/service/TSysUserService.kt
#	zen-common/src/main/kotlin/com/gxzc/zen/common/base/persistence/ZenBaseMapper.kt
#	zen-common/src/main/kotlin/com/gxzc/zen/common/base/persistence/ZenBaseModel.kt
#	zen-common/src/main/kotlin/com/gxzc/zen/common/base/persistence/ZenBaseService.kt
#	zen-orm/src/main/kotlin/com/gxzc/zen/Generator.kt
NorthLan 7 years ago
parent
commit
d36511bd13

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

@@ -1,10 +1,12 @@
+
 server:
   port: 8081
 
-#druid配置
+
+###################  druid配置  ###################
 druid:
   view:
-#    enable: false
+    enable: false
     username: root
     password: 123456
     slowSql: true

+ 1 - 1
zen-common/src/main/java/com/gxzc/zen/plug/Encodes.java → zen-common/src/main/java/com/gxzc/zen/common/plug/Encodes.java

@@ -1,7 +1,7 @@
 /**
  * Copyright (c) 2005-2012 springside.org.cn
  */
-package com.gxzc.zen.plug;
+package com.gxzc.zen.common.plug;
 
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.binary.Base64;

+ 1 - 1
zen-common/src/main/java/com/gxzc/zen/plug/IdGen.java → zen-common/src/main/java/com/gxzc/zen/common/plug/IdGen.java

@@ -1,7 +1,7 @@
 /**
  * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
  */
-package com.gxzc.zen.plug;
+package com.gxzc.zen.common.plug;
 
 import java.security.SecureRandom;
 import java.util.UUID;

+ 1 - 1
zen-common/src/main/kotlin/com/gxzc/zen/persistence/BaseMapper.kt → zen-common/src/main/kotlin/com/gxzc/zen/common/base/persistence/BaseMapper.kt

@@ -1,4 +1,4 @@
-package com.gxzc.zen.persistence
+package com.gxzc.zen.common.base.persistence
 
 import com.baomidou.mybatisplus.mapper.BaseMapper
 

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

@@ -1,4 +1,4 @@
-package com.gxzc.zen.persistence
+package com.gxzc.zen.common.base.persistence
 
 import com.baomidou.mybatisplus.annotations.TableField
 import com.baomidou.mybatisplus.annotations.TableId

+ 1 - 1
zen-common/src/main/kotlin/com/gxzc/zen/persistence/BaseService.kt → zen-common/src/main/kotlin/com/gxzc/zen/common/base/persistence/BaseService.kt

@@ -1,4 +1,4 @@
-package com.gxzc.zen.persistence
+package com.gxzc.zen.common.base.persistence
 
 import com.baomidou.mybatisplus.service.IService
 

+ 67 - 68
zen-config/src/main/kotlin/com/gxzc/zen/config/DruidConfig.kt

@@ -5,6 +5,7 @@ import com.alibaba.druid.support.http.StatViewServlet
 import com.alibaba.druid.support.http.WebStatFilter
 import org.mybatis.spring.annotation.MapperScan
 import org.slf4j.LoggerFactory
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
 import org.springframework.boot.context.properties.ConfigurationProperties
 import org.springframework.boot.web.servlet.FilterRegistrationBean
 import org.springframework.boot.web.servlet.ServletRegistrationBean
@@ -17,100 +18,98 @@ import javax.sql.DataSource
 @Configuration
 @ConfigurationProperties(prefix = "druid.datasource-sys")
 @MapperScan(basePackages = ["com.gxzc.zen.sys"])
-class SysDruidConfig:DruidConfig()
+open class SysDruidConfig : DruidConfig()
 
 
-
-
-
-/*-----------------druid数据源bean注册 */
+/**
+ * druid数据源bean注册
+ */
 open class DruidConfig {
-    var url:String?=null
-    var username:String?=null
-    var password:String?=null
-    var filters:String?=null
+    var url: String? = null
+    var username: String? = null
+    var password: String? = null
+    var filters: String? = null
 
-    var driverClassName:String?="com.mysql.jdbc.Driver"
-    var initialSize:Int?=5
-    var minIdle:Int?=5
-    var maxActive:Int?=20
-    var maxWait:Long?=60000
+    var driverClassName: String? = "com.mysql.jdbc.Driver"
+    var initialSize: Int = 5
+    var minIdle: Int = 5
+    var maxActive: Int = 20
+    var maxWait: Long = 60000
 
-    var timeBetweenEvictionRunsMillis:Long?=null
-    var minEvictableIdleTimeMillis:Long?=null
-    var validationQuery:String?=null
-    var testWhileIdle:Boolean?=null
-    var testOnBorrow:Boolean?=null
-    var testOnReturn:Boolean?=null
+    var timeBetweenEvictionRunsMillis: Long = 60000
+    var minEvictableIdleTimeMillis: Long = 30000
+    var validationQuery: String? = null
+    var testWhileIdle: Boolean = true
+    var testOnBorrow: Boolean = false
+    var testOnReturn: Boolean = false
 
-    private val logger= LoggerFactory.getLogger(javaClass)
+    private val logger = LoggerFactory.getLogger(javaClass)
 
-    private var datasource:DruidDataSource?=null
-
-//    private val name=nm
+    private var datasource: DruidDataSource? = null
 
     @Bean
-    open fun druidDataSource(): DataSource {
-        datasource = DruidDataSource()
-        datasource?.url = url
-        datasource?.username = username
-        datasource?.password = password
-        datasource?.driverClassName = driverClassName
-        datasource?.initialSize = initialSize!!
-        datasource?.minIdle = minIdle!!
-        datasource?.maxActive = maxActive!!
-        datasource?.maxWait = maxWait!!
-        datasource?.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis!!
-        datasource?.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis!!
-        datasource?.validationQuery = validationQuery!!
-        datasource?.isTestWhileIdle = testWhileIdle!!
-        datasource?.isTestOnBorrow = testOnBorrow!!
-        datasource?.isTestOnReturn = testOnReturn!!
+    open fun druidDataSource(): DataSource? {
+        datasource = DruidDataSource().also {
+            it.url = url
+            it.username = username
+            it.password = password
+            it.driverClassName = driverClassName
+            it.initialSize = initialSize
+            it.minIdle = minIdle
+            it.maxActive = maxActive
+            it.maxWait = maxWait
+            it.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis
+            it.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis
+            it.validationQuery = validationQuery
+            it.isTestWhileIdle = testWhileIdle
+            it.isTestOnBorrow = testOnBorrow
+            it.isTestOnReturn = testOnReturn
+        }
         try {
             datasource?.setFilters(filters)
         } catch (e: SQLException) {
             logger.error("druid configuration initialization filter", e)
         }
 
-        return datasource!!
+        return datasource
     }
 
-    fun getDatasource():DruidDataSource{
-        return datasource!!
+    fun getDatasource(): DruidDataSource? {
+        return datasource
     }
 }
 
-
-
-
-/*-----------------配置druid显示界面 */
+/**
+ * 配置druid显示界面
+ */
 @Configuration
 @ConfigurationProperties(prefix = "druid.view")
-class DruidViewConfig{
-    var username:String?=null
-    var password:String?=null
-    var slowsql:String?=null
+@ConditionalOnProperty(prefix = "druid.view", name = ["enable"], havingValue = "true", matchIfMissing = true)
+open class DruidViewConfig {
+    var username: String? = null
+    var password: String? = null
+    var slowSql: String? = null
 
     @Bean
-    fun druidServlet(): ServletRegistrationBean {
-//        if(!enable!!)return throw Exception()
-        val reg = ServletRegistrationBean()
-        reg.setServlet(StatViewServlet())
-        reg.addUrlMappings("/druid/*")
-        reg.addInitParameter("loginUsername", username)
-        reg.addInitParameter("loginPassword", password)
-        reg.addInitParameter("logSlowSql", slowsql)
-        return reg
+    @ConditionalOnProperty(prefix = "druid.view", name = ["enable"], havingValue = "true", matchIfMissing = true)
+    open fun druidServlet(): ServletRegistrationBean {
+        return ServletRegistrationBean().also {
+            it.setServlet(StatViewServlet())
+            it.addUrlMappings("/druid/*")
+            it.addInitParameter("loginUsername", username)
+            it.addInitParameter("loginPassword", password)
+            it.addInitParameter("logSlowSql", slowSql)
+        }
     }
 
     @Bean
-    fun filterRegistrationBean(): FilterRegistrationBean {
-//        if(!enable!!)return throw Exception()
-        val filterRegistrationBean = FilterRegistrationBean()
-        filterRegistrationBean.filter = WebStatFilter()
-        filterRegistrationBean.addUrlPatterns("/*")
-        filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*")
-        filterRegistrationBean.addInitParameter("profileEnable", "true")
-        return filterRegistrationBean
+    @ConditionalOnProperty(prefix = "druid.view", name = ["enable"], havingValue = "true", matchIfMissing = true)
+    open fun filterRegistrationBean(): FilterRegistrationBean {
+        return FilterRegistrationBean().also {
+            it.filter = WebStatFilter()
+            it.addUrlPatterns("/*")
+            it.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*")
+            it.addInitParameter("profileEnable", "true")
+        }
     }
 }

+ 9 - 0
zen-orm/src/main/kotlin/com/gxzc/zen/GeneratorMain.kt

@@ -0,0 +1,9 @@
+package com.gxzc.zen
+
+/**
+ * 代码生成器入口方法
+ * @author NorthLan at 2018/1/25
+ */
+fun main(args: Array<String>) {
+
+}