배치 UPSERT 기능 및 고정값 매핑 버그 수정

This commit is contained in:
dohyeons
2025-12-04 17:26:29 +09:00
parent 7a2f80b646
commit ef3b85f343
9 changed files with 1176 additions and 576 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -58,6 +58,10 @@ export default function BatchEditPage() {
const [cronSchedule, setCronSchedule] = useState("0 12 * * *");
const [description, setDescription] = useState("");
const [isActive, setIsActive] = useState("Y");
const [saveMode, setSaveMode] = useState<"INSERT" | "UPSERT">("INSERT");
const [conflictKey, setConflictKey] = useState("");
const [authServiceName, setAuthServiceName] = useState("");
const [authServiceNames, setAuthServiceNames] = useState<string[]>([]);
// 연결 정보
const [connections, setConnections] = useState<ConnectionInfo[]>([]);
@@ -87,9 +91,20 @@ export default function BatchEditPage() {
if (batchId) {
loadBatchConfig();
loadConnections();
loadAuthServiceNames();
}
}, [batchId]);
// 인증 서비스명 목록 로드
const loadAuthServiceNames = async () => {
try {
const names = await BatchAPI.getAuthServiceNames();
setAuthServiceNames(names);
} catch (error) {
console.error("인증 서비스 목록 로드 실패:", error);
}
};
// 연결 정보가 로드된 후 배치 설정의 연결 정보 설정
useEffect(() => {
if (batchConfig && connections.length > 0 && batchConfig.batch_mappings && batchConfig.batch_mappings.length > 0) {
@@ -184,6 +199,9 @@ export default function BatchEditPage() {
setCronSchedule(config.cron_schedule);
setDescription(config.description || "");
setIsActive(config.is_active || "Y");
setSaveMode((config as any).save_mode || "INSERT");
setConflictKey((config as any).conflict_key || "");
setAuthServiceName((config as any).auth_service_name || "");
if (config.batch_mappings && config.batch_mappings.length > 0) {
console.log("📊 매핑 정보:", config.batch_mappings);
@@ -460,7 +478,10 @@ export default function BatchEditPage() {
description,
cronSchedule,
isActive,
mappings
mappings,
saveMode,
conflictKey: saveMode === "UPSERT" ? conflictKey : undefined,
authServiceName: authServiceName || undefined
});
toast.success("배치 설정이 성공적으로 수정되었습니다.");
@@ -558,6 +579,68 @@ export default function BatchEditPage() {
/>
<Label htmlFor="isActive"></Label>
</div>
{/* 저장 모드 설정 */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 pt-4 border-t">
<div className="space-y-2">
<Label htmlFor="saveMode"> </Label>
<Select
value={saveMode}
onValueChange={(value: "INSERT" | "UPSERT") => setSaveMode(value)}
>
<SelectTrigger>
<SelectValue placeholder="저장 모드 선택" />
</SelectTrigger>
<SelectContent>
<SelectItem value="INSERT">INSERT ( )</SelectItem>
<SelectItem value="UPSERT">UPSERT ( , )</SelectItem>
</SelectContent>
</Select>
<p className="text-xs text-muted-foreground">
UPSERT: 동일한 , .
</p>
</div>
{saveMode === "UPSERT" && (
<div className="space-y-2">
<Label htmlFor="conflictKey"> *</Label>
<Input
id="conflictKey"
value={conflictKey}
onChange={(e) => setConflictKey(e.target.value)}
placeholder="예: device_serial_number"
/>
<p className="text-xs text-muted-foreground">
UPSERT .
</p>
</div>
)}
</div>
{/* 인증 토큰 서비스 설정 */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 pt-4 border-t">
<div className="space-y-2">
<Label htmlFor="authServiceName"> </Label>
<Select
value={authServiceName || "none"}
onValueChange={(value) => setAuthServiceName(value === "none" ? "" : value)}
>
<SelectTrigger>
<SelectValue placeholder="인증 토큰 서비스 선택 (선택사항)" />
</SelectTrigger>
<SelectContent>
<SelectItem value="none"> </SelectItem>
{authServiceNames.map((name) => (
<SelectItem key={name} value={name}>
{name}
</SelectItem>
))}
</SelectContent>
</Select>
<p className="text-xs text-muted-foreground">
REST API auth_tokens Authorization .
</p>
</div>
</div>
</CardContent>
</Card>