restapi 버튼 동작
This commit is contained in:
@@ -384,3 +384,66 @@ export const copyDataflowDiagram = async (
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 🔥 전체 관계 목록 조회 (버튼 제어용)
|
||||
* dataflow_diagrams 테이블에서 관계도 데이터를 조회 (데이터 흐름 관계 화면과 동일)
|
||||
*/
|
||||
export const getAllRelationshipsForButtonControl = async (
|
||||
companyCode: string
|
||||
): Promise<Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
sourceTable: string;
|
||||
targetTable: string;
|
||||
category: string;
|
||||
}>> => {
|
||||
try {
|
||||
logger.info(`전체 관계 목록 조회 시작 - companyCode: ${companyCode}`);
|
||||
|
||||
// dataflow_diagrams 테이블에서 관계도들을 조회
|
||||
const diagrams = await prisma.dataflow_diagrams.findMany({
|
||||
where: {
|
||||
company_code: companyCode,
|
||||
},
|
||||
select: {
|
||||
diagram_id: true,
|
||||
diagram_name: true,
|
||||
relationships: true,
|
||||
},
|
||||
orderBy: {
|
||||
updated_at: "desc",
|
||||
},
|
||||
});
|
||||
|
||||
const allRelationships = diagrams.map((diagram) => {
|
||||
// relationships 구조에서 테이블 정보 추출
|
||||
const relationships = diagram.relationships as any || {};
|
||||
|
||||
// 테이블 정보 추출
|
||||
let sourceTable = "";
|
||||
let targetTable = "";
|
||||
|
||||
if (relationships.fromTable?.tableName) {
|
||||
sourceTable = relationships.fromTable.tableName;
|
||||
}
|
||||
if (relationships.toTable?.tableName) {
|
||||
targetTable = relationships.toTable.tableName;
|
||||
}
|
||||
|
||||
return {
|
||||
id: diagram.diagram_id.toString(),
|
||||
name: diagram.diagram_name || `관계 ${diagram.diagram_id}`,
|
||||
sourceTable: sourceTable,
|
||||
targetTable: targetTable,
|
||||
category: "데이터 흐름",
|
||||
};
|
||||
});
|
||||
|
||||
logger.info(`전체 관계 ${allRelationships.length}개 조회 완료`);
|
||||
return allRelationships;
|
||||
} catch (error) {
|
||||
logger.error("전체 관계 목록 조회 서비스 오류:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user