외부 연결 목록에 회사명 표시 기능 추가

This commit is contained in:
dohyeons 2025-12-02 17:36:28 +09:00
parent 436d604bb3
commit faacd5402c
4 changed files with 36 additions and 23 deletions

View File

@ -28,39 +28,39 @@ export class ExternalDbConnectionService {
// 회사별 필터링 (최고 관리자가 아닌 경우 필수) // 회사별 필터링 (최고 관리자가 아닌 경우 필수)
if (userCompanyCode && userCompanyCode !== "*") { if (userCompanyCode && userCompanyCode !== "*") {
whereConditions.push(`company_code = $${paramIndex++}`); whereConditions.push(`e.company_code = $${paramIndex++}`);
params.push(userCompanyCode); params.push(userCompanyCode);
logger.info(`회사별 외부 DB 연결 필터링: ${userCompanyCode}`); logger.info(`회사별 외부 DB 연결 필터링: ${userCompanyCode}`);
} else if (userCompanyCode === "*") { } else if (userCompanyCode === "*") {
logger.info(`최고 관리자: 모든 외부 DB 연결 조회`); logger.info(`최고 관리자: 모든 외부 DB 연결 조회`);
// 필터가 있으면 적용 // 필터가 있으면 적용
if (filter.company_code) { if (filter.company_code) {
whereConditions.push(`company_code = $${paramIndex++}`); whereConditions.push(`e.company_code = $${paramIndex++}`);
params.push(filter.company_code); params.push(filter.company_code);
} }
} else { } else {
// userCompanyCode가 없는 경우 (하위 호환성) // userCompanyCode가 없는 경우 (하위 호환성)
if (filter.company_code) { if (filter.company_code) {
whereConditions.push(`company_code = $${paramIndex++}`); whereConditions.push(`e.company_code = $${paramIndex++}`);
params.push(filter.company_code); params.push(filter.company_code);
} }
} }
// 필터 조건 적용 // 필터 조건 적용
if (filter.db_type) { if (filter.db_type) {
whereConditions.push(`db_type = $${paramIndex++}`); whereConditions.push(`e.db_type = $${paramIndex++}`);
params.push(filter.db_type); params.push(filter.db_type);
} }
if (filter.is_active) { if (filter.is_active) {
whereConditions.push(`is_active = $${paramIndex++}`); whereConditions.push(`e.is_active = $${paramIndex++}`);
params.push(filter.is_active); params.push(filter.is_active);
} }
// 검색 조건 적용 (연결명 또는 설명에서 검색) // 검색 조건 적용 (연결명 또는 설명에서 검색)
if (filter.search && filter.search.trim()) { if (filter.search && filter.search.trim()) {
whereConditions.push( 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()}%`); params.push(`%${filter.search.trim()}%`);
paramIndex++; paramIndex++;
@ -72,9 +72,12 @@ export class ExternalDbConnectionService {
: ""; : "";
const connections = await query<any>( const connections = await query<any>(
`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} ${whereClause}
ORDER BY is_active DESC, connection_name ASC`, ORDER BY e.is_active DESC, e.connection_name ASC`,
params params
); );

View File

