From 4c93ee038ad21a626fb33deac14204c4d132a8cc Mon Sep 17 00:00:00 2001 From: thug0bin Date: Sat, 28 Feb 2026 12:32:03 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=B1=97=EB=B4=87=20=EA=B4=80=EB=A0=A8?= =?UTF-8?q?=20=EC=A0=9C=ED=92=88=EC=97=90=20=EB=B6=84=EB=A5=98=20=EB=B1=83?= =?UTF-8?q?=EC=A7=80=20=EC=B6=94=EA=B0=80=20(=EB=82=B4=EB=B6=80=EA=B5=AC?= =?UTF-8?q?=EC=B6=A9=EC=A0=9C,=20=EC=8B=AC=EC=9E=A5=EC=82=AC=EC=83=81?= =?UTF-8?q?=EC=B6=A9=EC=95=BD=20=EB=93=B1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app.py | 18 +++++++++++------- backend/templates/admin_products.html | 10 ++++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/backend/app.py b/backend/app.py index 477d449..3e04016 100644 --- a/backend/app.py +++ b/backend/app.py @@ -2797,6 +2797,7 @@ def _get_animal_drugs(): 'apc': apc, 'stock': int(r.Stock) if r.Stock else 0, 'wholesaler_stock': 0, # PostgreSQL에서 가져옴 + 'category': None, # PostgreSQL에서 가져옴 'image_url': None # PostgreSQL에서 가져옴 }) @@ -2807,11 +2808,12 @@ def _get_animal_drugs(): pg_engine = create_engine('postgresql://admin:trajet6640@192.168.0.87:5432/apdb_master') with pg_engine.connect() as conn: placeholders = ','.join([f"'{a}'" for a in apc_list]) - # 이미지 URL 조회 - img_result = conn.execute(text(f""" - SELECT apc, image_url1 FROM apc WHERE apc IN ({placeholders}) + # 이미지 URL + 분류 조회 + info_result = conn.execute(text(f""" + SELECT apc, image_url1, llm_pharm->>'분류' as category + FROM apc WHERE apc IN ({placeholders}) """)) - img_map = {row.apc: row.image_url1 for row in img_result} + info_map = {row.apc: {'image_url': row.image_url1, 'category': row.category} for row in info_result} # 도매상 재고 조회 (SUM) stock_result = conn.execute(text(f""" @@ -2825,8 +2827,9 @@ def _get_animal_drugs(): for item in result: if item['apc']: - if item['apc'] in img_map: - item['image_url'] = img_map[item['apc']] + if item['apc'] in info_map: + item['image_url'] = info_map[item['apc']]['image_url'] + item['category'] = info_map[item['apc']]['category'] if item['apc'] in stock_map: item['wholesaler_stock'] = stock_map[item['apc']] else: @@ -2991,7 +2994,8 @@ def api_animal_chat(): 'code': drug['code'], 'image_url': drug.get('image_url'), # APC 이미지 URL 'stock': drug.get('stock', 0), # 약국 재고 - 'wholesaler_stock': drug.get('wholesaler_stock', 0) # 도매상 재고 + 'wholesaler_stock': drug.get('wholesaler_stock', 0), # 도매상 재고 + 'category': drug.get('category') # 분류 (내부구충제, 심장사상충약 등) }) return jsonify({ diff --git a/backend/templates/admin_products.html b/backend/templates/admin_products.html index 6a6cdc1..654ccae 100644 --- a/backend/templates/admin_products.html +++ b/backend/templates/admin_products.html @@ -987,7 +987,7 @@ imgContainer.innerHTML = '
💊
'; } - // 텍스트 (약국/도매 재고) + // 텍스트 (카테고리 뱃지 + 약국/도매 재고) const textDiv = document.createElement('div'); const pharmacyStock = p.stock || 0; const wholesalerStock = p.wholesaler_stock || 0; @@ -995,7 +995,13 @@ const pharmacyText = (pharmacyStock > 0) ? `약국 ${pharmacyStock}` : '품절'; const wholesalerText = (wholesalerStock > 0) ? `도매 ${wholesalerStock}` : ''; const stockDisplay = wholesalerText ? `${pharmacyText} / ${wholesalerText}` : pharmacyText; - textDiv.innerHTML = `
${p.name}
${formatPrice(p.price)} ${stockDisplay}
`; + + // 카테고리 뱃지 + const categoryBadge = p.category + ? `${p.category}` + : ''; + + textDiv.innerHTML = `
${p.name}${categoryBadge}
${formatPrice(p.price)} ${stockDisplay}
`; card.appendChild(imgContainer); card.appendChild(textDiv);