restapi 버튼 동작

This commit is contained in:
kjs
2025-09-29 12:17:10 +09:00
parent cedb5e3ec3
commit c9afdec09f
19 changed files with 1910 additions and 81 deletions

View File

@@ -89,7 +89,7 @@ export const DataFlowDesigner: React.FC<DataFlowDesignerProps> = ({
return;
}, []);
// 편집 모드일 때 관계 데이터 로드
// 편집 모드일 때 관계 데이터 로드
useEffect(() => {
const loadDiagramData = async () => {
if (diagramId && diagramId > 0) {
@@ -99,7 +99,7 @@ export const DataFlowDesigner: React.FC<DataFlowDesignerProps> = ({
const jsonDiagram = await DataFlowAPI.getJsonDataFlowDiagramById(diagramId, companyCode);
if (jsonDiagram) {
// 관계 이름 설정
// 관계 이름 설정
if (jsonDiagram.diagram_name) {
setCurrentDiagramName(jsonDiagram.diagram_name);
}

View File

@@ -96,14 +96,14 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
setTotal(response.pagination.total || 0);
setTotalPages(Math.max(1, Math.ceil((response.pagination.total || 0) / 20)));
} catch (error) {
console.error("관계 목록 조회 실패", error);
toast.error("관계 목록을 불러오는데 실패했습니다.");
console.error("관계 목록 조회 실패", error);
toast.error("관계 목록을 불러오는데 실패했습니다.");
} finally {
setLoading(false);
}
}, [currentPage, searchTerm, companyCode]);
// 관계 목록 로드
// 관계 목록 로드
useEffect(() => {
loadDiagrams();
}, [loadDiagrams]);
@@ -130,13 +130,13 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
undefined,
user?.userId || "SYSTEM",
);
toast.success(`관계가 성공적으로 복사되었습니다: ${copiedDiagram.diagram_name}`);
toast.success(`관계가 성공적으로 복사되었습니다: ${copiedDiagram.diagram_name}`);
// 목록 새로고침
await loadDiagrams();
} catch (error) {
console.error("관계 복사 실패:", error);
toast.error("관계 복사에 실패했습니다.");
console.error("관계 복사 실패:", error);
toast.error("관계 복사에 실패했습니다.");
} finally {
setLoading(false);
setShowCopyModal(false);
@@ -151,13 +151,13 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
try {
setLoading(true);
await DataFlowAPI.deleteJsonDataFlowDiagram(selectedDiagramForAction.diagramId, companyCode);
toast.success(`관계가 삭제되었습니다: ${selectedDiagramForAction.diagramName}`);
toast.success(`관계가 삭제되었습니다: ${selectedDiagramForAction.diagramName}`);
// 목록 새로고침
await loadDiagrams();
} catch (error) {
console.error("관계 삭제 실패:", error);
toast.error("관계 삭제에 실패했습니다.");
console.error("관계 삭제 실패:", error);
toast.error("관계 삭제에 실패했습니다.");
} finally {
setLoading(false);
setShowDeleteModal(false);
@@ -181,7 +181,7 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
<div className="relative">
<Search className="absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 transform text-gray-400" />
<Input
placeholder="관계명, 테이블명으로 검색..."
placeholder="관계명, 테이블명으로 검색..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="w-80 pl-10"
@@ -189,17 +189,17 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
</div>
</div>
<Button className="bg-blue-600 hover:bg-blue-700" onClick={() => onDesignDiagram(null)}>
<Plus className="mr-2 h-4 w-4" />
<Plus className="mr-2 h-4 w-4" />
</Button>
</div>
{/* 관계 목록 테이블 */}
{/* 관계 목록 테이블 */}
<Card>
<CardHeader>
<CardTitle className="flex items-center justify-between">
<span className="flex items-center">
<Network className="mr-2 h-5 w-5" />
({total})
({total})
</span>
</CardTitle>
</CardHeader>
@@ -207,7 +207,7 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
<Table>
<TableHeader>
<TableRow>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead> </TableHead>
<TableHead> </TableHead>
<TableHead> </TableHead>
@@ -284,8 +284,8 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
{diagrams.length === 0 && (
<div className="py-8 text-center text-gray-500">
<Network className="mx-auto mb-4 h-12 w-12 text-gray-300" />
<div className="mb-2 text-lg font-medium"> </div>
<div className="text-sm"> .</div>
<div className="mb-2 text-lg font-medium"> </div>
<div className="text-sm"> .</div>
</div>
)}
</CardContent>
@@ -320,11 +320,11 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
<Dialog open={showCopyModal} onOpenChange={setShowCopyModal}>
<DialogContent>
<DialogHeader>
<DialogTitle> </DialogTitle>
<DialogTitle> </DialogTitle>
<DialogDescription>
&ldquo;{selectedDiagramForAction?.diagramName}&rdquo; ?
&ldquo;{selectedDiagramForAction?.diagramName}&rdquo; ?
<br />
(1), (2), (3)... .
(1), (2), (3)... .
</DialogDescription>
</DialogHeader>
<DialogFooter>
@@ -342,9 +342,9 @@ export default function DataFlowList({ onDesignDiagram }: DataFlowListProps) {
<Dialog open={showDeleteModal} onOpenChange={setShowDeleteModal}>
<DialogContent>
<DialogHeader>
<DialogTitle className="text-red-600"> </DialogTitle>
<DialogTitle className="text-red-600"> </DialogTitle>
<DialogDescription>
&ldquo;{selectedDiagramForAction?.diagramName}&rdquo; ?
&ldquo;{selectedDiagramForAction?.diagramName}&rdquo; ?
<br />
<span className="font-medium text-red-600">
, .

View File

@@ -65,7 +65,7 @@ export const DataFlowSidebar: React.FC<DataFlowSidebarProps> = ({
hasUnsavedChanges ? "animate-pulse" : ""
}`}
>
💾 {tempRelationships.length > 0 && `(${tempRelationships.length})`}
💾 {tempRelationships.length > 0 && `(${tempRelationships.length})`}
</button>
</div>

View File

@@ -622,7 +622,57 @@ const DataConnectionDesigner: React.FC<DataConnectionDesignerProps> = ({
company_code: "*", // 기본값
};
const configResult = await ExternalCallConfigAPI.createConfig(configData);
let configResult;
if (diagramId) {
// 수정 모드: 기존 설정이 있는지 확인하고 업데이트 또는 생성
console.log("🔄 수정 모드 - 외부호출 설정 처리");
try {
// 먼저 기존 설정 조회 시도
const existingConfigs = await ExternalCallConfigAPI.getConfigs({
company_code: "*",
is_active: "Y",
});
const existingConfig = existingConfigs.data?.find(
(config: any) => config.config_name === (state.relationshipName || "외부호출 설정")
);
if (existingConfig) {
// 기존 설정 업데이트
console.log("📝 기존 외부호출 설정 업데이트:", existingConfig.id);
configResult = await ExternalCallConfigAPI.updateConfig(existingConfig.id, configData);
} else {
// 기존 설정이 없으면 새로 생성
console.log("🆕 새 외부호출 설정 생성 (수정 모드)");
configResult = await ExternalCallConfigAPI.createConfig(configData);
}
} catch (updateError) {
// 중복 생성 오류인 경우 무시하고 계속 진행
if (updateError.message && updateError.message.includes("이미 존재합니다")) {
console.log("⚠️ 외부호출 설정이 이미 존재함 - 기존 설정 사용");
configResult = { success: true, message: "기존 외부호출 설정 사용" };
} else {
console.warn("⚠️ 외부호출 설정 처리 실패:", updateError);
throw updateError;
}
}
} else {
// 신규 생성 모드
console.log("🆕 신규 생성 모드 - 외부호출 설정 생성");
try {
configResult = await ExternalCallConfigAPI.createConfig(configData);
} catch (createError) {
// 중복 생성 오류인 경우 무시하고 계속 진행
if (createError.message && createError.message.includes("이미 존재합니다")) {
console.log("⚠️ 외부호출 설정이 이미 존재함 - 기존 설정 사용");
configResult = { success: true, message: "기존 외부호출 설정 사용" };
} else {
throw createError;
}
}
}
if (!configResult.success) {
throw new Error(configResult.error || "외부호출 설정 저장 실패");