refactor: Update table schema retrieval to prioritize company-specific labels

- Modified the `getTableSchema` function in `adminController.ts` to use company-specific column labels when available, falling back to common labels if not.
- Adjusted the SQL query to join `table_type_columns` for both company-specific and common labels, ensuring the correct display order is maintained.
- Removed unnecessary component count display in the `TabsDesignEditor` to streamline the UI.

These changes enhance the accuracy of the table schema representation based on company context and improve the overall user interface by simplifying tab displays.
This commit is contained in:
kjs 2026-03-10 11:49:02 +09:00
parent 4f8c31c893
commit c0eab878a1
2 changed files with 13 additions and 18 deletions

View File

@ -3564,6 +3564,7 @@ export async function getTableSchema(
logger.info("테이블 스키마 조회", { tableName, companyCode });
// information_schema와 table_type_columns를 JOIN하여 컬럼 정보와 라벨 정보 함께 가져오기
// 회사별 라벨 우선, 없으면 공통(*) 라벨 사용
const schemaQuery = `
SELECT
ic.column_name,
@ -3573,19 +3574,23 @@ export async function getTableSchema(
ic.character_maximum_length,
ic.numeric_precision,
ic.numeric_scale,
ttc.column_label,
ttc.display_order
COALESCE(ttc_company.column_label, ttc_common.column_label) AS column_label,
COALESCE(ttc_company.display_order, ttc_common.display_order) AS display_order
FROM information_schema.columns ic
LEFT JOIN table_type_columns ttc
ON ttc.table_name = ic.table_name
AND ttc.column_name = ic.column_name
AND ttc.company_code = '*'
LEFT JOIN table_type_columns ttc_common
ON ttc_common.table_name = ic.table_name
AND ttc_common.column_name = ic.column_name
AND ttc_common.company_code = '*'
LEFT JOIN table_type_columns ttc_company
ON ttc_company.table_name = ic.table_name
AND ttc_company.column_name = ic.column_name
AND ttc_company.company_code = $2
WHERE ic.table_schema = 'public'
AND ic.table_name = $1
ORDER BY COALESCE(ttc.display_order, ic.ordinal_position), ic.ordinal_position
ORDER BY COALESCE(ttc_company.display_order, ttc_common.display_order, ic.ordinal_position), ic.ordinal_position
`;
const columns = await query<any>(schemaQuery, [tableName]);
const columns = await query<any>(schemaQuery, [tableName, companyCode]);
if (columns.length === 0) {
res.status(404).json({

View File

@ -295,11 +295,6 @@ const TabsDesignEditor: React.FC<{
}}
>
{tab.label || "탭"}
{tab.components && tab.components.length > 0 && (
<span className="ml-1 text-xs text-muted-foreground">
({tab.components.length})
</span>
)}
</div>
))
) : (
@ -649,11 +644,6 @@ ComponentRegistry.registerComponent({
}}
>
{tab.label || "탭"}
{tab.components && tab.components.length > 0 && (
<span className="ml-1 text-xs text-muted-foreground">
({tab.components.length})
</span>
)}
</div>
))
) : (