테이블 변경 이력 로그 시스템 구현
This commit is contained in:
@@ -211,6 +211,114 @@ class TableManagementApi {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// 테이블 로그 시스템 API
|
||||
// ========================================
|
||||
|
||||
/**
|
||||
* 로그 테이블 생성
|
||||
*/
|
||||
async createLogTable(
|
||||
tableName: string,
|
||||
pkColumn: { columnName: string; dataType: string },
|
||||
): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await apiClient.post(`${this.basePath}/tables/${tableName}/log`, { pkColumn });
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error(`❌ 로그 테이블 생성 실패: ${tableName}`, error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || error.message || "로그 테이블을 생성할 수 없습니다.",
|
||||
errorCode: error.response?.data?.errorCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 설정 조회
|
||||
*/
|
||||
async getLogConfig(tableName: string): Promise<
|
||||
ApiResponse<{
|
||||
originalTableName: string;
|
||||
logTableName: string;
|
||||
triggerName: string;
|
||||
triggerFunctionName: string;
|
||||
isActive: string;
|
||||
createdAt: Date;
|
||||
createdBy: string;
|
||||
} | null>
|
||||
> {
|
||||
try {
|
||||
const response = await apiClient.get(`${this.basePath}/tables/${tableName}/log/config`);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error(`❌ 로그 설정 조회 실패: ${tableName}`, error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || error.message || "로그 설정을 조회할 수 없습니다.",
|
||||
errorCode: error.response?.data?.errorCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 데이터 조회
|
||||
*/
|
||||
async getLogData(
|
||||
tableName: string,
|
||||
options: {
|
||||
page?: number;
|
||||
size?: number;
|
||||
operationType?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
changedBy?: string;
|
||||
originalId?: string;
|
||||
} = {},
|
||||
): Promise<
|
||||
ApiResponse<{
|
||||
data: any[];
|
||||
total: number;
|
||||
page: number;
|
||||
size: number;
|
||||
totalPages: number;
|
||||
}>
|
||||
> {
|
||||
try {
|
||||
const response = await apiClient.get(`${this.basePath}/tables/${tableName}/log`, {
|
||||
params: options,
|
||||
});
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error(`❌ 로그 데이터 조회 실패: ${tableName}`, error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || error.message || "로그 데이터를 조회할 수 없습니다.",
|
||||
errorCode: error.response?.data?.errorCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 테이블 활성화/비활성화
|
||||
*/
|
||||
async toggleLogTable(tableName: string, isActive: boolean): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await apiClient.post(`${this.basePath}/tables/${tableName}/log/toggle`, {
|
||||
isActive,
|
||||
});
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error(`❌ 로그 테이블 토글 실패: ${tableName}`, error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.response?.data?.message || error.message || "로그 테이블 설정을 변경할 수 없습니다.",
|
||||
errorCode: error.response?.data?.errorCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 싱글톤 인스턴스 생성
|
||||
|
||||
Reference in New Issue
Block a user