diff --git a/backend/app.py b/backend/app.py index 6273036..a8676aa 100644 --- a/backend/app.py +++ b/backend/app.py @@ -3450,13 +3450,14 @@ def api_products(): apc_row = apc_result.fetchone() if apc_row: apc = apc_row[0] - elif row.barcode: - apc = row.barcode # 바코드=APC 케이스 except: pass - # APC 코드: 쿼리에서 조회한 것 또는 기존 로직에서 찾은 것 - apc_code = getattr(row, 'apc_code', None) or apc + # APC 코드: 쿼리에서 02%로 조회한 것만 사용 (바코드 대체 X) + apc_code = getattr(row, 'apc_code', None) or '' + + # PostgreSQL 조회용 APC (분류/도매재고): apc 또는 apc_code 사용 + pg_apc = apc or apc_code items.append({ 'drug_code': row.drug_code or '', @@ -3469,14 +3470,15 @@ def api_products(): 'is_animal_drug': is_animal, 'stock': int(row.stock) if row.stock else 0, 'location': row.location or '', # 위치 - 'apc': apc_code, # APC 코드 (02로 시작) + 'apc': apc_code, # UI용 APC 코드 (02로 시작하는 것만) + '_pg_apc': pg_apc, # PostgreSQL 조회용 (내부용) 'category': None, # PostgreSQL에서 lazy fetch 'wholesaler_stock': None, 'thumbnail': None # 아래에서 채움 }) # 동물약 분류 Lazy Fetch (PostgreSQL) - 실패해도 무시 - animal_items = [i for i in items if i['is_animal_drug'] and i['apc']] + animal_items = [i for i in items if i['is_animal_drug'] and i.get('_pg_apc')] if animal_items: try: from sqlalchemy import create_engine