Merge branch 'feature/rest-api-integration' of http://39.117.244.52:3000/kjs/ERP-node
This commit is contained in:
@@ -12,21 +12,14 @@ import { MultiConnectionQueryService } from "./multiConnectionQueryService";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
export interface EnhancedControlAction extends ControlAction {
|
||||
// 🆕 커넥션 정보 추가
|
||||
fromConnection?: {
|
||||
connectionId?: number;
|
||||
connectionName?: string;
|
||||
dbType?: string;
|
||||
};
|
||||
toConnection?: {
|
||||
connectionId?: number;
|
||||
connectionName?: string;
|
||||
dbType?: string;
|
||||
};
|
||||
// 🆕 기본 ControlAction 속성들 (상속됨)
|
||||
id?: number;
|
||||
actionType?: string;
|
||||
fromTable: string;
|
||||
|
||||
// 🆕 명시적 테이블 정보
|
||||
fromTable?: string;
|
||||
targetTable: string;
|
||||
// 🆕 추가 속성들
|
||||
conditions?: ControlCondition[];
|
||||
fieldMappings?: any[];
|
||||
|
||||
// 🆕 UPDATE 액션 관련 필드
|
||||
updateConditions?: UpdateCondition[];
|
||||
@@ -172,13 +165,20 @@ export class EnhancedDataflowControlService extends DataflowControlService {
|
||||
const enhancedAction = action as EnhancedControlAction;
|
||||
let actionResult: any;
|
||||
|
||||
// 커넥션 ID 추출
|
||||
const sourceConnectionId = enhancedAction.fromConnection?.connectionId || enhancedAction.fromConnection?.id || 0;
|
||||
const targetConnectionId = enhancedAction.toConnection?.connectionId || enhancedAction.toConnection?.id || 0;
|
||||
|
||||
switch (enhancedAction.actionType) {
|
||||
case "insert":
|
||||
actionResult = await this.executeMultiConnectionInsert(
|
||||
enhancedAction,
|
||||
sourceData,
|
||||
enhancedAction.fromTable,
|
||||
enhancedAction.targetTable,
|
||||
sourceConnectionId,
|
||||
targetConnectionId
|
||||
targetConnectionId,
|
||||
null
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -186,8 +186,11 @@ export class EnhancedDataflowControlService extends DataflowControlService {
|
||||
actionResult = await this.executeMultiConnectionUpdate(
|
||||
enhancedAction,
|
||||
sourceData,
|
||||
enhancedAction.fromTable,
|
||||
enhancedAction.targetTable,
|
||||
sourceConnectionId,
|
||||
targetConnectionId
|
||||
targetConnectionId,
|
||||
null
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -195,8 +198,11 @@ export class EnhancedDataflowControlService extends DataflowControlService {
|
||||
actionResult = await this.executeMultiConnectionDelete(
|
||||
enhancedAction,
|
||||
sourceData,
|
||||
enhancedAction.fromTable,
|
||||
enhancedAction.targetTable,
|
||||
sourceConnectionId,
|
||||
targetConnectionId
|
||||
targetConnectionId,
|
||||
null
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -241,20 +247,21 @@ export class EnhancedDataflowControlService extends DataflowControlService {
|
||||
/**
|
||||
* 🆕 다중 커넥션 INSERT 실행
|
||||
*/
|
||||
private async executeMultiConnectionInsert(
|
||||
async executeMultiConnectionInsert(
|
||||
action: EnhancedControlAction,
|
||||
sourceData: Record<string, any>,
|
||||
sourceConnectionId?: number,
|
||||
targetConnectionId?: number
|
||||
sourceTable: string,
|
||||
targetTable: string,
|
||||
fromConnectionId: number,
|
||||
toConnectionId: number,
|
||||
multiConnService: any
|
||||
): Promise<any> {
|
||||
try {
|
||||
logger.info(`다중 커넥션 INSERT 실행: action=${action.id}`);
|
||||
logger.info(`다중 커넥션 INSERT 실행: action=${action.action}`);
|
||||
|
||||
// 커넥션 ID 결정
|
||||
const fromConnId =
|
||||
sourceConnectionId || action.fromConnection?.connectionId || 0;
|
||||
const toConnId =
|
||||
targetConnectionId || action.toConnection?.connectionId || 0;
|
||||
const fromConnId = fromConnectionId || action.fromConnection?.connectionId || 0;
|
||||
const toConnId = toConnectionId || action.toConnection?.connectionId || 0;
|
||||
|
||||
// FROM 테이블에서 소스 데이터 조회 (조건이 있는 경우)
|
||||
let fromData = sourceData;
|
||||
@@ -287,7 +294,7 @@ export class EnhancedDataflowControlService extends DataflowControlService {
|
||||
|
||||
// 필드 매핑 적용
|
||||
const mappedData = this.applyFieldMappings(
|
||||
action.fieldMappings,
|
||||
action.fieldMappings || [],
|
||||
fromData
|
||||
);
|
||||
|
||||
@@ -310,20 +317,21 @@ export class EnhancedDataflowControlService extends DataflowControlService {
|
||||
/**
|
||||
* 🆕 다중 커넥션 UPDATE 실행
|
||||
*/
|
||||
private async executeMultiConnectionUpdate(
|
||||
async executeMultiConnectionUpdate(
|
||||
action: EnhancedControlAction,
|
||||
sourceData: Record<string, any>,
|
||||
sourceConnectionId?: number,
|
||||
targetConnectionId?: number
|
||||
sourceTable: string,
|
||||
targetTable: string,
|
||||
fromConnectionId: number,
|
||||
toConnectionId: number,
|
||||
multiConnService: any
|
||||
): Promise<any> {
|
||||
try {
|
||||
logger.info(`다중 커넥션 UPDATE 실행: action=${action.id}`);
|
||||
logger.info(`다중 커넥션 UPDATE 실행: action=${action.action}`);
|
||||
|
||||
// 커넥션 ID 결정
|
||||
const fromConnId =
|
||||
sourceConnectionId || action.fromConnection?.connectionId || 0;
|
||||
const toConnId =
|
||||
targetConnectionId || action.toConnection?.connectionId || 0;
|
||||
const fromConnId = fromConnectionId || action.fromConnection?.connectionId || 0;
|
||||
const toConnId = toConnectionId || action.toConnection?.connectionId || 0;
|
||||
|
||||
// UPDATE 조건 확인
|
||||
if (!action.updateConditions || action.updateConditions.length === 0) {
|
||||
@@ -382,20 +390,23 @@ export class EnhancedDataflowControlService extends DataflowControlService {
|
||||
/**
|
||||
* 🆕 다중 커넥션 DELETE 실행
|
||||
*/
|
||||
private async executeMultiConnectionDelete(
|
||||
async executeMultiConnectionDelete(
|
||||
action: EnhancedControlAction,
|
||||
sourceData: Record<string, any>,
|
||||
sourceConnectionId?: number,
|
||||
targetConnectionId?: number
|
||||
sourceTable: string,
|
||||
targetTable: string,
|
||||
fromConnectionId: number,
|
||||
toConnectionId: number,
|
||||
multiConnService: any
|
||||
): Promise<any> {
|
||||
try {
|
||||
logger.info(`다중 커넥션 DELETE 실행: action=${action.id}`);
|
||||
logger.info(`다중 커넥션 DELETE 실행: action=${action.action}`);
|
||||
|
||||
// 커넥션 ID 결정
|
||||
const fromConnId =
|
||||
sourceConnectionId || action.fromConnection?.connectionId || 0;
|
||||
fromConnectionId || action.fromConnection?.connectionId || 0;
|
||||
const toConnId =
|
||||
targetConnectionId || action.toConnection?.connectionId || 0;
|
||||
toConnectionId || action.toConnection?.connectionId || 0;
|
||||
|
||||
// DELETE 조건 확인
|
||||
if (!action.deleteConditions || action.deleteConditions.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user