feat: 관리자 대시보드 사용자 모달에 반려동물 탭 추가
- /admin/user/<id> API에 pets 데이터 추가
- 사용자 상세 모달에 🐾 반려동물 탭 추가
- 반려동물 사진, 이름, 종류, 품종, 성별, 등록일 표시
This commit is contained in:
@@ -1621,7 +1621,38 @@ def admin_user_detail(user_id):
|
||||
except Exception as interest_error:
|
||||
logging.warning(f"관심상품 조회 실패 (user {user_id}): {interest_error}")
|
||||
|
||||
# 8. 응답 생성
|
||||
# 8. 반려동물 조회
|
||||
pets = []
|
||||
try:
|
||||
cursor.execute("""
|
||||
SELECT id, name, species, breed, gender, birth_date, age_months,
|
||||
weight, photo_url, notes, created_at
|
||||
FROM pets
|
||||
WHERE user_id = ? AND is_active = TRUE
|
||||
ORDER BY created_at DESC
|
||||
""", (user_id,))
|
||||
for row in cursor.fetchall():
|
||||
species_label = '강아지 🐕' if row['species'] == 'dog' else ('고양이 🐈' if row['species'] == 'cat' else '기타')
|
||||
gender_label = '♂ 남아' if row['gender'] == 'male' else ('♀ 여아' if row['gender'] == 'female' else '')
|
||||
pets.append({
|
||||
'id': row['id'],
|
||||
'name': row['name'],
|
||||
'species': row['species'],
|
||||
'species_label': species_label,
|
||||
'breed': row['breed'],
|
||||
'gender': row['gender'],
|
||||
'gender_label': gender_label,
|
||||
'birth_date': row['birth_date'],
|
||||
'age_months': row['age_months'],
|
||||
'weight': float(row['weight']) if row['weight'] else None,
|
||||
'photo_url': row['photo_url'],
|
||||
'notes': row['notes'],
|
||||
'created_at': utc_to_kst_str(row['created_at'])
|
||||
})
|
||||
except Exception as pet_error:
|
||||
logging.warning(f"반려동물 조회 실패 (user {user_id}): {pet_error}")
|
||||
|
||||
# 9. 응답 생성
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'user': {
|
||||
@@ -1647,7 +1678,8 @@ def admin_user_detail(user_id):
|
||||
'purchases': purchases,
|
||||
'prescriptions': prescriptions,
|
||||
'pos_customer': pos_customer,
|
||||
'interests': interests
|
||||
'interests': interests,
|
||||
'pets': pets
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user