From faacd5402c7883cfcce5b2c10161c657e4b7df09 Mon Sep 17 00:00:00 2001 From: dohyeons Date: Tue, 2 Dec 2025 17:36:28 +0900 Subject: [PATCH] =?UTF-8?q?=EC=99=B8=EB=B6=80=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EC=97=90=20=ED=9A=8C=EC=82=AC=EB=AA=85=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/externalDbConnectionService.ts | 19 ++++++----- .../externalRestApiConnectionService.ts | 32 ++++++++++--------- .../admin/external-connections/page.tsx | 4 +++ .../admin/RestApiConnectionList.tsx | 4 +++ 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/backend-node/src/services/externalDbConnectionService.ts b/backend-node/src/services/externalDbConnectionService.ts index 99164ae1..410e8daf 100644 --- a/backend-node/src/services/externalDbConnectionService.ts +++ b/backend-node/src/services/externalDbConnectionService.ts @@ -28,39 +28,39 @@ export class ExternalDbConnectionService { // 회사별 필터링 (최고 관리자가 아닌 경우 필수) if (userCompanyCode && userCompanyCode !== "*") { - whereConditions.push(`company_code = $${paramIndex++}`); + whereConditions.push(`e.company_code = $${paramIndex++}`); params.push(userCompanyCode); logger.info(`회사별 외부 DB 연결 필터링: ${userCompanyCode}`); } else if (userCompanyCode === "*") { logger.info(`최고 관리자: 모든 외부 DB 연결 조회`); // 필터가 있으면 적용 if (filter.company_code) { - whereConditions.push(`company_code = $${paramIndex++}`); + whereConditions.push(`e.company_code = $${paramIndex++}`); params.push(filter.company_code); } } else { // userCompanyCode가 없는 경우 (하위 호환성) if (filter.company_code) { - whereConditions.push(`company_code = $${paramIndex++}`); + whereConditions.push(`e.company_code = $${paramIndex++}`); params.push(filter.company_code); } } // 필터 조건 적용 if (filter.db_type) { - whereConditions.push(`db_type = $${paramIndex++}`); + whereConditions.push(`e.db_type = $${paramIndex++}`); params.push(filter.db_type); } if (filter.is_active) { - whereConditions.push(`is_active = $${paramIndex++}`); + whereConditions.push(`e.is_active = $${paramIndex++}`); params.push(filter.is_active); } // 검색 조건 적용 (연결명 또는 설명에서 검색) if (filter.search && filter.search.trim()) { whereConditions.push( - `(connection_name ILIKE $${paramIndex} OR description ILIKE $${paramIndex})` + `(e.connection_name ILIKE $${paramIndex} OR e.description ILIKE $${paramIndex})` ); params.push(`%${filter.search.trim()}%`); paramIndex++; @@ -72,9 +72,12 @@ export class ExternalDbConnectionService { : ""; const connections = await query( - `SELECT * FROM external_db_connections + `SELECT e.*, + COALESCE(c.company_name, CASE WHEN e.company_code = '*' THEN '전체' ELSE e.company_code END) AS company_name + FROM external_db_connections e + LEFT JOIN company_mng c ON e.company_code = c.company_code ${whereClause} - ORDER BY is_active DESC, connection_name ASC`, + ORDER BY e.is_active DESC, e.connection_name ASC`, params ); diff --git a/backend-node/src/services/externalRestApiConnectionService.ts b/backend-node/src/services/externalRestApiConnectionService.ts index cc1a46e5..63622951 100644 --- a/backend-node/src/services/externalRestApiConnectionService.ts +++ b/backend-node/src/services/externalRestApiConnectionService.ts @@ -31,15 +31,17 @@ export class ExternalRestApiConnectionService { try { let query = ` SELECT - id, connection_name, description, base_url, endpoint_path, default_headers, - default_method, + e.id, e.connection_name, e.description, e.base_url, e.endpoint_path, e.default_headers, + e.default_method, -- DB 스키마의 컬럼명은 default_request_body 기준이고 -- 코드에서는 default_body 필드로 사용하기 위해 alias 처리 - default_request_body AS default_body, - auth_type, auth_config, timeout, retry_count, retry_delay, - company_code, is_active, created_date, created_by, - updated_date, updated_by, last_test_date, last_test_result, last_test_message - FROM external_rest_api_connections + e.default_request_body AS default_body, + e.auth_type, e.auth_config, e.timeout, e.retry_count, e.retry_delay, + e.company_code, e.is_active, e.created_date, e.created_by, + e.updated_date, e.updated_by, e.last_test_date, e.last_test_result, e.last_test_message, + COALESCE(c.company_name, CASE WHEN e.company_code = '*' THEN '전체' ELSE e.company_code END) AS company_name + FROM external_rest_api_connections e + LEFT JOIN company_mng c ON e.company_code = c.company_code WHERE 1=1 `; @@ -48,7 +50,7 @@ export class ExternalRestApiConnectionService { // 회사별 필터링 (최고 관리자가 아닌 경우 필수) if (userCompanyCode && userCompanyCode !== "*") { - query += ` AND company_code = $${paramIndex}`; + query += ` AND e.company_code = $${paramIndex}`; params.push(userCompanyCode); paramIndex++; logger.info(`회사별 REST API 연결 필터링: ${userCompanyCode}`); @@ -56,14 +58,14 @@ export class ExternalRestApiConnectionService { logger.info(`최고 관리자: 모든 REST API 연결 조회`); // 필터가 있으면 적용 if (filter.company_code) { - query += ` AND company_code = $${paramIndex}`; + query += ` AND e.company_code = $${paramIndex}`; params.push(filter.company_code); paramIndex++; } } else { // userCompanyCode가 없는 경우 (하위 호환성) if (filter.company_code) { - query += ` AND company_code = $${paramIndex}`; + query += ` AND e.company_code = $${paramIndex}`; params.push(filter.company_code); paramIndex++; } @@ -71,14 +73,14 @@ export class ExternalRestApiConnectionService { // 활성 상태 필터 if (filter.is_active) { - query += ` AND is_active = $${paramIndex}`; + query += ` AND e.is_active = $${paramIndex}`; params.push(filter.is_active); paramIndex++; } // 인증 타입 필터 if (filter.auth_type) { - query += ` AND auth_type = $${paramIndex}`; + query += ` AND e.auth_type = $${paramIndex}`; params.push(filter.auth_type); paramIndex++; } @@ -86,9 +88,9 @@ export class ExternalRestApiConnectionService { // 검색어 필터 (연결명, 설명, URL) if (filter.search) { query += ` AND ( - connection_name ILIKE $${paramIndex} OR - description ILIKE $${paramIndex} OR - base_url ILIKE $${paramIndex} + e.connection_name ILIKE $${paramIndex} OR + e.description ILIKE $${paramIndex} OR + e.base_url ILIKE $${paramIndex} )`; params.push(`%${filter.search}%`); paramIndex++; diff --git a/frontend/app/(main)/admin/external-connections/page.tsx b/frontend/app/(main)/admin/external-connections/page.tsx index 88754ac4..0ab2fbeb 100644 --- a/frontend/app/(main)/admin/external-connections/page.tsx +++ b/frontend/app/(main)/admin/external-connections/page.tsx @@ -317,6 +317,7 @@ export default function ExternalConnectionsPage() { 연결명 + 회사 DB 타입 호스트:포트 데이터베이스 @@ -333,6 +334,9 @@ export default function ExternalConnectionsPage() {
{connection.connection_name}
+ + {(connection as any).company_name || connection.company_code} + {DB_TYPE_LABELS[connection.db_type] || connection.db_type} diff --git a/frontend/components/admin/RestApiConnectionList.tsx b/frontend/components/admin/RestApiConnectionList.tsx index ad57eb01..8ed5ea58 100644 --- a/frontend/components/admin/RestApiConnectionList.tsx +++ b/frontend/components/admin/RestApiConnectionList.tsx @@ -284,6 +284,7 @@ export function RestApiConnectionList() { 연결명 + 회사 기본 URL 인증 타입 헤더 수 @@ -308,6 +309,9 @@ export function RestApiConnectionList() { )} + + {(connection as any).company_name || connection.company_code} +
{connection.base_url}