feat: add POST /api/cases/parties to store UYAP taraf bilgileri
The UYAP extension now captures the davaci/davali/sanik + vekil data from the "Taraf Bilgileri" tab and sends it once per case. This endpoint finds/creates the matching case by title (same lookup used by registerLocalDocument, now shared via lib/caseLookup.ts) and stores it in a new cases.parties column - a much more reliable source for the case detail screen's "Taraflar" info than the AI's own guess from OCR'd document text. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
9f5c5c1e45
commit
99d4d770d5
@@ -3,6 +3,7 @@ import { supabase } from '../lib/supabase';
|
||||
import { AuthenticatedRequest } from '../middleware/auth';
|
||||
import * as officeParser from 'officeparser';
|
||||
import Tesseract from 'tesseract.js';
|
||||
import { findOrCreateCaseByTitle } from '../lib/caseLookup';
|
||||
const heicConvert = require('heic-convert');
|
||||
|
||||
const ANALYSIS_SYSTEM_PROMPT = `
|
||||
@@ -65,27 +66,7 @@ export const registerLocalDocument = async (req: AuthenticatedRequest, res: Resp
|
||||
return res.status(400).json({ error: 'case_title, filename ve extracted_text zorunludur.' });
|
||||
}
|
||||
|
||||
// Dava başlığına göre mevcut case'i bul (case-insensitive), yoksa oluştur.
|
||||
const { data: existing } = await supabase
|
||||
.from('cases')
|
||||
.select('id, title')
|
||||
.eq('user_id', userId)
|
||||
.ilike('title', case_title)
|
||||
.limit(1)
|
||||
.maybeSingle();
|
||||
|
||||
let caseId: string;
|
||||
if (existing) {
|
||||
caseId = existing.id;
|
||||
} else {
|
||||
const { data: newCase, error: caseError } = await supabase
|
||||
.from('cases')
|
||||
.insert([{ title: String(case_title).slice(0, 200), user_id: userId }])
|
||||
.select('id')
|
||||
.single();
|
||||
if (caseError) throw caseError;
|
||||
caseId = newCase.id;
|
||||
}
|
||||
const caseId = await findOrCreateCaseByTitle(userId as string, case_title);
|
||||
|
||||
const { data: documentRecord, error: docError } = await supabase
|
||||
.from('documents')
|
||||
|
||||
Reference in New Issue
Block a user