feat: Enhance entity join functionality with company code support

- Updated the EntityJoinController to log the company code during entity join configuration retrieval.
- Modified the entityJoinService to accept company code as a parameter, allowing for company-specific entity join detection.
- Enhanced the TableManagementService to pass the company code when detecting entity joins and retrieving reference table columns.
- Implemented a helper function in the SplitPanelLayoutComponent to extract additional join columns based on the entity join configuration.
- Improved the SplitPanelLayoutConfigPanel to display entity join columns dynamically, enhancing user experience and functionality.
This commit is contained in:
DDD1542
2026-02-10 10:51:23 +09:00
parent 9e1a54c738
commit 3c8c2ebcf4
5 changed files with 392 additions and 374 deletions

View File

@@ -2875,10 +2875,11 @@ export class TableManagementService {
};
}
// Entity 조인 설정 감지 (화면별 엔티티 설정 전달)
// Entity 조인 설정 감지 (화면별 엔티티 설정 + 회사코드 전달)
let joinConfigs = await entityJoinService.detectEntityJoins(
tableName,
options.screenEntityConfigs
options.screenEntityConfigs,
options.companyCode
);
logger.info(
@@ -3258,6 +3259,28 @@ export class TableManagementService {
startTime: number
): Promise<EntityJoinResponse> {
try {
// 🆕 참조 테이블별 전체 컬럼 목록 미리 조회
const referenceTableColumns = new Map<string, string[]>();
const uniqueRefTables = new Set(
joinConfigs
.filter((c) => c.referenceTable !== "table_column_category_values") // 카테고리는 제외
.map((c) => `${c.referenceTable}:${c.sourceColumn}`)
);
for (const key of uniqueRefTables) {
const refTable = key.split(":")[0];
if (!referenceTableColumns.has(key)) {
const cols = await query<{ column_name: string }>(
`SELECT column_name FROM information_schema.columns
WHERE table_name = $1 AND table_schema = 'public'
ORDER BY ordinal_position`,
[refTable]
);
referenceTableColumns.set(key, cols.map((c) => c.column_name));
logger.info(`🔍 참조 테이블 컬럼 조회: ${refTable}${cols.length}`);
}
}
// 데이터 조회 쿼리
const dataQuery = entityJoinService.buildJoinQuery(
tableName,
@@ -3266,7 +3289,9 @@ export class TableManagementService {
whereClause,
orderBy,
limit,
offset
offset,
undefined,
referenceTableColumns // 🆕 참조 테이블 전체 컬럼 전달
).query;
// 카운트 쿼리
@@ -3767,12 +3792,12 @@ export class TableManagementService {
reference_table: string;
reference_column: string;
}>(
`SELECT column_name, reference_table, reference_column
`SELECT DISTINCT ON (column_name) column_name, reference_table, reference_column
FROM table_type_columns
WHERE table_name = $1
AND input_type = 'entity'
AND reference_table = $2
AND company_code = '*'
ORDER BY column_name, CASE WHEN company_code = '*' THEN 1 ELSE 0 END
LIMIT 1`,
[tableName, refTable]
);
@@ -3883,7 +3908,7 @@ export class TableManagementService {
/**
* 참조 테이블의 표시 컬럼 목록 조회
*/
async getReferenceTableColumns(tableName: string): Promise<
async getReferenceTableColumns(tableName: string, companyCode?: string): Promise<
Array<{
columnName: string;
displayName: string;
@@ -3891,7 +3916,7 @@ export class TableManagementService {
inputType?: string;
}>
> {
return await entityJoinService.getReferenceTableColumns(tableName);
return await entityJoinService.getReferenceTableColumns(tableName, companyCode);
}
/**
@@ -5005,14 +5030,14 @@ export class TableManagementService {
input_type: string;
display_column: string | null;
}>(
`SELECT column_name, reference_column, input_type, display_column
`SELECT DISTINCT ON (column_name) column_name, reference_column, input_type, display_column
FROM table_type_columns
WHERE table_name = $1
AND input_type IN ('entity', 'category')
AND reference_table = $2
AND reference_column IS NOT NULL
AND reference_column != ''
AND company_code = '*'`,
ORDER BY column_name, CASE WHEN company_code = '*' THEN 1 ELSE 0 END`,
[rightTable, leftTable]
);
@@ -5034,14 +5059,14 @@ export class TableManagementService {
input_type: string;
display_column: string | null;
}>(
`SELECT column_name, reference_column, input_type, display_column
`SELECT DISTINCT ON (column_name) column_name, reference_column, input_type, display_column
FROM table_type_columns
WHERE table_name = $1
AND input_type IN ('entity', 'category')
AND reference_table = $2
AND reference_column IS NOT NULL
AND reference_column != ''
AND company_code = '*'`,
ORDER BY column_name, CASE WHEN company_code = '*' THEN 1 ELSE 0 END`,
[leftTable, rightTable]
);