@ -31,15 +31,17 @@ export class ExternalRestApiConnectionService {
try { try {
let query = ` let query = `
SELECT SELECT
id, connection_name, description, base_url, endpoint_path, default_headers, e.id, e.connection_name, e.description, e.base_url, e.endpoint_path, e.default_headers,
default_method, e.default_method,
-- DB default_request_body -- DB default_request_body
-- default_body alias -- default_body alias
default_request_body AS default_body, e.default_request_body AS default_body,
auth_type, auth_config, timeout, retry_count, retry_delay, e.auth_type, e.auth_config, e.timeout, e.retry_count, e.retry_delay,
company_code, is_active, created_date, created_by, e.company_code, e.is_active, e.created_date, e.created_by,
updated_date, updated_by, last_test_date, last_test_result, last_test_message e.updated_date, e.updated_by, e.last_test_date, e.last_test_result, e.last_test_message,
FROM external_rest_api_connections 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 WHERE 1=1
`; `;
@ -48,7 +50,7 @@ export class ExternalRestApiConnectionService {
// 회사별 필터링 (최고 관리자가 아닌 경우 필수) // 회사별 필터링 (최고 관리자가 아닌 경우 필수)
if (userCompanyCode && userCompanyCode !== "*") { if (userCompanyCode && userCompanyCode !== "*") {
query += ` AND company_code = $${paramIndex}`; query += ` AND e.company_code = $${paramIndex}`;
params.push(userCompanyCode); params.push(userCompanyCode);
paramIndex++; paramIndex++;
logger.info(`회사별 REST API 연결 필터링: ${userCompanyCode}`); logger.info(`회사별 REST API 연결 필터링: ${userCompanyCode}`);
@ -56,14 +58,14 @@ export class ExternalRestApiConnectionService {
logger.info(`최고 관리자: 모든 REST API 연결 조회`); logger.info(`최고 관리자: 모든 REST API 연결 조회`);
// 필터가 있으면 적용 // 필터가 있으면 적용
if (filter.company_code) { if (filter.company_code) {
query += ` AND company_code = $${paramIndex}`; query += ` AND e.company_code = $${paramIndex}`;
params.push(filter.company_code); params.push(filter.company_code);
paramIndex++; paramIndex++;
} }
} else { } else {
// userCompanyCode가 없는 경우 (하위 호환성) // userCompanyCode가 없는 경우 (하위 호환성)
if (filter.company_code) { if (filter.company_code) {
query += ` AND company_code = $${paramIndex}`; query += ` AND e.company_code = $${paramIndex}`;
params.push(filter.company_code); params.push(filter.company_code);
paramIndex++; paramIndex++;
} }
@ -71,14 +73,14 @@ export class ExternalRestApiConnectionService {
// 활성 상태 필터 // 활성 상태 필터
if (filter.is_active) { if (filter.is_active) {
query += ` AND is_active = $${paramIndex}`; query += ` AND e.is_active = $${paramIndex}`;
params.push(filter.is_active); params.push(filter.is_active);
paramIndex++; paramIndex++;
} }
// 인증 타입 필터 // 인증 타입 필터
if (filter.auth_type) { if (filter.auth_type) {
query += ` AND auth_type = $${paramIndex}`; query += ` AND e.auth_type = $${paramIndex}`;
params.push(filter.auth_type); params.push(filter.auth_type);
paramIndex++; paramIndex++;
} }
@ -86,9 +88,9 @@ export class ExternalRestApiConnectionService {
// 검색어 필터 (연결명, 설명, URL) // 검색어 필터 (연결명, 설명, URL)
if (filter.search) { if (filter.search) {
query += ` AND ( query += ` AND (
connection_name ILIKE $${paramIndex} OR e.connection_name ILIKE $${paramIndex} OR
description ILIKE $${paramIndex} OR e.description ILIKE $${paramIndex} OR
base_url ILIKE $${paramIndex} e.base_url ILIKE $${paramIndex}
)`; )`;
params.push(`%${filter.search}%`); params.push(`%${filter.search}%`);
paramIndex++; paramIndex++;

View File

@ -317,6 +317,7 @@ export default function ExternalConnectionsPage() {
<TableHeader> <TableHeader>
<TableRow className="bg-background"> <TableRow className="bg-background">
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold">DB </TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold">DB </TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold">호스트:포트</TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold">호스트:포트</TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead>
@ -333,6 +334,9 @@ export default function ExternalConnectionsPage() {
<TableCell className="h-16 px-6 py-3 text-sm"> <TableCell className="h-16 px-6 py-3 text-sm">
<div className="font-medium">{connection.connection_name}</div> <div className="font-medium">{connection.connection_name}</div>
</TableCell> </TableCell>
<TableCell className="h-16 px-6 py-3 text-sm">
{(connection as any).company_name || connection.company_code}
</TableCell>
<TableCell className="h-16 px-6 py-3 text-sm"> <TableCell className="h-16 px-6 py-3 text-sm">
<Badge variant="outline"> <Badge variant="outline">
{DB_TYPE_LABELS[connection.db_type] || connection.db_type} {DB_TYPE_LABELS[connection.db_type] || connection.db_type}

View File

@ -284,6 +284,7 @@ export function RestApiConnectionList() {
<TableHeader> <TableHeader>
<TableRow className="bg-background"> <TableRow className="bg-background">
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"></TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"> URL</TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold"> URL</TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"> </TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold"> </TableHead>
<TableHead className="h-12 px-6 py-3 text-sm font-semibold"> </TableHead> <TableHead className="h-12 px-6 py-3 text-sm font-semibold"> </TableHead>
@ -308,6 +309,9 @@ export function RestApiConnectionList() {
)} )}
</div> </div>
</TableCell> </TableCell>
<TableCell className="h-16 px-6 py-3 text-sm">
{(connection as any).company_name || connection.company_code}
</TableCell>
<TableCell className="h-16 px-6 py-3 font-mono text-sm"> <TableCell className="h-16 px-6 py-3 font-mono text-sm">
<div className="max-w-[300px] truncate" title={connection.base_url}> <div className="max-w-[300px] truncate" title={connection.base_url}>
{connection.base_url} {connection.base_url}