server:
  port: ${GATEWAY_PORT:8080}

spring:
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
          lower-case-service-id: true
      routes:
        # 认证服务
        - id: auth-service
          uri: lb://erp-auth
          predicates:
            - Path=/api/auth/**
          filters:
            - StripPrefix=1
            - name: RequestRateLimiter
              args:
                redis-rate-limiter.replenishRate: 100
                redis-rate-limiter.burstCapacity: 200
        # 用户服务
        - id: user-service
          uri: lb://erp-user
          predicates:
            - Path=/api/user/**
          filters:
            - StripPrefix=1
        # 订单服务
        - id: order-service
          uri: lb://erp-order
          predicates:
            - Path=/api/order/**
          filters:
            - StripPrefix=1
        # 商品服务
        - id: product-service
          uri: lb://erp-product
          predicates:
            - Path=/api/product/**
          filters:
            - StripPrefix=1
        # 仓库服务
        - id: warehouse-service
          uri: lb://erp-warehouse
          predicates:
            - Path=/api/warehouse/**
          filters:
            - StripPrefix=1
      default-filters:
        - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST

  redis:
    host: ${REDIS_HOST:localhost}
    port: ${REDIS_PORT:6379}
    password: ${REDIS_PASSWORD:}
    database: 0
    timeout: 3000ms
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 0
        max-wait: -1ms

  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8

# JWT配置
jwt:
  secret: ${JWT_SECRET:your-256-bit-secret-key-for-jwt-token-generation}
  expiration: 86400000  # 24小时
  header: Authorization
  prefix: Bearer

# Sentinel配置
sentinel:
  eager: true
  dashboard: ${SENTINEL_DASHBOARD:localhost:8080}

# 限流规则
gateway:
  rate-limit:
    enabled: true
    default-replenish-rate: 100
    default-burst-capacity: 200

# 日志配置
logging:
  level:
    root: INFO
    com.erp.gateway: DEBUG
    org.springframework.cloud.gateway: DEBUG
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"

# Actuator
management:
  endpoints:
    web:
      exposure:
        include: health,info,gateway
  endpoint:
    health:
      show-details: always
