fix(upload): product_name NOT NULL 에러 수정

- 세션 생성 시 product_name 저장
- 업로드 API에서 product_name INSERT
- 프론트엔드에서 product_name 전달
This commit is contained in:
thug0bin 2026-03-08 13:49:23 +09:00
parent aef867645e
commit 90cb91d644
2 changed files with 8 additions and 4 deletions

View File

@ -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()

View File

@ -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();