배치 UPSERT 기능 및 고정값 매핑 버그 수정
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user