chore(테이블관리): 사소 3건 정리 (PR-D) — 디버그 로그 / dead code / 에러 메시지
1. 운영 console.log/warn 제거 (G15) — page.tsx 의 이모지 prefix 디버그 로그 (🔍 🔄 ✅ 🗑️ 📥 📊 📋) 일괄 제거. catch 블록의 console.error 는 추적용으로 유지. CreateTableModal 의 컬럼 조회 디버그 로그도 정리. 2. useLogTable dead code 정리 (G16) — CreateTableModal 의 useLogTable state, handleCreateTable 분기, 주석 처리된 체크박스 UI 모두 제거. 시그니처 안 맞는 createLogTable 호출 페이로드까지 같이 사라짐. Activity / Checkbox import 도 필요 없어졌으므로 제거. 3. 에러 메시지 일관화 (G17) — DdlController 와 TableManagementController 의 "최고 관리자 권한이 필요합니다." 메시지 모두 "최고 관리자(SUPER_ADMIN) 권한이 필요합니다." 로 통일. 일반 ADMIN 권한 메시지는 그대로 유지. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ public class DdlController {
|
|||||||
@RequestBody Map<String, Object> body) {
|
@RequestBody Map<String, Object> body) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
String tableName = (String) body.get("table_name");
|
String tableName = (String) body.get("table_name");
|
||||||
@@ -71,7 +71,7 @@ public class DdlController {
|
|||||||
@RequestBody Map<String, Object> body) {
|
@RequestBody Map<String, Object> body) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -105,7 +105,7 @@ public class DdlController {
|
|||||||
@RequestAttribute("user_id") String userId) {
|
@RequestAttribute("user_id") String userId) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> result = ddlService.dropColumn(tableName, columnName, companyCode, userId);
|
Map<String, Object> result = ddlService.dropColumn(tableName, columnName, companyCode, userId);
|
||||||
@@ -131,7 +131,7 @@ public class DdlController {
|
|||||||
@RequestAttribute("user_id") String userId) {
|
@RequestAttribute("user_id") String userId) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> result = ddlService.dropTable(tableName, companyCode, userId);
|
Map<String, Object> result = ddlService.dropTable(tableName, companyCode, userId);
|
||||||
@@ -155,7 +155,7 @@ public class DdlController {
|
|||||||
@RequestBody Map<String, Object> body) {
|
@RequestBody Map<String, Object> body) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
String tableName = (String) body.get("table_name");
|
String tableName = (String) body.get("table_name");
|
||||||
@@ -187,7 +187,7 @@ public class DdlController {
|
|||||||
@RequestParam(required = false) String ddlType) {
|
@RequestParam(required = false) String ddlType) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> logs = ddlService.getDdlLogs(limit, userId, ddlType);
|
List<Map<String, Object>> logs = ddlService.getDdlLogs(limit, userId, ddlType);
|
||||||
@@ -206,7 +206,7 @@ public class DdlController {
|
|||||||
@RequestParam(required = false) String toDate) {
|
@RequestParam(required = false) String toDate) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> statistics = ddlService.getDdlStatistics(fromDate, toDate);
|
Map<String, Object> statistics = ddlService.getDdlStatistics(fromDate, toDate);
|
||||||
@@ -223,7 +223,7 @@ public class DdlController {
|
|||||||
@RequestAttribute(value = "role", required = false) String role) {
|
@RequestAttribute(value = "role", required = false) String role) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> history = ddlService.getTableDdlHistory(tableName);
|
List<Map<String, Object>> history = ddlService.getTableDdlHistory(tableName);
|
||||||
@@ -242,7 +242,7 @@ public class DdlController {
|
|||||||
@RequestAttribute(value = "role", required = false) String role) {
|
@RequestAttribute(value = "role", required = false) String role) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> tableInfo = ddlService.getTableInfo(tableName);
|
Map<String, Object> tableInfo = ddlService.getTableInfo(tableName);
|
||||||
@@ -268,7 +268,7 @@ public class DdlController {
|
|||||||
@RequestParam(required = false, defaultValue = "90") int retentionDays) {
|
@RequestParam(required = false, defaultValue = "90") int retentionDays) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
int deletedCount = ddlService.cleanupOldLogs(retentionDays);
|
int deletedCount = ddlService.cleanupOldLogs(retentionDays);
|
||||||
@@ -286,7 +286,7 @@ public class DdlController {
|
|||||||
@RequestAttribute(value = "role", required = false) String role) {
|
@RequestAttribute(value = "role", required = false) String role) {
|
||||||
|
|
||||||
if (!isSuperAdmin(companyCode, role)) {
|
if (!isSuperAdmin(companyCode, role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok(ApiResponse.success(Map.of(
|
return ResponseEntity.ok(ApiResponse.success(Map.of(
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ public class TableManagementController {
|
|||||||
@RequestBody Map<String, Object> body,
|
@RequestBody Map<String, Object> body,
|
||||||
@RequestAttribute("role") String role) {
|
@RequestAttribute("role") String role) {
|
||||||
if (!isSuperAdmin(role)) {
|
if (!isSuperAdmin(role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> columns = (List<String>) body.get("columns");
|
List<String> columns = (List<String>) body.get("columns");
|
||||||
@@ -293,7 +293,7 @@ public class TableManagementController {
|
|||||||
@RequestBody Map<String, Object> body,
|
@RequestBody Map<String, Object> body,
|
||||||
@RequestAttribute("role") String role) {
|
@RequestAttribute("role") String role) {
|
||||||
if (!isSuperAdmin(role)) {
|
if (!isSuperAdmin(role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
String columnName = (String) body.get("column_name");
|
String columnName = (String) body.get("column_name");
|
||||||
String indexType = (String) body.get("index_type");
|
String indexType = (String) body.get("index_type");
|
||||||
@@ -322,7 +322,7 @@ public class TableManagementController {
|
|||||||
@RequestAttribute("role") String role,
|
@RequestAttribute("role") String role,
|
||||||
@RequestAttribute("company_code") String companyCode) {
|
@RequestAttribute("company_code") String companyCode) {
|
||||||
if (!isSuperAdmin(role)) {
|
if (!isSuperAdmin(role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
Object nullableObj = body.get("nullable");
|
Object nullableObj = body.get("nullable");
|
||||||
if (tableName == null || columnName == null || !(nullableObj instanceof Boolean)) {
|
if (tableName == null || columnName == null || !(nullableObj instanceof Boolean)) {
|
||||||
@@ -344,7 +344,7 @@ public class TableManagementController {
|
|||||||
@RequestAttribute("role") String role,
|
@RequestAttribute("role") String role,
|
||||||
@RequestAttribute("company_code") String companyCode) {
|
@RequestAttribute("company_code") String companyCode) {
|
||||||
if (!isSuperAdmin(role)) {
|
if (!isSuperAdmin(role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
Object uniqueObj = body.get("unique");
|
Object uniqueObj = body.get("unique");
|
||||||
if (tableName == null || columnName == null || !(uniqueObj instanceof Boolean)) {
|
if (tableName == null || columnName == null || !(uniqueObj instanceof Boolean)) {
|
||||||
@@ -569,7 +569,7 @@ public class TableManagementController {
|
|||||||
@RequestBody Map<String, Object> body,
|
@RequestBody Map<String, Object> body,
|
||||||
@RequestAttribute("role") String role) {
|
@RequestAttribute("role") String role) {
|
||||||
if (!isSuperAdmin(role)) {
|
if (!isSuperAdmin(role)) {
|
||||||
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자 권한이 필요합니다."));
|
return ResponseEntity.status(403).body(ApiResponse.error("최고 관리자(SUPER_ADMIN) 권한이 필요합니다."));
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> logColumns = (List<String>) body.get("log_columns");
|
List<String> logColumns = (List<String>) body.get("log_columns");
|
||||||
|
|||||||
@@ -279,11 +279,9 @@ export default function TableManagementPage() {
|
|||||||
if (response.success && response.data) {
|
if (response.success && response.data) {
|
||||||
setSecondLevelMenus(response.data);
|
setSecondLevelMenus(response.data);
|
||||||
} else {
|
} else {
|
||||||
console.warn("⚠️ 2레벨 메뉴 로드 실패:", response);
|
|
||||||
setSecondLevelMenus([]); // 빈 배열로 설정하여 로딩 상태 해제
|
setSecondLevelMenus([]); // 빈 배열로 설정하여 로딩 상태 해제
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ 2레벨 메뉴 로드 에러:", error);
|
|
||||||
setSecondLevelMenus([]); // 에러 발생 시에도 빈 배열로 설정
|
setSecondLevelMenus([]); // 에러 발생 시에도 빈 배열로 설정
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -326,12 +324,6 @@ export default function TableManagementPage() {
|
|||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
const data = response.data.data;
|
const data = response.data.data;
|
||||||
|
|
||||||
console.log("📥 원본 API 응답:", {
|
|
||||||
hasColumns: !!(data.columns || data),
|
|
||||||
firstColumn: (data.columns || data)[0],
|
|
||||||
statusColumn: (data.columns || data).find((col: any) => col.column_name === "status"),
|
|
||||||
});
|
|
||||||
|
|
||||||
// 컬럼 데이터에 기본값 설정
|
// 컬럼 데이터에 기본값 설정
|
||||||
const processedColumns = (data.columns || data).map((col: any) => {
|
const processedColumns = (data.columns || data).map((col: any) => {
|
||||||
let hierarchyRole: "large" | "medium" | "small" | undefined = undefined;
|
let hierarchyRole: "large" | "medium" | "small" | undefined = undefined;
|
||||||
@@ -648,7 +640,6 @@ export default function TableManagementPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
finalDetailSettings = JSON.stringify(entitySettings);
|
finalDetailSettings = JSON.stringify(entitySettings);
|
||||||
console.log("🔧 Entity 설정 JSON 생성:", entitySettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🎯 Code 타입인 경우 hierarchyRole을 detailSettings에 포함
|
// 🎯 Code 타입인 경우 hierarchyRole을 detailSettings에 포함
|
||||||
@@ -668,7 +659,6 @@ export default function TableManagementPage() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
finalDetailSettings = JSON.stringify(codeSettings);
|
finalDetailSettings = JSON.stringify(codeSettings);
|
||||||
console.log("🔧 Code 계층 역할 설정 JSON 생성:", codeSettings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const columnSetting = {
|
const columnSetting = {
|
||||||
@@ -686,49 +676,22 @@ export default function TableManagementPage() {
|
|||||||
|
|
||||||
// console.log("저장할 컬럼 설정:", columnSetting);
|
// console.log("저장할 컬럼 설정:", columnSetting);
|
||||||
|
|
||||||
console.log("💾 저장할 컬럼 정보:", {
|
|
||||||
columnName: column.column_name,
|
|
||||||
inputType: column.input_type,
|
|
||||||
categoryMenus: column.category_menus,
|
|
||||||
hasCategoryMenus: !!column.category_menus,
|
|
||||||
categoryMenusLength: column.category_menus?.length || 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await apiClient.post(`/table-management/tables/${selectedTable}/columns/settings`, [
|
const response = await apiClient.post(`/table-management/tables/${selectedTable}/columns/settings`, [
|
||||||
columnSetting,
|
columnSetting,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (response.data.success) {
|
if (response.data.success) {
|
||||||
console.log("✅ 컬럼 설정 저장 성공");
|
|
||||||
|
|
||||||
// 🆕 Category 타입인 경우 컬럼 매핑 처리
|
// 🆕 Category 타입인 경우 컬럼 매핑 처리
|
||||||
console.log("🔍 카테고리 조건 체크:", {
|
|
||||||
isCategory: column.input_type === "category",
|
|
||||||
hasCategoryMenus: !!column.category_menus,
|
|
||||||
length: column.category_menus?.length || 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (column.input_type === "category" && !column.category_ref) {
|
if (column.input_type === "category" && !column.category_ref) {
|
||||||
// 참조가 아닌 자체 카테고리만 메뉴 매핑 처리
|
// 참조가 아닌 자체 카테고리만 메뉴 매핑 처리
|
||||||
console.log("기존 카테고리 메뉴 매핑 삭제 시작:", {
|
|
||||||
tableName: selectedTable,
|
|
||||||
columnName: column.column_name,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const deleteResponse = await deleteColumnMappingsByColumn(selectedTable, column.column_name);
|
await deleteColumnMappingsByColumn(selectedTable, column.column_name);
|
||||||
console.log("🗑️ 기존 매핑 삭제 결과:", deleteResponse);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ 기존 매핑 삭제 실패:", error);
|
console.error("❌ 기존 매핑 삭제 실패:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 새로운 매핑 추가 (선택된 메뉴가 있는 경우만)
|
// 2. 새로운 매핑 추가 (선택된 메뉴가 있는 경우만)
|
||||||
if (column.category_menus && column.category_menus.length > 0) {
|
if (column.category_menus && column.category_menus.length > 0) {
|
||||||
console.log("📥 카테고리 메뉴 매핑 시작:", {
|
|
||||||
columnName: column.column_name,
|
|
||||||
categoryMenus: column.category_menus,
|
|
||||||
count: column.category_menus.length,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 직렬 await 대신 Promise.allSettled 로 병렬 호출 (메뉴가 많으면 직렬은 수십 초 멈춤)
|
// 직렬 await 대신 Promise.allSettled 로 병렬 호출 (메뉴가 많으면 직렬은 수십 초 멈춤)
|
||||||
const mappingResults = await Promise.allSettled(
|
const mappingResults = await Promise.allSettled(
|
||||||
@@ -890,29 +853,14 @@ export default function TableManagementPage() {
|
|||||||
// 자체 카테고리 컬럼만 메뉴 매핑 처리 (참조 컬럼 제외)
|
// 자체 카테고리 컬럼만 메뉴 매핑 처리 (참조 컬럼 제외)
|
||||||
const categoryColumns = columns.filter((col) => col.input_type === "category" && !col.category_ref);
|
const categoryColumns = columns.filter((col) => col.input_type === "category" && !col.category_ref);
|
||||||
|
|
||||||
console.log("📥 전체 저장: 카테고리 컬럼 확인", {
|
|
||||||
totalColumns: columns.length,
|
|
||||||
categoryColumns: categoryColumns.length,
|
|
||||||
categoryColumnsData: categoryColumns.map((col) => ({
|
|
||||||
columnName: col.column_name,
|
|
||||||
categoryMenus: col.category_menus,
|
|
||||||
})),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (categoryColumns.length > 0) {
|
if (categoryColumns.length > 0) {
|
||||||
let totalSuccessCount = 0;
|
let totalSuccessCount = 0;
|
||||||
let totalFailCount = 0;
|
let totalFailCount = 0;
|
||||||
|
|
||||||
for (const column of categoryColumns) {
|
for (const column of categoryColumns) {
|
||||||
// 1. 먼저 기존 매핑 모두 삭제
|
// 1. 먼저 기존 매핑 모두 삭제
|
||||||
console.log("🗑️ 기존 카테고리 메뉴 매핑 삭제:", {
|
|
||||||
tableName: selectedTable,
|
|
||||||
columnName: column.column_name,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const deleteResponse = await deleteColumnMappingsByColumn(selectedTable, column.column_name);
|
await deleteColumnMappingsByColumn(selectedTable, column.column_name);
|
||||||
console.log("🗑️ 기존 매핑 삭제 결과:", deleteResponse);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("❌ 기존 매핑 삭제 실패:", error);
|
console.error("❌ 기존 매핑 삭제 실패:", error);
|
||||||
}
|
}
|
||||||
@@ -938,8 +886,6 @@ export default function TableManagementPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("📊 전체 매핑 결과:", { totalSuccessCount, totalFailCount });
|
|
||||||
|
|
||||||
if (totalSuccessCount > 0) {
|
if (totalSuccessCount > 0) {
|
||||||
toast.success(`테이블 설정 및 ${totalSuccessCount}개 카테고리 메뉴 매핑이 저장되었습니다.`);
|
toast.success(`테이블 설정 및 ${totalSuccessCount}개 카테고리 메뉴 매핑이 저장되었습니다.`);
|
||||||
} else if (totalFailCount > 0) {
|
} else if (totalFailCount > 0) {
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ import { Input } from "@/components/ui/input";
|
|||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Loader2, Info, AlertCircle, CheckCircle2, Plus } from "lucide-react";
|
||||||
import { Loader2, Info, AlertCircle, CheckCircle2, Plus, Activity } from "lucide-react";
|
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { ColumnDefinitionTable } from "./ColumnDefinitionTable";
|
import { ColumnDefinitionTable } from "./ColumnDefinitionTable";
|
||||||
import { ddlApi } from "../../lib/api/ddl";
|
import { ddlApi } from "../../lib/api/ddl";
|
||||||
@@ -57,8 +56,6 @@ export function CreateTableModal({
|
|||||||
const [validating, setValidating] = useState(false);
|
const [validating, setValidating] = useState(false);
|
||||||
const [tableNameError, setTableNameError] = useState("");
|
const [tableNameError, setTableNameError] = useState("");
|
||||||
const [validationResult, setValidationResult] = useState<any>(null);
|
const [validationResult, setValidationResult] = useState<any>(null);
|
||||||
const [useLogTable, setUseLogTable] = useState(false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 모달 리셋
|
* 모달 리셋
|
||||||
*/
|
*/
|
||||||
@@ -76,7 +73,6 @@ export function CreateTableModal({
|
|||||||
]);
|
]);
|
||||||
setTableNameError("");
|
setTableNameError("");
|
||||||
setValidationResult(null);
|
setValidationResult(null);
|
||||||
setUseLogTable(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,14 +104,10 @@ export function CreateTableModal({
|
|||||||
// 1. 테이블 컬럼 정보 조회
|
// 1. 테이블 컬럼 정보 조회
|
||||||
const columnsResponse = await tableManagementApi.getColumnList(tableName);
|
const columnsResponse = await tableManagementApi.getColumnList(tableName);
|
||||||
|
|
||||||
console.log("🔍 컬럼 조회 응답:", columnsResponse);
|
|
||||||
|
|
||||||
if (columnsResponse.success && columnsResponse.data) {
|
if (columnsResponse.success && columnsResponse.data) {
|
||||||
// API는 { columns, total, page, size } 형태로 반환
|
// API는 { columns, total, page, size } 형태로 반환
|
||||||
const columnsList = columnsResponse.data.columns;
|
const columnsList = columnsResponse.data.columns;
|
||||||
|
|
||||||
console.log("🔍 컬럼 리스트:", columnsList);
|
|
||||||
|
|
||||||
if (columnsList && columnsList.length > 0) {
|
if (columnsList && columnsList.length > 0) {
|
||||||
// 첫 번째 컬럼에서 테이블 설명 가져오기 (모든 컬럼이 같은 테이블 설명을 가짐)
|
// 첫 번째 컬럼에서 테이블 설명 가져오기 (모든 컬럼이 같은 테이블 설명을 가짐)
|
||||||
const firstColumn = columnsList[0];
|
const firstColumn = columnsList[0];
|
||||||
@@ -285,23 +277,6 @@ export function CreateTableModal({
|
|||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
toast.success(result.message);
|
toast.success(result.message);
|
||||||
|
|
||||||
// 로그 테이블 생성 옵션이 선택되었다면 로그 테이블 생성
|
|
||||||
if (useLogTable) {
|
|
||||||
try {
|
|
||||||
const pkColumn = { columnName: "id", dataType: "integer" };
|
|
||||||
const logResult = await tableManagementApi.createLogTable(tableName, pkColumn);
|
|
||||||
|
|
||||||
if (logResult.success) {
|
|
||||||
toast.success(`${tableName}_log 테이블이 생성되었습니다.`);
|
|
||||||
} else {
|
|
||||||
toast.warning(`테이블은 생성되었으나 로그 테이블 생성 실패: ${logResult.message}`);
|
|
||||||
}
|
|
||||||
} catch (logError) {
|
|
||||||
toast.warning("테이블은 생성되었으나 로그 테이블 생성 중 오류가 발생했습니다.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onSuccess(result);
|
onSuccess(result);
|
||||||
onClose();
|
onClose();
|
||||||
} else {
|
} else {
|
||||||
@@ -380,29 +355,6 @@ export function CreateTableModal({
|
|||||||
<ColumnDefinitionTable columns={columns} onChange={setColumns} disabled={loading} />
|
<ColumnDefinitionTable columns={columns} onChange={setColumns} disabled={loading} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 로그 테이블 생성 옵션 - 통합 변경 이력 시스템으로 대체됨 (숨김 처리) */}
|
|
||||||
{/* <div className="flex items-start space-x-3 rounded-lg border p-4">
|
|
||||||
<Checkbox
|
|
||||||
id="useLogTable"
|
|
||||||
checked={useLogTable}
|
|
||||||
onCheckedChange={(checked) => setUseLogTable(checked as boolean)}
|
|
||||||
disabled={loading}
|
|
||||||
/>
|
|
||||||
<div className="grid gap-1.5 leading-none">
|
|
||||||
<label
|
|
||||||
htmlFor="useLogTable"
|
|
||||||
className="flex cursor-pointer items-center gap-2 text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
||||||
>
|
|
||||||
<Activity className="h-4 w-4" />
|
|
||||||
변경 이력 로그 테이블 생성
|
|
||||||
</label>
|
|
||||||
<p className="text-muted-foreground text-xs">
|
|
||||||
선택 시 <code className="bg-muted rounded px-1 py-0.5">{tableName || "table"}_log</code> 테이블이
|
|
||||||
자동으로 생성되어 INSERT/UPDATE/DELETE 변경 이력을 기록합니다.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div> */}
|
|
||||||
|
|
||||||
{/* 자동 추가 컬럼 안내 */}
|
{/* 자동 추가 컬럼 안내 */}
|
||||||
<Alert>
|
<Alert>
|
||||||
<Info className="h-4 w-4" />
|
<Info className="h-4 w-4" />
|
||||||
|
|||||||
Reference in New Issue
Block a user