From c5256322465acf0c36c3dab6ec539a310d707588 Mon Sep 17 00:00:00 2001 From: thug0bin Date: Mon, 2 Mar 2026 16:37:25 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=96=B4=EB=93=9C=EB=AF=BC=20=EC=A7=91?= =?UTF-8?q?=EA=B3=84=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=20=EB=B0=98?= =?UTF-8?q?=EB=A0=A4=EB=8F=99=EB=AC=BC=20=ED=86=B5=EA=B3=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 통계 카드: - 등록 반려동물 총 수 - 강아지/고양이 종류별 수 - 노란색 그라데이션 카드 스타일 최근 등록 반려동물 섹션: - 최근 10마리 반려동물 카드 - 사진 + 이름 + 품종 + 보호자 정보 - 보호자 전화번호 마스킹 처리 --- backend/app.py | 33 ++++++++++++++++++++++++++++++++- backend/templates/admin.html | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/backend/app.py b/backend/app.py index f8e6fff..cfa7d90 100644 --- a/backend/app.py +++ b/backend/app.py @@ -2208,6 +2208,35 @@ def admin(): FROM claim_tokens """) token_stats = cursor.fetchone() + + # 반려동물 통계 + cursor.execute(""" + SELECT + COUNT(*) as total_pets, + SUM(CASE WHEN species = 'dog' THEN 1 ELSE 0 END) as dog_count, + SUM(CASE WHEN species = 'cat' THEN 1 ELSE 0 END) as cat_count, + COUNT(DISTINCT user_id) as owners_count + FROM pets + WHERE is_active = 1 + """) + pet_stats = cursor.fetchone() + + # 최근 등록 반려동물 (10마리) + cursor.execute(""" + SELECT p.id, p.name, p.species, p.breed, p.photo_url, p.created_at, + u.nickname as owner_name, u.phone as owner_phone + FROM pets p + JOIN users u ON p.user_id = u.id + WHERE p.is_active = 1 + ORDER BY p.created_at DESC + LIMIT 10 + """) + recent_pets_raw = cursor.fetchall() + recent_pets = [] + for pet in recent_pets_raw: + pet_dict = dict(pet) + pet_dict['created_at'] = utc_to_kst_str(pet['created_at']) + recent_pets.append(pet_dict) # 최근 QR 발행 내역 (20건) cursor.execute(""" @@ -2237,7 +2266,9 @@ def admin(): recent_users=recent_users, recent_transactions=recent_transactions, token_stats=token_stats, - recent_tokens=recent_tokens) + recent_tokens=recent_tokens, + pet_stats=pet_stats, + recent_pets=recent_pets) # ============================================================================ diff --git a/backend/templates/admin.html b/backend/templates/admin.html index d74b6a9..5ef63b8 100644 --- a/backend/templates/admin.html +++ b/backend/templates/admin.html @@ -457,8 +457,44 @@ {% endif %} +
+
🐾 등록 반려동물
+
+ {{ pet_stats.total_pets or 0 }}마리 + + (🐕 {{ pet_stats.dog_count or 0 }} / 🐈 {{ pet_stats.cat_count or 0 }}) + +
+
+ + {% if recent_pets %} +
+
🐾 최근 등록 반려동물 (10마리)
+
+ {% for pet in recent_pets %} +
+ {% if pet.photo_url %} + + {% else %} +
+ {% if pet.species == 'dog' %}🐕{% elif pet.species == 'cat' %}🐈{% else %}🐾{% endif %} +
+ {% endif %} +
+
+ {% if pet.species == 'dog' %}🐕{% elif pet.species == 'cat' %}🐈{% else %}🐾{% endif %} {{ pet.name }} +
+
{{ pet.breed or '품종 미등록' }}
+
{{ pet.owner_name }} ({{ pet.owner_phone[:3] }}-****-{{ pet.owner_phone[-4:] }})
+
+
+ {% endfor %} +
+
+ {% endif %} +
최근 가입 사용자 (20명)