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 += ` + + + + `;