테이블에서 라벨명으로 표시되게 수정
This commit is contained in:
parent
7a39acaaca
commit
2aa4d83f33
|
|
@ -277,10 +277,10 @@ export class EntityJoinService {
|
||||||
}>
|
}>
|
||||||
> {
|
> {
|
||||||
try {
|
try {
|
||||||
|
// 1. 테이블의 기본 컬럼 정보 조회
|
||||||
const columns = (await prisma.$queryRaw`
|
const columns = (await prisma.$queryRaw`
|
||||||
SELECT
|
SELECT
|
||||||
column_name,
|
column_name,
|
||||||
column_name as display_name,
|
|
||||||
data_type
|
data_type
|
||||||
FROM information_schema.columns
|
FROM information_schema.columns
|
||||||
WHERE table_name = ${tableName}
|
WHERE table_name = ${tableName}
|
||||||
|
|
@ -288,13 +288,30 @@ export class EntityJoinService {
|
||||||
ORDER BY ordinal_position
|
ORDER BY ordinal_position
|
||||||
`) as Array<{
|
`) as Array<{
|
||||||
column_name: string;
|
column_name: string;
|
||||||
display_name: string;
|
|
||||||
data_type: string;
|
data_type: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
// 2. column_labels 테이블에서 라벨 정보 조회
|
||||||
|
const columnLabels = await prisma.column_labels.findMany({
|
||||||
|
where: { table_name: tableName },
|
||||||
|
select: {
|
||||||
|
column_name: true,
|
||||||
|
column_label: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. 라벨 정보를 맵으로 변환
|
||||||
|
const labelMap = new Map<string, string>();
|
||||||
|
columnLabels.forEach((label) => {
|
||||||
|
if (label.column_name && label.column_label) {
|
||||||
|
labelMap.set(label.column_name, label.column_label);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 4. 컬럼 정보와 라벨 정보 결합
|
||||||
return columns.map((col) => ({
|
return columns.map((col) => ({
|
||||||
columnName: col.column_name,
|
columnName: col.column_name,
|
||||||
displayName: col.display_name,
|
displayName: labelMap.get(col.column_name) || col.column_name, // 라벨이 있으면 사용, 없으면 컬럼명
|
||||||
dataType: col.data_type,
|
dataType: col.data_type,
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -145,9 +145,13 @@ export class TableManagementService {
|
||||||
cl.reference_column as "referenceColumn",
|
cl.reference_column as "referenceColumn",
|
||||||
cl.display_column as "displayColumn",
|
cl.display_column as "displayColumn",
|
||||||
cl.display_order as "displayOrder",
|
cl.display_order as "displayOrder",
|
||||||
cl.is_visible as "isVisible"
|
cl.is_visible as "isVisible",
|
||||||
|
-- Entity 조인 컬럼의 표시 컬럼 라벨 조회
|
||||||
|
dcl.column_label as "displayColumnLabel"
|
||||||
FROM information_schema.columns c
|
FROM information_schema.columns c
|
||||||
LEFT JOIN column_labels cl ON c.table_name = cl.table_name AND c.column_name = cl.column_name
|
LEFT JOIN column_labels cl ON c.table_name = cl.table_name AND c.column_name = cl.column_name
|
||||||
|
-- Entity 조인의 display_column에 대한 라벨 정보 조회
|
||||||
|
LEFT JOIN column_labels dcl ON cl.reference_table = dcl.table_name AND cl.display_column = dcl.column_name
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT kcu.column_name, kcu.table_name
|
SELECT kcu.column_name, kcu.table_name
|
||||||
FROM information_schema.table_constraints tc
|
FROM information_schema.table_constraints tc
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,19 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
||||||
const meta: Record<string, { webType?: string; codeCategory?: string }> = {};
|
const meta: Record<string, { webType?: string; codeCategory?: string }> = {};
|
||||||
|
|
||||||
columns.forEach((column: any) => {
|
columns.forEach((column: any) => {
|
||||||
labels[column.columnName] = column.displayName || column.columnName;
|
// 🎯 Entity 조인된 컬럼의 경우 표시 컬럼명 사용
|
||||||
|
let displayLabel = column.displayName || column.columnName;
|
||||||
|
|
||||||
|
// Entity 타입이고 display_column이 있는 경우
|
||||||
|
if (column.webType === "entity" && column.displayColumn) {
|
||||||
|
// 백엔드에서 받은 displayColumnLabel을 사용하거나, 없으면 displayColumn 사용
|
||||||
|
displayLabel = column.displayColumnLabel || column.displayColumn;
|
||||||
|
console.log(
|
||||||
|
`🎯 Entity 조인 컬럼 라벨 설정: ${column.columnName} → "${displayLabel}" (${column.displayColumn})`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
labels[column.columnName] = displayLabel;
|
||||||
// 🎯 웹타입과 코드카테고리 정보 저장
|
// 🎯 웹타입과 코드카테고리 정보 저장
|
||||||
meta[column.columnName] = {
|
meta[column.columnName] = {
|
||||||
webType: column.webType,
|
webType: column.webType,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue