논리연산자 input 크기 조절
This commit is contained in:
parent
8e6f8d2a27
commit
af08b67331
|
|
@ -35,7 +35,17 @@ interface TargetAction {
|
|||
targetTable: string;
|
||||
enabled: boolean;
|
||||
fieldMappings: FieldMapping[];
|
||||
conditions?: ConditionNode;
|
||||
conditions?: Array<{
|
||||
field: string;
|
||||
operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE";
|
||||
value: string;
|
||||
logicalOperator?: "AND" | "OR";
|
||||
}>;
|
||||
splitConfig?: {
|
||||
sourceField: string;
|
||||
delimiter: string;
|
||||
targetField: string;
|
||||
};
|
||||
description?: string;
|
||||
}
|
||||
|
||||
|
|
@ -255,6 +265,77 @@ export class EventTriggerService {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 액션별 조건들 평가 (AND/OR 연산자 지원)
|
||||
*/
|
||||
private static async evaluateActionConditions(
|
||||
conditions: Array<{
|
||||
field: string;
|
||||
operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE";
|
||||
value: string;
|
||||
logicalOperator?: "AND" | "OR";
|
||||
}>,
|
||||
data: Record<string, any>
|
||||
): Promise<boolean> {
|
||||
if (conditions.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let result = await this.evaluateActionCondition(conditions[0], data);
|
||||
|
||||
for (let i = 1; i < conditions.length; i++) {
|
||||
const prevCondition = conditions[i - 1];
|
||||
const currentCondition = conditions[i];
|
||||
const currentResult = await this.evaluateActionCondition(
|
||||
currentCondition,
|
||||
data
|
||||
);
|
||||
|
||||
if (prevCondition.logicalOperator === "OR") {
|
||||
result = result || currentResult;
|
||||
} else {
|
||||
// 기본값은 AND
|
||||
result = result && currentResult;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 액션 단일 조건 평가
|
||||
*/
|
||||
private static async evaluateActionCondition(
|
||||
condition: {
|
||||
field: string;
|
||||
operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE";
|
||||
value: string;
|
||||
},
|
||||
data: Record<string, any>
|
||||
): Promise<boolean> {
|
||||
const fieldValue = data[condition.field];
|
||||
const conditionValue = condition.value;
|
||||
|
||||
switch (condition.operator) {
|
||||
case "=":
|
||||
return fieldValue == conditionValue;
|
||||
case "!=":
|
||||
return fieldValue != conditionValue;
|
||||
case ">":
|
||||
return Number(fieldValue) > Number(conditionValue);
|
||||
case "<":
|
||||
return Number(fieldValue) < Number(conditionValue);
|
||||
case ">=":
|
||||
return Number(fieldValue) >= Number(conditionValue);
|
||||
case "<=":
|
||||
return Number(fieldValue) <= Number(conditionValue);
|
||||
case "LIKE":
|
||||
return String(fieldValue).includes(String(conditionValue));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 조건 평가
|
||||
*/
|
||||
|
|
@ -298,6 +379,20 @@ export class EventTriggerService {
|
|||
sourceData: Record<string, any>,
|
||||
companyCode: string
|
||||
): Promise<void> {
|
||||
// 액션별 조건 평가
|
||||
if (action.conditions && action.conditions.length > 0) {
|
||||
const conditionMet = await this.evaluateActionConditions(
|
||||
action.conditions,
|
||||
sourceData
|
||||
);
|
||||
if (!conditionMet) {
|
||||
logger.info(
|
||||
`Action conditions not met for action ${action.id}, skipping execution`
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 필드 매핑을 통해 대상 데이터 생성
|
||||
const targetData: Record<string, any> = {};
|
||||
|
||||
|
|
@ -329,14 +424,14 @@ export class EventTriggerService {
|
|||
await this.executeUpdateAction(
|
||||
action.targetTable,
|
||||
targetData,
|
||||
action.conditions
|
||||
null // 액션별 조건은 이미 평가했으므로 WHERE 조건은 null
|
||||
);
|
||||
break;
|
||||
case "delete":
|
||||
await this.executeDeleteAction(
|
||||
action.targetTable,
|
||||
targetData,
|
||||
action.conditions
|
||||
null // 액션별 조건은 이미 평가했으므로 WHERE 조건은 null
|
||||
);
|
||||
break;
|
||||
case "upsert":
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -36,7 +36,17 @@ export interface TargetAction {
|
|||
targetTable: string;
|
||||
enabled: boolean;
|
||||
fieldMappings: FieldMapping[];
|
||||
conditions?: ConditionNode;
|
||||
conditions?: Array<{
|
||||
field: string;
|
||||
operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE";
|
||||
value: string;
|
||||
logicalOperator?: "AND" | "OR"; // 다음 조건과의 논리 연산자
|
||||
}>;
|
||||
splitConfig?: {
|
||||
sourceField: string;
|
||||
delimiter: string;
|
||||
targetField: string;
|
||||
};
|
||||
description?: string;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue