# 生产环境配置
server:
  port: 8086
  servlet:
    context-path: /customer
  compression:
    enabled: true
    mime-types: application/json,application/xml,text/html,text/xml,text/plain
    min-response-size: 1024
  error:
    include-message: never
    include-stacktrace: never
    propagate: false

spring:
  application:
    name: customer-service
  
  # 数据源配置（生产环境应使用Vault或K8s Secrets）
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://${DB_HOST:mysql}:3306/${DB_NAME:erp_java}?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai&requireSSL=true
    username: ${DB_USERNAME:erp_user}
    password: ${DB_PASSWORD}
    hikari:
      connection-timeout: 30000
      maximum-pool-size: 50
      minimum-idle: 10
      idle-timeout: 600000
      max-lifetime: 1800000
      leak-detection-threshold: 60000
      pool-name: CustomerServiceHikariPool
  
  # Redis配置（生产环境应使用Vault或K8s Secrets）
  redis:
    host: ${REDIS_HOST:redis}
    port: ${REDIS_PORT:6379}
    password: ${REDIS_PASSWORD}
    database: ${REDIS_DB:0}
    timeout: 5000ms
    lettuce:
      pool:
        max-active: 100
        max-idle: 50
        min-idle: 10
        max-wait: 3000ms
      shutdown-timeout: 100ms
  
  # MyBatis配置
  mybatis-plus:
    configuration:
      map-underscore-to-camel-case: true
      log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
    global-config:
      db-config:
        logic-delete-field: deletedAt
        id-type: auto
  
  # Nacos配置
  cloud:
    nacos:
      discovery:
        server-addr: ${NACOS_HOST:nacos}:8848
        namespace: ${NACOS_NAMESPACE:prod}
        group: DEFAULT_GROUP
        enabled: true
      config:
        server-addr: ${NACOS_HOST:nacos}:8848
        file-extension: yaml
        group: DEFAULT_GROUP
        namespace: ${NACOS_NAMESPACE:prod}
        enabled: true

# Actuator监控配置
management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
      base-path: /actuator
  endpoint:
    health:
      show-details: when_authorized
      probes:
        enabled: true
  metrics:
    export:
      prometheus:
        enabled: true
    tags:
      application: ${spring.application.name}
  health:
    redis:
      enabled: true
    db:
      enabled: true

# 日志配置
logging:
  level:
    root: INFO
    com.erp.customer: INFO
    org.springframework.security: WARN
    org.springframework.web: WARN
    org.springframework.data.redis: WARN
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
    file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level [%X{traceId:-},%X{spanId:-}] %logger{50} - %msg%n"
  file:
    name: /app/logs/customer-service.log
    max-size: 100MB
    max-history: 30
    total-size-cap: 3GB

# 服务配置
service:
  customer:
    overdue-followup-days: 7
    vip-default-limit: 10
