
# mysql 个性化配置， 不同的环境，需要配置不同的链接信息，只需要将这段信息复制到具体环境的配置文件中进行修改即可
# 如：复制到zuihou-authority-server-dev.yml中将数据库名和ip改掉
zuihou:
  mysql:
    ip: 127.0.0.1
    port: 3306
    driverClassName: com.mysql.cj.jdbc.Driver
    database: zuihou_defaults
    username: root
    password: root
    url: jdbc:mysql://${zuihou.mysql.ip}:${zuihou.mysql.port}/${zuihou.mysql.database}?serverTimezone=CTT&characterEncoding=utf8&useUnicode=true&useSSL=false&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&nullCatalogMeansCurrent=true
  database: # 字段介绍参考 DatabaseProperties
    tenantDatabasePrefix: zuihou_base
    multiTenantType: SCHEMA
    isNotWrite: false
    isBlockAttack: false
    isSeata: false
    id-type: CACHE
    cache-id:
      time-bits: 31
      worker-bits: 22
      seq-bits: 10
      epochStr: '2020-09-15'
      boost-power: 3
      padding-factor: 50

# mysql 通用配置
spring:
  autoconfigure:
    exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
  datasource:
    dynamic:
      enabled: false  # 这里一定要写成false，无论是什么模式
      # 从这里开始(dynamic)，中间的这段配置用于 zuihou.database.multiTenantType == DATASOURCE 时
      # DATASOURCE模式 联系群主购买开通
      # 从这里结束(dynamic)，中间的这段配置用于 zuihou.database.multiTenantType == DATASOURCE 时
    druid:
      enable: true
      # 从这里开始(druid)，中间的这段配置用于 zuihou.database.multiTenantType != DATASOURCE 时
      username: ${zuihou.mysql.username}
      password: ${zuihou.mysql.password}
      driver-class-name: ${zuihou.mysql.driverClassName}
      url: jdbc:mysql://${zuihou.mysql.ip}:${zuihou.mysql.port}/${zuihou.mysql.database}?serverTimezone=CTT&characterEncoding=utf8&useUnicode=true&useSSL=false&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&nullCatalogMeansCurrent=true
      db-type: mysql
      initialSize: 10
      minIdle: 10
      maxActive: 200
      max-wait: 60000
      pool-prepared-statements: true
      max-pool-prepared-statement-per-connection-size: 20
      validation-query: SELECT 'x'
      test-on-borrow: false
      test-on-return: false
      test-while-idle: true
      time-between-eviction-runs-millis: 60000  #配置间隔多久才进行一次检测，检测需要关闭的空闲连接，单位是毫秒
      min-evictable-idle-time-millis: 300000    #配置一个连接在池中最小生存的时间，单位是毫秒
      filters: stat,wall
      filter:
        wall:
          enabled: true
          config:
            commentAllow: true
            multiStatementAllow: true
            noneBaseStatementAllow: true
      # 从这里结束(druid)，中间的这段配置用于 zuihou.database.multiTenantType != DATASOURCE 时

      # 以下的2段配置，同时适用于所有模式
      web-stat-filter:  # WebStatFilter配置，说明请参考Druid Wiki，配置_配置WebStatFilter
        enabled: true
        url-pattern: /*
        exclusions: "*.js , *.gif ,*.jpg ,*.png ,*.css ,*.ico , /druid/*"
        session-stat-max-count: 1000
        profile-enable: true
        session-stat-enable: false
      stat-view-servlet:  #展示Druid的统计信息,StatViewServlet的用途包括：1.提供监控信息展示的html页面2.提供监控信息的JSON API
        enabled: true
        url-pattern: /druid/*   #根据配置中的url-pattern来访问内置监控页面，如果是上面的配置，内置监控页面的首页是/druid/index.html例如：http://127.0.0.1:9000/druid/index.html
        reset-enable: true    #允许清空统计数据
        login-username: zuihou
        login-password: zuihou


mybatis-plus:
  mapper-locations:
    - classpath*:mapper_**/**/*Mapper.xml
  #实体扫描，多个package用逗号或者分号分隔
  typeAliasesPackage: com.github.zuihou.*.entity;com.github.zuihou.database.mybatis.typehandler
  typeEnumsPackage: com.github.zuihou.*.enumeration
  global-config:
    db-config:
      id-type: INPUT
      insert-strategy: NOT_NULL
      update-strategy: NOT_NULL
      select-strategy: NOT_EMPTY
  configuration:
    #配置返回数据库(column下划线命名&&返回java实体是驼峰命名)，自动匹配无需as（没开启这个，SQL需要写as： select user_id as userId）
    map-underscore-to-camel-case: true
    cache-enabled: false
    #配置JdbcTypeForNull, oracle数据库必须配置
    jdbc-type-for-null: 'null'

# 分布式事务相关
seata:
  enabled: ${zuihou.database.isSeata}
  enableAutoDataSourceProxy: true
  tx-service-group: zuihou_admin_seata_tx_group
  registry:
    type: nacos
    nacos:
      server-addr: ${zuihou.nacos.ip}:${zuihou.nacos.port}
      username: ${zuihou.nacos.username}
      password: ${zuihou.nacos.password}
      namespace: ${zuihou.seata.namespace}
  config:
    type: nacos
    nacos:
      server-addr: ${zuihou.nacos.ip}:${zuihou.nacos.port}
      username: ${zuihou.nacos.username}
      password: ${zuihou.nacos.password}
      namespace: ${zuihou.seata.namespace}
  service:
    grouplist:
      default: ${zuihou.seata.ip:}:${zuihou.seata.port:}
    vgroup-mapping:
      zuihou_admin_seata_tx_group: default
    disable-global-transaction: false
  client:
    rm:
      report-success-enable: false
