# QAUP 生产环境配置
# 此配置将覆盖 application.yml 中的默认配置

# 服务器配置
server:
  port: 8080
  servlet:
    context-path: /
  tomcat:
    uri-encoding: UTF-8
    accept-count: 1000
    threads:
      max: 800
      min-spare: 100
    # 生产环境连接超时配置
    connection-timeout: 20000
    keep-alive-timeout: 60000

# 数据源配置
spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: org.postgresql.Driver
    druid:
      master:
        url: jdbc:postgresql://${DB_HOST:localhost}:${DB_PORT:5432}/${DB_NAME:qaup}?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai
        username: ${DB_USERNAME:qaup_app}
        password: ${DB_PASSWORD:qaup123}
      slave:
        enabled: false
      # 生产环境连接池配置
      initialSize: 10
      minIdle: 20
      maxActive: 100
      maxWait: 60000
      connectTimeout: 30000
      socketTimeout: 60000
      timeBetweenEvictionRunsMillis: 60000
      minEvictableIdleTimeMillis: 300000
      maxEvictableIdleTimeMillis: 900000
      validationQuery: SELECT version()
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      # 生产环境监控配置
      webStatFilter:
        enabled: false  # 生产环境关闭 Web 监控
      statViewServlet:
        enabled: false  # 生产环境关闭控制台
      filter:
        stat:
          enabled: true
          log-slow-sql: true
          slow-sql-millis: 2000
          merge-sql: true
        wall:
          config:
            multi-statement-allow: true

  # Redis 配置
  data:
    redis:
      host: ${REDIS_HOST:localhost}
      port: ${REDIS_PORT:6379}
      password: ${REDIS_PASSWORD:}
      database: 0
      timeout: 10s
      lettuce:
        pool:
          min-idle: 5
          max-idle: 20
          max-active: 50
          max-wait: -1ms

  # JPA 配置
  jpa:
    hibernate:
      ddl-auto: none
    show-sql: false
    properties:
      hibernate:
        format_sql: false
        jdbc:
          batch_size: 100
          fetch_size: 100
        cache:
          use_second_level_cache: false
          use_query_cache: false
        order_inserts: true
        order_updates: true
        batch_versioned_data: true

# 日志配置
logging:
  level:
    com.qaup: info
    org.springframework: warn
    org.hibernate: warn
    com.alibaba.druid: warn
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n"
    file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n"
  file:
    name: /app/logs/qaup.log
    max-size: 100MB
    max-history: 30

# 项目配置
qaup:
  name: QAUP
  version: 1.0.1
  copyrightYear: 2025
  profile: ${UPLOAD_PATH:/app/uploadPath}
  addressEnabled: false
  captchaType: math

# 用户配置
user:
  password:
    maxRetryCount: 5
    lockTime: 10

# Token 配置
token:
  header: Authorization
  secret: ${TOKEN_SECRET:abcdefghijklmnopqrstuvwxyz}
  expireTime: 30

# 管理端点配置
management:
  endpoints:
    web:
      exposure:
        include: ${MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE:health,info,metrics}
  endpoint:
    health:
      show-details: ${MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS:when_authorized}
  metrics:
    export:
      simple:
        enabled: true

# XSS 防护
xss:
  enabled: true
  excludes: /system/notice
  urlPatterns: /system/*,/monitor/*,/tool/*

# 数据采集配置
data:
  collector:
    interval: 250
    route:
      interval: 5000
    detection:
      interval: 1000
    airport-api:
      base-url: ${AIRPORT_API_BASE_URL:http://airport-api-server:8090}
      auth:
        username: ${AIRPORT_API_USERNAME:dianxin}
        password: ${AIRPORT_API_PASSWORD:dianxin@123}
    vehicle-api:
      base-url: ${VEHICLE_API_BASE_URL:http://vehicle-api-server:8090}
      timeout: 1000
      retry-attempts: 3
    unmanned-vehicle:
      persistence:
        enabled: true
        batch-size: 50
        location-retention-days: 90
        command-retention-days: 365
  retention:
    redis-expire-seconds: 60
    postgresql-days: 30

# 坐标系统配置
coordinate-system:
  airport:
    center-longitude: ${AIRPORT_CENTER_LONGITUDE:120.0834104}
    center-latitude: ${AIRPORT_CENTER_LATITUDE:36.35406879}