server:
  port: 8016

spring:
  application:
    name: zioinfo-esn
  datasource:
    url: ${DB_URL:jdbc:postgresql://localhost:5432/esn_db}
    username: ${DB_USER:esn_user}
    password: ${DB_PASS:esn_pass2026}
    driver-class-name: org.postgresql.Driver
    hikari:
      maximum-pool-size: 3
      connection-timeout: 30000
  # UIWS 이식: 부팅 시 schema.sql + 91_uiws_port.sql 멱등 적용
  # (둘 다 IF NOT EXISTS / ADD COLUMN IF NOT EXISTS / ON CONFLICT DO NOTHING — 재실행 안전).
  # 기존 deploy 의 psql -f schema.sql 와 중복돼도 멱등. 91_uiws_port 는 deploy 미적용분(uiws 테이블/2FA 컬럼) 보강.
  sql:
    init:
      mode: always
      continue-on-error: true
      schema-locations:
        - classpath:db/schema.sql
        # UIWS system(권한관리) 이식 — tb_uiws_* (멱등, 90 → 91 순서)
        - classpath:db/90_uiws_system.sql
        - classpath:db/91_uiws_port.sql
        # AI 기법(중앙 guardia-rag) 토글 — 테넌트 격리 esn_rag_setting (멱등)
        - classpath:db/92_esn_rag_setting.sql
        # 로그인 보조(가입 승인대기/아이디찾기) — esn_user name/approval_status ALTER (멱등)
        - classpath:db/93_esn_login_helper.sql
  web:
    resources:
      static-locations: classpath:/static/
  mvc:
    throw-exception-if-no-handler-found: true

mybatis:
  # UIWS 이식: mapper/uiws/*.xml 포함을 위해 재귀 글로브(**)로 확장(기존 mapper/*.xml 포함).
  mapper-locations: classpath:mapper/**/*.xml
  configuration:
    map-underscore-to-camel-case: true
    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
  type-aliases-package: com.zioinfo.esn.domain

guardia:
  ollama-url: ${OLLAMA_URL:http://localhost:11434}
  ollama-text-model: ${OLLAMA_TEXT_MODEL:llama3.2:1b}
  itsm-url: ${ITSM_URL:http://localhost:9001}
  # 중앙 guardia-rag (온프레미스 루프백 전용 — 외부 엔드포인트 금지).
  # 미가용/타임아웃 시 EsnRagClient 가 degraded 폴백, 기존 OllamaClient/룰로 무손실 동작.
  rag:
    base-url: ${RAG_URL:http://127.0.0.1:8020}
    timeout-ms: ${RAG_TIMEOUT_MS:120000}
    enabled: ${RAG_ENABLED:true}
    solution: esn
    max-concurrent-streams: 2
  jwt:
    secret: ${JWT_SECRET:ZioInfoEsnJwtSecret2026VeryLongSecretKeyForHS256AlgorithmAtLeast256Bits}
    expiration: 86400000

management:
  endpoints:
    web:
      exposure:
        include: health
  endpoint:
    health:
      show-details: never

logging:
  level:
    com.zioinfo.esn: DEBUG
    org.mybatis: WARN
