From 90cb91d6446ff88d831f12e32080a5f35de81367 Mon Sep 17 00:00:00 2001 From: thug0bin Date: Sun, 8 Mar 2026 13:49:23 +0900 Subject: [PATCH] =?UTF-8?q?fix(upload):=20product=5Fname=20NOT=20NULL=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 세션 생성 시 product_name 저장 - 업로드 API에서 product_name INSERT - 프론트엔드에서 product_name 전달 --- backend/app.py | 10 +++++++--- backend/templates/admin_products.html | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/app.py b/backend/app.py index 5689579..4f60f12 100644 --- a/backend/app.py +++ b/backend/app.py @@ -7628,6 +7628,7 @@ def api_create_upload_session(): data = request.get_json() or {} barcode = data.get('barcode', '') + product_name = data.get('product_name', barcode) # 없으면 바코드 사용 if not barcode: return jsonify({'success': False, 'error': '바코드가 필요합니다'}), 400 @@ -7637,6 +7638,7 @@ def api_create_upload_session(): upload_sessions[session_id] = { 'barcode': barcode, + 'product_name': product_name, 'created_at': datetime.now(), 'expires_at': expires_at, 'status': 'pending', # pending → uploaded @@ -7704,6 +7706,8 @@ def api_upload_session_image(session_id): cursor.execute('SELECT id FROM product_images WHERE barcode = ?', (barcode,)) existing = cursor.fetchone() + product_name = session.get('product_name', barcode) # 세션에서 가져오거나 바코드 사용 + if existing: cursor.execute(''' UPDATE product_images @@ -7712,9 +7716,9 @@ def api_upload_session_image(session_id): ''', (image_base64, barcode)) else: cursor.execute(''' - INSERT INTO product_images (barcode, image_base64, created_at) - VALUES (?, ?, CURRENT_TIMESTAMP) - ''', (barcode, image_base64)) + INSERT INTO product_images (barcode, product_name, image_base64, status, created_at) + VALUES (?, ?, ?, 'manual', CURRENT_TIMESTAMP) + ''', (barcode, product_name, image_base64)) conn.commit() conn.close() diff --git a/backend/templates/admin_products.html b/backend/templates/admin_products.html index b28b433..7b1b1be 100644 --- a/backend/templates/admin_products.html +++ b/backend/templates/admin_products.html @@ -1741,7 +1741,7 @@ const res = await fetch('/api/upload-session', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ barcode }) + body: JSON.stringify({ barcode, product_name: imgModalName || barcode }) }); const data = await res.json();