feat(representation): expose doctor representation details and add counts in admin views

This commit is contained in:
hamed
2026-07-12 13:00:49 +03:30
parent 476d5bb80e
commit 1a8b3bfa53
10 changed files with 366 additions and 4 deletions
+45 -1
View File
@@ -357,13 +357,18 @@ List all doctors with pagination.
"degree": "متخصص",
"gender": "male",
"doctor_rate": 4.5,
"active_doctor_appointment": true
"active_doctor_appointment": true,
"representation_id": 12,
"representation_uuid": "9c1...",
"representation_name": "علی محمدی"
}
],
"meta": { "totalRecords": 92, "totalPages": 5, "currentPage": 1 }
}
```
> `representation_id`/`representation_uuid`/`representation_name` نماینده‌ی مالکِ پزشک‌اند؛ برای پزشکانِ بدون نماینده (مثل ایمپورت‌های IRIMC) هر سه `null`.
---
### GET `/api/v1/admin/doctors/stats`
@@ -761,18 +766,57 @@ Paginated representation list. Each item:
"city": "یزد، تهران",
"commission_percent": 10.0,
"wallet_balance": 0,
"doctor_count": 14,
"appointment_count": 231,
"is_active": true,
"created_at": "2026-06-18T..."
}
```
> `city_id` = اولین شهر (BC)؛ `city` = نام شهرها با «،». `is_global=true` یعنی نماینده سراسری (badge در پنل).
> `doctor_count` = تعداد پزشکانِ `representation_id = r.id`؛ `appointment_count` = تعداد نوبت‌های آن پزشکان. هر دو با کوئری گروهی محاسبه می‌شوند (بدون N+1).
> `mobile_number` falls back to the linked user's mobile when the representation's own `mobile_number` column is empty.
> **Deactivation, not deletion:** the admin panel deactivates a representation via `PATCH /api/v1/representation/{uuid}` with `{ "active": false }` rather than calling `DELETE`.
---
### GET `/api/v1/admin/representations/{uuid}/doctors`
پزشکان زیرمجموعه‌ی یک نماینده (paginated).
**Permission:** `ROLE_ADMIN`
### Query Parameters
| Param | Type | Required | Description |
|-------|------|----------|-------------|
| `page` | integer | ❌ | Default: 1 |
| `limit` | integer | ❌ | Default: 15 (max 100) |
### Response `200`
Paginated. Each item:
```json
{
"uuid": "...",
"id": 45,
"name": "دکتر علی احمدی",
"gender": "man",
"medical_code": "12345",
"is_active": true,
"owner_status": "claimed",
"appointment_count": 17,
"created_at": "2026-06-18T..."
}
```
### Errors
| Code | HTTP | Description |
|------|------|-------------|
| `ERR_NOT_FOUND_001` | 404 | نماینده یافت نشد |
---
## Secretary Management
### GET `/api/v1/admin/secretaries`
+4 -1
View File
@@ -116,13 +116,16 @@ Get doctor detail with clinics.
"address": [],
"state": [],
"city": [],
"clinics": [{ "uuid": "...", "name": "کلینیک الوند", "address": "...", "telephone": "..." }]
"clinics": [{ "uuid": "...", "name": "کلینیک الوند", "address": "...", "telephone": "..." }],
"representation": { "id": 12, "uuid": "9c1...", "full_name": "علی محمدی" }
}
}
}
```
> ⚠️ **Double-nested:** Frontend extracts with `data?.data?.data`
>
> ️ `representation` نماینده‌ی مالکِ پزشک است؛ برای پزشکِ بدون نماینده `null`.
### Errors
| Code | HTTP | Description |