From 8c366cc4db9a432a6bd63a84afe17ae87da9ad38 Mon Sep 17 00:00:00 2001 From: thug0bin Date: Fri, 27 Feb 2026 17:10:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C=20?= =?UTF-8?q?=EB=AA=A8=EB=8B=AC=EC=97=90=20=EA=B4=80=EC=8B=AC=EC=83=81?= =?UTF-8?q?=ED=92=88=20=ED=83=AD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - /admin/user/ API에 interests 필드 추가 - ai_recommendations 테이블에서 status='interested' 조회 - 모달에 💝 관심 탭 추가 - 트리거 상품, 추천 이유 표시 --- backend/app.py | 25 +++++++++++++++++++-- backend/templates/admin.html | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/backend/app.py b/backend/app.py index acfcd52..bd5935e 100644 --- a/backend/app.py +++ b/backend/app.py @@ -1448,7 +1448,27 @@ def admin_user_detail(user_id): except Exception as rx_error: logging.warning(f"조제 이력 조회 실패 (user {user_id}): {rx_error}") - # 7. 응답 생성 + # 7. 관심상품 조회 (AI 추천에서 '관심있어요' 누른 상품) + interests = [] + try: + cursor.execute(""" + SELECT recommended_product, recommendation_reason, trigger_products, created_at + FROM ai_recommendations + WHERE user_id = ? AND status = 'interested' + ORDER BY created_at DESC + LIMIT 20 + """, (user_id,)) + for row in cursor.fetchall(): + interests.append({ + 'product': row['recommended_product'], + 'reason': row['recommendation_reason'], + 'trigger_products': row['trigger_products'], + 'created_at': utc_to_kst_str(row['created_at']) + }) + except Exception as interest_error: + logging.warning(f"관심상품 조회 실패 (user {user_id}): {interest_error}") + + # 8. 응답 생성 return jsonify({ 'success': True, 'user': { @@ -1472,7 +1492,8 @@ def admin_user_detail(user_id): ], 'purchases': purchases, 'prescriptions': prescriptions, - 'pos_customer': pos_customer + 'pos_customer': pos_customer, + 'interests': interests }) except Exception as e: diff --git a/backend/templates/admin.html b/backend/templates/admin.html index 91069ff..6599b28 100644 --- a/backend/templates/admin.html +++ b/backend/templates/admin.html @@ -904,6 +904,9 @@ + @@ -1009,6 +1012,46 @@ html += '

📭 조제 이력이 없습니다

'; } + html += ` + + + + `;