플로우 로그기능 수정
This commit is contained in:
@@ -161,6 +161,28 @@ export class FlowDataMoveService {
|
||||
}
|
||||
|
||||
// 5. 감사 로그 기록
|
||||
let dbConnectionName = null;
|
||||
if (
|
||||
flowDefinition.dbSourceType === "external" &&
|
||||
flowDefinition.dbConnectionId
|
||||
) {
|
||||
// 외부 DB인 경우 연결 이름 조회
|
||||
try {
|
||||
const connResult = await client.query(
|
||||
`SELECT connection_name FROM external_db_connections WHERE id = $1`,
|
||||
[flowDefinition.dbConnectionId]
|
||||
);
|
||||
if (connResult.rows && connResult.rows.length > 0) {
|
||||
dbConnectionName = connResult.rows[0].connection_name;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("외부 DB 연결 이름 조회 실패:", error);
|
||||
}
|
||||
} else {
|
||||
// 내부 DB인 경우
|
||||
dbConnectionName = "내부 데이터베이스";
|
||||
}
|
||||
|
||||
await this.logDataMove(client, {
|
||||
flowId,
|
||||
fromStepId,
|
||||
@@ -173,6 +195,11 @@ export class FlowDataMoveService {
|
||||
statusFrom: fromStep.statusValue,
|
||||
statusTo: toStep.statusValue,
|
||||
userId,
|
||||
dbConnectionId:
|
||||
flowDefinition.dbSourceType === "external"
|
||||
? flowDefinition.dbConnectionId
|
||||
: null,
|
||||
dbConnectionName,
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -361,8 +388,9 @@ export class FlowDataMoveService {
|
||||
move_type, source_table, target_table,
|
||||
source_data_id, target_data_id,
|
||||
status_from, status_to,
|
||||
changed_by, note
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
||||
changed_by, note,
|
||||
db_connection_id, db_connection_name
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
|
||||
`;
|
||||
|
||||
await client.query(query, [
|
||||
@@ -378,6 +406,8 @@ export class FlowDataMoveService {
|
||||
params.statusTo,
|
||||
params.userId,
|
||||
params.note || null,
|
||||
params.dbConnectionId || null,
|
||||
params.dbConnectionName || null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -452,6 +482,8 @@ export class FlowDataMoveService {
|
||||
targetDataId: row.target_data_id,
|
||||
statusFrom: row.status_from,
|
||||
statusTo: row.status_to,
|
||||
dbConnectionId: row.db_connection_id,
|
||||
dbConnectionName: row.db_connection_name,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -496,6 +528,8 @@ export class FlowDataMoveService {
|
||||
targetDataId: row.target_data_id,
|
||||
statusFrom: row.status_from,
|
||||
statusTo: row.status_to,
|
||||
dbConnectionId: row.db_connection_id,
|
||||
dbConnectionName: row.db_connection_name,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -718,7 +752,21 @@ export class FlowDataMoveService {
|
||||
|
||||
// 3. 외부 연동 처리는 생략 (외부 DB 자체가 외부이므로)
|
||||
|
||||
// 4. 감사 로그 기록 (내부 DB에)
|
||||
// 4. 외부 DB 연결 이름 조회
|
||||
let dbConnectionName = null;
|
||||
try {
|
||||
const connResult = await db.query(
|
||||
`SELECT connection_name FROM external_db_connections WHERE id = $1`,
|
||||
[dbConnectionId]
|
||||
);
|
||||
if (connResult.length > 0) {
|
||||
dbConnectionName = connResult[0].connection_name;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("외부 DB 연결 이름 조회 실패:", error);
|
||||
}
|
||||
|
||||
// 5. 감사 로그 기록 (내부 DB에)
|
||||
// 외부 DB는 내부 DB 트랜잭션 외부이므로 직접 쿼리 실행
|
||||
const auditQuery = `
|
||||
INSERT INTO flow_audit_log (
|
||||
@@ -726,8 +774,9 @@ export class FlowDataMoveService {
|
||||
move_type, source_table, target_table,
|
||||
source_data_id, target_data_id,
|
||||
status_from, status_to,
|
||||
changed_by, note
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
||||
changed_by, note,
|
||||
db_connection_id, db_connection_name
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
|
||||
`;
|
||||
|
||||
await db.query(auditQuery, [
|
||||
@@ -743,6 +792,8 @@ export class FlowDataMoveService {
|
||||
toStep.statusValue || null, // statusTo
|
||||
userId,
|
||||
`외부 DB (${dbType}) 데이터 이동`,
|
||||
dbConnectionId,
|
||||
dbConnectionName,
|
||||
]);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user