restapi 버튼 동작

This commit is contained in:
kjs
2025-09-29 12:17:10 +09:00
parent cedb5e3ec3
commit c9afdec09f
19 changed files with 1910 additions and 81 deletions

View File

@@ -0,0 +1,19 @@
/**
* 🔥 데이터플로우 실행 라우트
*
* 버튼 제어에서 관계 실행 시 사용되는 API 엔드포인트
*/
import express from "express";
import { authenticateToken } from "../middleware/authMiddleware";
import { executeDataAction } from "../controllers/dataflowExecutionController";
const router = express.Router();
// 🔥 모든 라우트에 인증 미들웨어 적용
router.use(authenticateToken);
// 데이터 액션 실행
router.post("/execute-data-action", executeDataAction);
export default router;

View File

@@ -249,4 +249,80 @@ router.post("/:id/test", async (req: Request, res: Response) => {
}
});
/**
* 🔥 개선된 외부호출 실행 (데이터 매핑 통합)
* POST /api/external-call-configs/:id/execute
*/
router.post("/:id/execute", async (req: Request, res: Response) => {
try {
const id = parseInt(req.params.id);
if (isNaN(id)) {
return res.status(400).json({
success: false,
message: "유효하지 않은 설정 ID입니다.",
errorCode: "INVALID_CONFIG_ID",
});
}
const { requestData, contextData } = req.body;
// 사용자 정보 가져오기
const userInfo = (req as any).user;
const userId = userInfo?.userId || "SYSTEM";
const companyCode = userInfo?.companyCode || "*";
const executionResult = await externalCallConfigService.executeConfigWithDataMapping(
id,
requestData || {},
{
...contextData,
userId,
companyCode,
executedAt: new Date().toISOString(),
}
);
return res.json({
success: executionResult.success,
message: executionResult.message,
data: executionResult.data,
executionTime: executionResult.executionTime,
error: executionResult.error,
});
} catch (error) {
logger.error("외부호출 실행 API 오류:", error);
return res.status(500).json({
success: false,
message: error instanceof Error ? error.message : "외부호출 실행 실패",
errorCode: "EXTERNAL_CALL_EXECUTE_ERROR",
});
}
});
/**
* 🔥 버튼 제어용 외부호출 목록 조회 (간소화된 정보)
* GET /api/external-call-configs/for-button-control
*/
router.get("/for-button-control", async (req: Request, res: Response) => {
try {
const userInfo = (req as any).user;
const companyCode = userInfo?.companyCode || "*";
const configs = await externalCallConfigService.getConfigsForButtonControl(companyCode);
return res.json({
success: true,
data: configs,
message: `버튼 제어용 외부호출 설정 ${configs.length}개 조회 완료`,
});
} catch (error) {
logger.error("버튼 제어용 외부호출 설정 조회 API 오류:", error);
return res.status(500).json({
success: false,
message: error instanceof Error ? error.message : "외부호출 설정 조회 실패",
errorCode: "EXTERNAL_CALL_BUTTON_CONTROL_LIST_ERROR",
});
}
});
export default router;

View File

@@ -14,6 +14,7 @@ import {
executeOptimizedButton,
executeSimpleDataflow,
getJobStatus,
getAllRelationships,
} from "../controllers/buttonDataflowController";
import { AuthenticatedRequest } from "../types/auth";
import config from "../config/environment";
@@ -52,6 +53,9 @@ if (config.nodeEnv !== "production") {
// 특정 관계도의 관계 목록 조회
router.get("/diagrams/:diagramId/relationships", getDiagramRelationships);
// 🔥 전체 관계 목록 조회 (버튼 제어용)
router.get("/relationships/all", getAllRelationships);
// 관계 미리보기 정보 조회
router.get(
"/diagrams/:diagramId/relationships/:relationshipId/preview",