<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="nodeExternalConnection">

  <!--
    external_db_connections 테이블
    map-underscore-to-camel-case: true → snake_case 컬럼이 camelCase 키로 자동 매핑됨
    e.g. connection_name → connectionName, database_name → databaseName
  -->

  <!-- 활성 커넥션 목록 (테스트 대상) -->
  <select id="selectActiveConnections" parameterType="map" resultType="map">
    SELECT
        ID
        , CONNECTION_NAME
        , DESCRIPTION
        , DB_TYPE
        , HOST
        , PORT
        , DATABASE_NAME
        , USERNAME
        , PASSWORD
        , SSL_ENABLED
        , CONNECTION_TIMEOUT
        , QUERY_TIMEOUT
        , COMPANY_CODE
        , IS_ACTIVE
    FROM EXTERNAL_DB_CONNECTIONS
    WHERE 1=1
      AND IS_ACTIVE = 'Y'
    <include refid="common.companyCodeFilter"/>
    ORDER BY CONNECTION_NAME ASC
  </select>

  <!-- 단건 조회 (JDBC 연결용 — password 포함) -->
  <select id="selectConnectionById" parameterType="map" resultType="map">
    SELECT
        ID
        , CONNECTION_NAME
        , DESCRIPTION
        , DB_TYPE
        , HOST
        , PORT
        , DATABASE_NAME
        , USERNAME
        , PASSWORD
        , SSL_ENABLED
        , CONNECTION_TIMEOUT
        , QUERY_TIMEOUT
        , COMPANY_CODE
        , IS_ACTIVE
    FROM EXTERNAL_DB_CONNECTIONS
    WHERE ID = #{id}
  </select>

</mapper>
