feat: 대시보드 모달에 관심상품 탭 추가

- /admin/user/<id> API에 interests 필드 추가
- ai_recommendations 테이블에서 status='interested' 조회
- 모달에 💝 관심 탭 추가
- 트리거 상품, 추천 이유 표시
This commit is contained in:
thug0bin
2026-02-27 17:10:35 +09:00
parent 3fc9bbaf8e
commit 8c366cc4db
2 changed files with 66 additions and 2 deletions

View File

@@ -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: