모달창 올리기

This commit is contained in:
kjs
2025-10-29 11:26:00 +09:00
parent eeae338cd4
commit efdef36cda
21 changed files with 727 additions and 728 deletions

View File

@@ -216,7 +216,7 @@ export const deleteFormData = async (
): Promise<Response | void> => {
try {
const { id } = req.params;
const { companyCode } = req.user as any;
const { companyCode, userId } = req.user as any;
const { tableName } = req.body;
if (!tableName) {
@@ -226,7 +226,7 @@ export const deleteFormData = async (
});
}
await dynamicFormService.deleteFormData(id, tableName); // parseInt 제거 - 문자열 ID 지원
await dynamicFormService.deleteFormData(id, tableName, companyCode, userId); // userId 추가
res.json({
success: true,

View File

@@ -64,7 +64,8 @@ export class DataflowControlService {
relationshipId: string,
triggerType: "insert" | "update" | "delete",
sourceData: Record<string, any>,
tableName: string
tableName: string,
userId: string = "system"
): Promise<{
success: boolean;
message: string;
@@ -78,6 +79,7 @@ export class DataflowControlService {
triggerType,
sourceData,
tableName,
userId,
});
// 관계도 정보 조회
@@ -238,7 +240,8 @@ export class DataflowControlService {
const actionResult = await this.executeMultiConnectionAction(
action,
sourceData,
targetPlan.sourceTable
targetPlan.sourceTable,
userId
);
executedActions.push({
@@ -288,7 +291,8 @@ export class DataflowControlService {
private async executeMultiConnectionAction(
action: ControlAction,
sourceData: Record<string, any>,
sourceTable: string
sourceTable: string,
userId: string = "system"
): Promise<any> {
try {
const extendedAction = action as any; // redesigned UI 구조 접근
@@ -321,7 +325,8 @@ export class DataflowControlService {
targetTable,
fromConnection.id,
toConnection.id,
multiConnService
multiConnService,
userId
);
case "update":
@@ -332,7 +337,8 @@ export class DataflowControlService {
targetTable,
fromConnection.id,
toConnection.id,
multiConnService
multiConnService,
userId
);
case "delete":
@@ -343,7 +349,8 @@ export class DataflowControlService {
targetTable,
fromConnection.id,
toConnection.id,
multiConnService
multiConnService,
userId
);
default:
@@ -368,7 +375,8 @@ export class DataflowControlService {
targetTable: string,
fromConnectionId: number,
toConnectionId: number,
multiConnService: any
multiConnService: any,
userId: string = "system"
): Promise<any> {
try {
// 필드 매핑 적용
@@ -387,6 +395,14 @@ export class DataflowControlService {
}
}
// 🆕 변경자 정보 추가
if (!mappedData.created_by) {
mappedData.created_by = userId;
}
if (!mappedData.updated_by) {
mappedData.updated_by = userId;
}
console.log(`📋 매핑된 데이터:`, mappedData);
// 대상 연결에 데이터 삽입
@@ -421,11 +437,32 @@ export class DataflowControlService {
targetTable: string,
fromConnectionId: number,
toConnectionId: number,
multiConnService: any
multiConnService: any,
userId: string = "system"
): Promise<any> {
try {
// UPDATE 로직 구현 (향후 확장)
// 필드 매핑 적용
const mappedData: Record<string, any> = {};
for (const mapping of action.fieldMappings) {
const sourceField = mapping.sourceField;
const targetField = mapping.targetField;
if (mapping.defaultValue !== undefined) {
mappedData[targetField] = mapping.defaultValue;
} else if (sourceField && sourceData[sourceField] !== undefined) {
mappedData[targetField] = sourceData[sourceField];
}
}
// 🆕 변경자 정보 추가
if (!mappedData.updated_by) {
mappedData.updated_by = userId;
}
console.log(`📋 UPDATE 매핑된 데이터:`, mappedData);
console.log(`⚠️ UPDATE 액션은 향후 구현 예정`);
return {
success: true,
message: "UPDATE 액션 실행됨 (향후 구현)",
@@ -449,11 +486,11 @@ export class DataflowControlService {
targetTable: string,
fromConnectionId: number,
toConnectionId: number,
multiConnService: any
multiConnService: any,
userId: string = "system"
): Promise<any> {
try {
// DELETE 로직 구현 (향후 확장)
console.log(`⚠️ DELETE 액션은 향후 구현 예정`);
console.log(`⚠️ DELETE 액션은 향후 구현 예정 (변경자: ${userId})`);
return {
success: true,
message: "DELETE 액션 실행됨 (향후 구현)",
@@ -941,7 +978,9 @@ export class DataflowControlService {
sourceData: Record<string, any>
): Promise<any> {
// 보안상 외부 DB에 대한 DELETE 작업은 비활성화
throw new Error("보안상 외부 데이터베이스에 대한 DELETE 작업은 허용되지 않습니다. SELECT 쿼리만 사용해주세요.");
throw new Error(
"보안상 외부 데이터베이스에 대한 DELETE 작업은 허용되지 않습니다. SELECT 쿼리만 사용해주세요."
);
const results = [];

View File

@@ -220,8 +220,14 @@ export class DynamicFormService {
console.log(`🔑 테이블 ${tableName}의 Primary Key:`, primaryKeys);
// 메타데이터 제거 (실제 테이블 컬럼이 아님)
const { created_by, updated_by, company_code, screen_id, ...actualData } =
data;
const {
created_by,
updated_by,
writer,
company_code,
screen_id,
...actualData
} = data;
// 기본 데이터 준비
const dataToInsert: any = { ...actualData };
@@ -236,8 +242,17 @@ export class DynamicFormService {
if (tableColumns.includes("regdate") && !dataToInsert.regdate) {
dataToInsert.regdate = new Date();
}
if (tableColumns.includes("created_date") && !dataToInsert.created_date) {
dataToInsert.created_date = new Date();
}
if (tableColumns.includes("updated_date") && !dataToInsert.updated_date) {
dataToInsert.updated_date = new Date();
}
// 성자/수정자 정보가 있고 해당 컬럼이 존재한다면 추가
// 성자 정보 추가 (writer 컬럼 우선, 없으면 created_by/updated_by)
if (writer && tableColumns.includes("writer")) {
dataToInsert.writer = writer;
}
if (created_by && tableColumns.includes("created_by")) {
dataToInsert.created_by = created_by;
}
@@ -579,7 +594,8 @@ export class DynamicFormService {
screenId,
tableName,
insertedRecord as Record<string, any>,
"insert"
"insert",
created_by || "system"
);
} catch (controlError) {
console.error("⚠️ 제어관리 실행 오류:", controlError);
@@ -876,7 +892,8 @@ export class DynamicFormService {
0, // UPDATE는 screenId를 알 수 없으므로 0으로 설정 (추후 개선 필요)
tableName,
updatedRecord as Record<string, any>,
"update"
"update",
updated_by || "system"
);
} catch (controlError) {
console.error("⚠️ 제어관리 실행 오류:", controlError);
@@ -905,7 +922,8 @@ export class DynamicFormService {
async deleteFormData(
id: string | number,
tableName: string,
companyCode?: string
companyCode?: string,
userId?: string
): Promise<void> {
try {
console.log("🗑️ 서비스: 실제 테이블에서 폼 데이터 삭제 시작:", {
@@ -1010,7 +1028,8 @@ export class DynamicFormService {
0, // DELETE는 screenId를 알 수 없으므로 0으로 설정 (추후 개선 필요)
tableName,
deletedRecord,
"delete"
"delete",
userId || "system"
);
}
} catch (controlError) {
@@ -1315,7 +1334,8 @@ export class DynamicFormService {
screenId: number,
tableName: string,
savedData: Record<string, any>,
triggerType: "insert" | "update" | "delete"
triggerType: "insert" | "update" | "delete",
userId: string = "system"
): Promise<void> {
try {
console.log(`🎯 제어관리 설정 확인 중... (screenId: ${screenId})`);
@@ -1364,7 +1384,8 @@ export class DynamicFormService {
relationshipId,
triggerType,
savedData,
tableName
tableName,
userId
);
console.log(`🎯 제어관리 실행 결과:`, controlResult);