feat: add Excel data validation functionality
- Implemented a new API endpoint for validating Excel data before upload, ensuring that required fields are not null and that unique constraints are respected. - Added frontend integration to handle validation results, displaying errors for missing required fields and duplicates within the Excel file and against existing database records. - Enhanced user experience by providing immediate feedback on data validity during the upload process. Made-with: Cursor
This commit is contained in:
@@ -372,3 +372,30 @@ export const getTableColumns = (tableName: string) => tableManagementApi.getColu
|
||||
export const updateColumnType = (tableName: string, columnName: string, settings: ColumnSettings) =>
|
||||
tableManagementApi.updateColumnSettings(tableName, columnName, settings);
|
||||
export const checkTableExists = (tableName: string) => tableManagementApi.checkTableExists(tableName);
|
||||
|
||||
// 엑셀 업로드 전 데이터 검증 API
|
||||
export interface ExcelValidationResult {
|
||||
isValid: boolean;
|
||||
notNullErrors: { row: number; column: string; label: string }[];
|
||||
uniqueInExcelErrors: { rows: number[]; column: string; label: string; value: string }[];
|
||||
uniqueInDbErrors: { row: number; column: string; label: string; value: string }[];
|
||||
summary: { notNull: number; uniqueInExcel: number; uniqueInDb: number };
|
||||
}
|
||||
|
||||
export async function validateExcelData(
|
||||
tableName: string,
|
||||
data: Record<string, any>[]
|
||||
): Promise<ApiResponse<ExcelValidationResult>> {
|
||||
try {
|
||||
const response = await apiClient.post<ApiResponse<ExcelValidationResult>>(
|
||||
"/table-management/validate-excel",
|
||||
{ tableName, data }
|
||||
);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || "데이터 검증 실패",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user