실행 조건 구현

This commit is contained in:
2025-09-12 11:33:54 +09:00
parent f50dd520ae
commit 3344a5785c
5 changed files with 79 additions and 177 deletions

View File

@@ -16,7 +16,7 @@ export async function testConditionalConnection(
const { diagramId } = req.params;
const { testData } = req.body;
const companyCode = req.user?.company_code;
const companyCode = req.user?.companyCode;
if (!companyCode) {
const response: ApiResponse<null> = {
@@ -86,7 +86,7 @@ export async function executeConditionalActions(
const { diagramId } = req.params;
const { triggerType, tableName, data } = req.body;
const companyCode = req.user?.company_code;
const companyCode = req.user?.companyCode;
if (!companyCode) {
const response: ApiResponse<null> = {

View File

@@ -1,5 +1,5 @@
import { PrismaClient } from "@prisma/client";
import { logger } from "../config/logger.js";
import { logger } from "../utils/logger";
const prisma = new PrismaClient();
@@ -9,24 +9,7 @@ interface ConditionNode {
operator?: "AND" | "OR";
children?: ConditionNode[];
field?: string;
operator_type?:
| "="
| "!="
| ">"
| "<"
| ">="
| "<="
| "LIKE"
| "NOT_LIKE"
| "CONTAINS"
| "STARTS_WITH"
| "ENDS_WITH"
| "IN"
| "NOT_IN"
| "IS_NULL"
| "IS_NOT_NULL"
| "BETWEEN"
| "NOT_BETWEEN";
operator_type?: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE";
value?: any;
dataType?: string;
}
@@ -164,9 +147,9 @@ export class EventTriggerService {
const errors: string[] = [];
try {
const control = diagram.control as ConditionControl;
const category = diagram.category as ConnectionCategory;
const plan = diagram.plan as ExecutionPlan;
const control = diagram.control as unknown as ConditionControl;
const category = diagram.category as unknown as ConnectionCategory;
const plan = diagram.plan as unknown as ExecutionPlan;
logger.info(
`Executing diagram ${diagram.diagram_id} (${diagram.diagram_name})`
@@ -302,38 +285,6 @@ export class EventTriggerService {
return Number(fieldValue) <= Number(value);
case "LIKE":
return String(fieldValue).includes(String(value));
case "NOT_LIKE":
return !String(fieldValue).includes(String(value));
case "CONTAINS":
return String(fieldValue)
.toLowerCase()
.includes(String(value).toLowerCase());
case "STARTS_WITH":
return String(fieldValue).startsWith(String(value));
case "ENDS_WITH":
return String(fieldValue).endsWith(String(value));
case "IN":
return Array.isArray(value) && value.includes(fieldValue);
case "NOT_IN":
return Array.isArray(value) && !value.includes(fieldValue);
case "IS_NULL":
return fieldValue == null || fieldValue === undefined;
case "IS_NOT_NULL":
return fieldValue != null && fieldValue !== undefined;
case "BETWEEN":
if (Array.isArray(value) && value.length === 2) {
const numValue = Number(fieldValue);
return numValue >= Number(value[0]) && numValue <= Number(value[1]);
}
return false;
case "NOT_BETWEEN":
if (Array.isArray(value) && value.length === 2) {
const numValue = Number(fieldValue);
return !(
numValue >= Number(value[0]) && numValue <= Number(value[1])
);
}
return false;
default:
return false;
}
@@ -553,7 +504,7 @@ export class EventTriggerService {
throw new Error(`Diagram ${diagramId} not found`);
}
const control = diagram.control as ConditionControl;
const control = diagram.control as unknown as ConditionControl;
// 조건 평가만 수행
const conditionMet = control.conditionTree