feat: writer 컬럼 자동 user_name 변환 기능 추가

- 문제: 테이블 리스트에서 writer 컬럼이 user_id로 표시됨
- 해결:
  1. 백엔드: entityJoinService에서 writer 컬럼 자동 감지
  2. writer 컬럼 발견 시 user_info 테이블과 자동 조인
  3. writer_name 별칭으로 user_name 반환
  4. 프론트엔드: writer 컬럼일 때 writer_name 우선 표시
- 영향:
  - writer 컬럼이 있는 모든 테이블에서 자동으로 작성자명 표시
  - 기존 entity 조인 설정과 충돌 없이 작동
  - column_labels 설정 불필요
This commit is contained in:
kjs
2025-11-10 16:32:00 +09:00
parent 0e95f8ed66
commit ccbb6924c8
3 changed files with 38 additions and 6 deletions

View File

@@ -49,6 +49,39 @@ export class EntityJoinService {
const joinConfigs: EntityJoinConfig[] = [];
// 🎯 writer 컬럼 자동 감지 및 조인 설정 추가
const tableColumns = await query<{ column_name: string }>(
`SELECT column_name
FROM information_schema.columns
WHERE table_name = $1
AND table_schema = 'public'
AND column_name = 'writer'`,
[tableName]
);
if (tableColumns.length > 0) {
logger.info(`✅ writer 컬럼 발견: ${tableName}.writer -> user_info.user_id`);
const writerJoinConfig: EntityJoinConfig = {
sourceTable: tableName,
sourceColumn: "writer",
referenceTable: "user_info",
referenceColumn: "user_id",
displayColumns: ["user_name"],
displayColumn: "user_name",
aliasColumn: "writer_name",
separator: " - ",
};
// 조인 설정 유효성 검증
if (await this.validateJoinConfig(writerJoinConfig)) {
joinConfigs.push(writerJoinConfig);
logger.info(`✅ writer 컬럼 조인 설정 추가됨: writer_name`);
} else {
logger.warn(`❌ writer 컬럼 조인 설정 검증 실패`);
}
}
for (const column of entityColumns) {
logger.info(`🔍 Entity 컬럼 상세 정보:`, {
column_name: column.column_name,