상세입력 컴포넌트 테이블 선택 기능 추가

This commit is contained in:
kjs
2025-11-17 15:25:08 +09:00
parent a783317820
commit bc557c4074
14 changed files with 1095 additions and 230 deletions

View File

@@ -1068,43 +1068,131 @@ export class ScreenManagementService {
[tableName]
);
// column_labels 테이블에서 입력타입 정보 조회 (있는 경우)
const webTypeInfo = await query<{
// 🆕 table_type_columns에서 입력타입 정보 조회 (회사별만, fallback 없음)
// 멀티테넌시: 각 회사는 자신의 설정만 사용, 최고관리자 설정은 별도 관리
console.log(`🔍 [getTableColumns] 시작: table=${tableName}, company=${companyCode}`);
const typeInfo = await query<{
column_name: string;
input_type: string | null;
column_label: string | null;
detail_settings: any;
}>(
`SELECT column_name, input_type, column_label, detail_settings
`SELECT column_name, input_type, detail_settings
FROM table_type_columns
WHERE table_name = $1
AND company_code = $2
ORDER BY id DESC`, // 최신 레코드 우선 (중복 방지)
[tableName, companyCode]
);
console.log(`📊 [getTableColumns] typeInfo 조회 완료: ${typeInfo.length}`);
const currencyCodeType = typeInfo.find(t => t.column_name === 'currency_code');
if (currencyCodeType) {
console.log(`💰 [getTableColumns] currency_code 발견:`, currencyCodeType);
} else {
console.log(`⚠️ [getTableColumns] currency_code 없음`);
}
// column_labels 테이블에서 라벨 정보 조회 (우선순위 2)
const labelInfo = await query<{
column_name: string;
column_label: string | null;
}>(
`SELECT column_name, column_label
FROM column_labels
WHERE table_name = $1`,
[tableName]
);
// 컬럼 정보 매핑
return columns.map((column: any) => {
const webTypeData = webTypeInfo.find(
(wt) => wt.column_name === column.column_name
);
// 🆕 category_column_mapping에서 코드 카테고리 정보 조회
const categoryInfo = await query<{
physical_column_name: string;
logical_column_name: string;
}>(
`SELECT physical_column_name, logical_column_name
FROM category_column_mapping
WHERE table_name = $1
AND company_code = $2`,
[tableName, companyCode]
);
return {
// 컬럼 정보 매핑
const columnMap = new Map<string, any>();
// 먼저 information_schema에서 가져온 컬럼들로 기본 맵 생성
columns.forEach((column: any) => {
columnMap.set(column.column_name, {
tableName: tableName,
columnName: column.column_name,
columnLabel:
webTypeData?.column_label ||
this.getColumnLabel(column.column_name),
dataType: column.data_type,
webType:
(webTypeData?.input_type as WebType) ||
this.inferWebType(column.data_type),
isNullable: column.is_nullable,
columnDefault: column.column_default || undefined,
characterMaximumLength: column.character_maximum_length || undefined,
numericPrecision: column.numeric_precision || undefined,
numericScale: column.numeric_scale || undefined,
detailSettings: webTypeData?.detail_settings || undefined,
};
});
});
console.log(`🗺️ [getTableColumns] 기본 columnMap 생성: ${columnMap.size}`);
// table_type_columns에서 input_type 추가 (중복 시 최신 것만)
const addedTypes = new Set<string>();
typeInfo.forEach((type) => {
const colName = type.column_name;
if (!addedTypes.has(colName) && columnMap.has(colName)) {
const col = columnMap.get(colName);
col.inputType = type.input_type;
col.webType = type.input_type; // webType도 동일하게 설정
col.detailSettings = type.detail_settings;
addedTypes.add(colName);
if (colName === 'currency_code') {
console.log(`✅ [getTableColumns] currency_code inputType 설정됨: ${type.input_type}`);
}
}
});
console.log(`🏷️ [getTableColumns] inputType 추가 완료: ${addedTypes.size}`);
// column_labels에서 라벨 추가
labelInfo.forEach((label) => {
const col = columnMap.get(label.column_name);
if (col) {
col.columnLabel = label.column_label || this.getColumnLabel(label.column_name);
}
});
// category_column_mapping에서 코드 카테고리 추가
categoryInfo.forEach((cat) => {
const col = columnMap.get(cat.physical_column_name);
if (col) {
col.codeCategory = cat.logical_column_name;
}
});
// 최종 결과 생성
const result = Array.from(columnMap.values()).map((col) => ({
...col,
// 기본값 설정
columnLabel: col.columnLabel || this.getColumnLabel(col.columnName),
inputType: col.inputType || this.inferWebType(col.dataType),
webType: col.webType || this.inferWebType(col.dataType),
detailSettings: col.detailSettings || undefined,
codeCategory: col.codeCategory || undefined,
}));
// 디버깅: currency_code의 최종 inputType 확인
const currencyCodeResult = result.find(r => r.columnName === 'currency_code');
if (currencyCodeResult) {
console.log(`🎯 [getTableColumns] 최종 currency_code:`, {
inputType: currencyCodeResult.inputType,
webType: currencyCodeResult.webType,
dataType: currencyCodeResult.dataType
});
}
console.log(`✅ [getTableColumns] 반환: ${result.length}개 컬럼`);
return result;
} catch (error) {
console.error("테이블 컬럼 조회 실패:", error);
throw new Error("테이블 컬럼 정보를 조회할 수 없습니다.");

View File

@@ -165,6 +165,10 @@ export class TableManagementService {
const offset = (page - 1) * size;
// 🔥 company_code가 있으면 table_type_columns 조인하여 회사별 inputType 가져오기
console.log(
`🔍 [getColumnList] 시작: table=${tableName}, company=${companyCode}`
);
const rawColumns = companyCode
? await query<any>(
`SELECT
@@ -174,6 +178,8 @@ export class TableManagementService {
c.data_type as "dbType",
COALESCE(cl.input_type, 'text') as "webType",
COALESCE(ttc.input_type, cl.input_type, 'direct') as "inputType",
ttc.input_type as "ttc_input_type",
cl.input_type as "cl_input_type",
COALESCE(ttc.detail_settings::text, cl.detail_settings, '') as "detailSettings",
COALESCE(cl.description, '') as "description",
c.is_nullable as "isNullable",
@@ -250,6 +256,22 @@ export class TableManagementService {
[tableName, size, offset]
);
// 디버깅: currency_code 확인
const currencyCol = rawColumns.find(
(col: any) => col.columnName === "currency_code"
);
if (currencyCol) {
console.log(`🎯 [getColumnList] currency_code 원본 쿼리 결과:`, {
columnName: currencyCol.columnName,
inputType: currencyCol.inputType,
ttc_input_type: currencyCol.ttc_input_type,
cl_input_type: currencyCol.cl_input_type,
webType: currencyCol.webType,
});
} else {
console.log(`⚠️ [getColumnList] currency_code가 rawColumns에 없음`);
}
// 🆕 category_column_mapping 조회
const tableExistsResult = await query<any>(
`SELECT EXISTS (