Explorar o código

分环境配置.

NorthLan %!s(int64=6) %!d(string=hai) anos
pai
achega
94581e183e

+ 2 - 2
zen-web/build.gradle

@@ -1,5 +1,5 @@
-// apply plugin: 'jar'
-apply plugin: 'war'
+//apply plugin: 'jar'
+//apply plugin: 'war'
 
 buildscript {
     repositories {

+ 19 - 11
zen-web/src/main/kotlin/com/gxzc/zen/orm/CustomMetaObjectHandler.kt

@@ -20,20 +20,28 @@ class CustomMetaObjectHandler : MetaObjectHandler() {
     }
 
     override fun insertFill(metaObject: MetaObject?) {
-        val curUser = SSOUtil.getCurAccount()
-        logger.debug("公共字段自动填充: insertFill $curUser")
-        if (getFieldValByName("createBy", metaObject) == null) {
-            setFieldValByName("createBy", curUser, metaObject)
-        }
-        if (getFieldValByName("createTime", metaObject) == null) {
-            setFieldValByName("createTime", Date(), metaObject)
+        try {
+            val curUser = SSOUtil.getCurAccount()
+            logger.trace("公共字段自动填充: insertFill $curUser")
+            if (getFieldValByName("createBy", metaObject) == null) {
+                setFieldValByName("createBy", curUser, metaObject)
+            }
+            if (getFieldValByName("createTime", metaObject) == null) {
+                setFieldValByName("createTime", Date(), metaObject)
+            }
+        } catch (e: Throwable) {
+            logger.warn("insertFill error, cause: ", e)
         }
     }
 
     override fun updateFill(metaObject: MetaObject?) {
-        val curUser = SSOUtil.getCurAccount()
-        logger.debug("公共字段自动填充: updateFill $curUser")
-        setFieldValByName("updateBy", curUser, metaObject)
-        setFieldValByName("updateTime", Date(), metaObject)
+        try {
+            val curUser = SSOUtil.getCurAccount()
+            logger.trace("公共字段自动填充: updateFill $curUser")
+            setFieldValByName("updateBy", curUser, metaObject)
+            setFieldValByName("updateTime", Date(), metaObject)
+        } catch (e: Throwable) {
+            logger.warn("updateFill error, cause: ", e)
+        }
     }
 }

+ 0 - 0
zen-web/src/main/resources/application-cache.yml → zen-web/src/main/resources/application-cache-dev.yml


+ 47 - 0
zen-web/src/main/resources/application-cache-prod.yml

@@ -0,0 +1,47 @@
+############## cache 配置 ##############
+spring:
+  cache:
+    type: redis # 使用什么作为缓存框架
+    # type: caffeine
+    caffeine:
+      spec:
+  redis:
+    database: 0 # redis数据库索引
+    host: 10.214.38.177
+    port: 6379
+    password:
+    timeout: 5000 # 连接超时时间(毫秒)
+    pool:
+      min-idle: 1 # 连接池中的最小空闲连接
+      max-idle: 20 # 连接池中的最大空闲连接
+      max-active: 20 # 连接池最大连接数(使用负值表示没有限制)
+      max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
+
+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}
+      user: # cache name
+        initialCapacity: -1 # 初始化容量 默认-1
+        maximumSize: 100 # 最大容量
+      user_perm: # cache name
+        initialCapacity: -1 # 初始化容量 默认-1
+        maximumSize: 100 # 最大容量
+      user_role: # cache name
+        initialCapacity: -1 # 初始化容量 默认-1
+        maximumSize: 100 # 最大容量
+      sys: # cache name
+        initialCapacity: -1 # 初始化容量 默认-1
+        maximumSize: 128 # 最大容量]

+ 0 - 0
zen-web/src/main/resources/application-job.yml → zen-web/src/main/resources/application-job-dev.yml


+ 12 - 0
zen-web/src/main/resources/application-job-prod.yml

@@ -0,0 +1,12 @@
+xxl:
+  job:
+    enable: false
+    admin:
+      address: http://127.0.0.1:8090
+    executor:
+      appname: xxl-job-sys
+      ip: 0.0.0.0
+      port: 10001
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: -1
+    accessToken:

+ 0 - 0
zen-web/src/main/resources/application-mq.yml → zen-web/src/main/resources/application-mq-dev.yml


+ 16 - 0
zen-web/src/main/resources/application-mq-prod.yml

@@ -0,0 +1,16 @@
+spring:
+  rabbitmq:
+    enable: false
+    host: localhost
+    port: 5672
+    username: admin
+    password: admin
+    publisher-confirms: true
+    publisher-returns: true
+    template:
+      mandatory: true
+    listener:
+      simple:
+        concurrency: 2 # 最小消息监听线程数
+        max-concurrency: 2 # 最大消息监听线程数
+    virtual-host: /

+ 0 - 0
zen-web/src/main/resources/application-orm-mycat.yml → zen-web/src/main/resources/application-orm-mycat-dev.yml


+ 38 - 0
zen-web/src/main/resources/application-orm-mycat-prod.yml

@@ -0,0 +1,38 @@
+################## Alibaba Druid 配置 ##################
+spring:
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    druid:
+      stat-view-servlet:
+        enabled: true
+        login-username: root
+        login-password: root
+        reset-enable: false
+      test-on-borrow: true
+      test-on-return: false
+      test-while-idle: true
+    driver-class-name: com.mysql.jdbc.Driver
+    username: archives
+    password: archives
+    url: jdbc:mysql://10.214.38.177:8066/SYS?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&useSSL=false&zeroDateTimeBehavior=convertToNull
+# &useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
+
+###################  mybatis-plus配置  ###################
+mybatis-plus:
+  mapper-locations: classpath*:mapping/**/*.xml
+  type-aliases-package: com.gxzc.zen.api.sys.mapper,com.gxzc.zen.api.biz.mapper
+  global-config:
+    id-type: 0  #0:数据库ID自增   1:用户输入id  2:全局唯一id(IdWorker)  3:全局唯一ID(uuid)
+    db-column-underline: true
+    refresh-mapper: true
+    logic-delete-value: 0
+    logic-not-delete-value: 1
+    sql-injector: com.gxzc.zen.orm.sql.ZenSqlInjector # 自定义injector
+    meta-object-handler: com.gxzc.zen.orm.CustomMetaObjectHandler
+  configuration:
+    map-underscore-to-camel-case: true
+    cache-enabled: true #配置的缓存的全局开关
+    lazyLoadingEnabled: true #延时加载的开关
+    multipleResultSetsEnabled: true #延时加载一个属性时会加载该对象全部属性,否则按需加载属性
+    interceptors: com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor, com.baomidou.mybatisplus.plugins.PaginationInterceptor
+    # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #打印sql语句,调试用

+ 0 - 0
zen-web/src/main/resources/application-platform.yml → zen-web/src/main/resources/application-platform-dev.yml


+ 2 - 0
zen-web/src/main/resources/application-platform-prod.yml

@@ -0,0 +1,2 @@
+platform:
+  id: 1 # 平台ID (0:通用,1:系统,2:接收,3:保存,4:管理,5:利用,6:库存)

+ 0 - 0
zen-web/src/main/resources/application-rpc.yml → zen-web/src/main/resources/application-rpc-dev.yml


+ 20 - 0
zen-web/src/main/resources/application-rpc-prod.yml

@@ -0,0 +1,20 @@
+dubbo:
+  enabled: false
+  application:
+    name: zen-dubbo
+    id: zen-dubbo
+  scan:
+    base-packages: com.gxzc.zen.rpc.provider
+  protocol:
+    id: dubbo
+    name: dubbo
+    port: -1
+  registry:
+    address: 192.168.1.10:2181
+    protocol: zookeeper
+    client: curator
+    id: zen-reg
+  consumer:
+    check: false
+    lazy: true
+    timeout: 300000

+ 0 - 0
zen-web/src/main/resources/application-umps.yml → zen-web/src/main/resources/application-umps-dev.yml


+ 20 - 0
zen-web/src/main/resources/application-umps-prod.yml

@@ -0,0 +1,20 @@
+shiro:
+  redis:
+    database: 1 # redis数据库索引
+    host: 10.214.38.177
+    port: 6379
+    password:
+    timeout: 5000 # 连接超时时间(毫秒)
+    sessionPrefix: zen_s #
+    sessionTime: 604800 # 秒 7天
+    cachePrefix: zen_c
+    cacheTime: 604800 # s
+    pool:
+      min-idle: 1 # 连接池中的最小空闲连接
+      max-idle: 20 # 连接池中的最大空闲连接
+      max-active: 20 # 连接池最大连接数(使用负值表示没有限制)
+      max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
+
+spring:
+  session:
+    store-type: redis

+ 0 - 0
zen-web/src/main/resources/application-upload.yml → zen-web/src/main/resources/application-upload-dev.yml


+ 15 - 0
zen-web/src/main/resources/application-upload-prod.yml

@@ -0,0 +1,15 @@
+spring:
+  http:
+    multipart:
+      enabled: true
+      max-request-size: 50MB #最大请求大小
+      max-file-size: 25MB #最大文件大小
+      location: ${java.io.tmpdir}
+      file-size-threshold: 5MB
+
+# 自定义配置
+upload:
+  tmpPath: /tmp # 临时文件存放位置 默认 /tmp/zen
+  dataPath: /archives/upload
+  maxFileSize: 4294967296 # 单位 byte 为0表示无限制
+  chunkSize: 10485760 # 10*1024*1024 = 10MB

+ 41 - 10
zen-web/src/main/resources/application.yml

@@ -1,16 +1,43 @@
-################### 服务端 配置 ####################
+spring:
+  profiles:
+    active: dev
+---
+spring:
+  profiles: dev
+    include: orm-mycat-dev,rpc-dev,mq-dev,cache-dev,umps-dev,platform-dev,job-dev,upload-dev
+  http:
+    converters:
+      preferred-json-mapper: fastjson
+  aop:
+    proxy-target-class: true #false为启用jdk默认动态代理,true为cglib动态代理
+    auto: true
+  jackson:
+    deserialization:
+      fail-on-unknown-properties: false # 多余字段反序列化过滤
+  application:
+    name: Zen
+
 server:
   port: 8082
 
-################## 各种奇怪的开关 ###################
 zen:
   swagger-open: true # swagger-ui是否开启
 
-###################  spring配置  ###################
+logging:
+  level:
+    root: info
+    com.gxzc:
+      zen: debug
+      zen.umps.config: warn
+    com.xxl.job.core: warn
+    com.atomikos: warn
+  path: logs/
+  file: zen.log
+
+---
 spring:
-  profiles:
-    active: dev
-    include: orm-mycat,rpc,mq,cache,umps,platform,job,upload
+  profiles: prod
+    include: orm-mycat-prod,rpc-prod,mq-prod,cache-prod,umps-prod,platform-prod,job-prod,upload-prod
   http:
     converters:
       preferred-json-mapper: fastjson
@@ -23,15 +50,19 @@ spring:
   application:
     name: Zen
 
+server:
+  port: 8082 # 生产环境端口号
+
+zen:
+  swagger-open: false # swagger-ui是否开启
+
 logging:
   level:
     root: info
     com.gxzc:
-      zen: debug
+      zen: warn
       zen.umps.config: warn
     com.xxl.job.core: warn
     com.atomikos: warn
   path: logs/
-  file: zen.log
-
-#debug: true
+  file: zen.log