데이터 관계 수정 시 라우트 변경

This commit is contained in:
2025-09-09 13:48:57 +09:00
parent 142cfe022b
commit 7bcd405a04
7 changed files with 244 additions and 13 deletions

View File

@@ -776,6 +776,7 @@ export class DataflowService {
const relationships = await prisma.table_relationships.findMany({
where: whereCondition,
select: {
relationship_id: true,
relationship_name: true,
from_table_name: true,
to_table_name: true,
@@ -797,6 +798,7 @@ export class DataflowService {
if (!diagramMap.has(diagramName)) {
diagramMap.set(diagramName, {
relationshipId: rel.relationship_id, // 첫 번째 관계의 ID를 대표 ID로 사용
diagramName: diagramName,
connectionType: rel.connection_type,
relationshipType: rel.relationship_type,
@@ -998,4 +1000,59 @@ export class DataflowService {
throw error;
}
}
/**
* relationship_id로 해당 관계도의 모든 관계 조회
*/
async getDiagramRelationshipsByRelationshipId(
companyCode: string,
relationshipId: number
) {
try {
logger.info(
`DataflowService: relationship_id로 관계도 관계 조회 - ${relationshipId}`
);
// 먼저 해당 relationship_id의 관계도명을 찾음
const targetRelationship = await prisma.table_relationships.findFirst({
where: {
relationship_id: relationshipId,
company_code: companyCode,
is_active: "Y",
},
select: {
relationship_name: true,
},
});
if (!targetRelationship) {
throw new Error("해당 관계 ID를 찾을 수 없습니다.");
}
// 같은 관계도명을 가진 모든 관계 조회
const relationships = await prisma.table_relationships.findMany({
where: {
relationship_name: targetRelationship.relationship_name,
company_code: companyCode,
is_active: "Y",
},
orderBy: [{ relationship_id: "asc" }],
});
logger.info(
`DataflowService: relationship_id로 관계도 관계 조회 완료 - ${relationships.length}개 관계`
);
return relationships.map((rel) => ({
...rel,
settings: rel.settings as any,
}));
} catch (error) {
logger.error(
`DataflowService: relationship_id로 관계도 관계 조회 실패 - ${relationshipId}`,
error
);
throw error;
}
}
}