버튼 삭제 수정기능 구현

This commit is contained in:
kjs
2025-09-18 18:49:30 +09:00
parent 87f3959036
commit 004bf28d17
14 changed files with 1637 additions and 134 deletions

View File

@@ -91,6 +91,53 @@ export class DynamicFormApi {
}
}
/**
* 폼 데이터 부분 업데이트 (변경된 필드만)
* @param id 레코드 ID
* @param originalData 원본 데이터
* @param newData 변경할 데이터
* @param tableName 테이블명
* @returns 업데이트 결과
*/
static async updateFormDataPartial(
id: number,
originalData: Record<string, any>,
newData: Record<string, any>,
tableName: string,
): Promise<ApiResponse<SaveFormDataResponse>> {
try {
console.log("🔄 폼 데이터 부분 업데이트 요청:", {
id,
originalData,
newData,
tableName,
});
const response = await apiClient.patch(`/dynamic-form/${id}/partial`, {
tableName,
originalData,
newData,
});
console.log("✅ 폼 데이터 부분 업데이트 성공:", response.data);
return {
success: true,
data: response.data,
message: "데이터가 성공적으로 업데이트되었습니다.",
};
} catch (error: any) {
console.error("❌ 폼 데이터 부분 업데이트 실패:", error);
const errorMessage = error.response?.data?.message || error.message || "부분 업데이트 중 오류가 발생했습니다.";
return {
success: false,
message: errorMessage,
errorCode: error.response?.data?.errorCode,
};
}
}
/**
* 폼 데이터 삭제
* @param id 레코드 ID
@@ -313,6 +360,36 @@ export class DynamicFormApi {
};
}
}
/**
* 테이블의 기본키 조회
* @param tableName 테이블명
* @returns 기본키 컬럼명 배열
*/
static async getTablePrimaryKeys(tableName: string): Promise<ApiResponse<string[]>> {
try {
console.log("🔑 테이블 기본키 조회 요청:", tableName);
const response = await apiClient.get(`/dynamic-form/table/${tableName}/primary-keys`);
console.log("✅ 테이블 기본키 조회 성공:", response.data);
return {
success: true,
data: response.data.data,
message: "기본키 조회가 완료되었습니다.",
};
} catch (error: any) {
console.error("❌ 테이블 기본키 조회 실패:", error);
const errorMessage = error.response?.data?.message || error.message || "기본키 조회 중 오류가 발생했습니다.";
return {
success: false,
message: errorMessage,
errorCode: error.response?.data?.errorCode,
};
}
}
}
// 편의를 위한 기본 export