- Add SendSmsMessage class for encapsulating SMS message data. - Create KavehNegarProvider and RanginehProvider classes implementing SmsProviderInterface for sending SMS. - Implement SmsLogRepository and SmsTemplateRepository for managing SMS logs and templates. - Develop SendSmsHandler for handling SMS sending messages. - Create SmsService to manage SMS dispatching and logging. - Add UserProfileController for managing user profiles with CRUD operations. - Implement UserProfile entity and repository for user profile data management. - Update symfony.lock and bootstrap.php for project dependencies and environment setup.
68 lines
2.4 KiB
Markdown
68 lines
2.4 KiB
Markdown
# نکات پیادهسازی — تسک ۰۳: ماژول پروفایل کاربر
|
|
|
|
## جریان بعد از ذخیره پروفایل
|
|
طبق مستندات Drupal، بعد از ذخیره پروفایل باید:
|
|
1. `POST /oauth/token` با refresh_token اجرا شود (دریافت access_token جدید)
|
|
2. `GET /oauth/userinfo` اجرا شود
|
|
|
|
در Symfony این جریان در سمت **کلاینت** انجام میشود، نه سرور.
|
|
→ در پاسخ POST /api/v1/user-profile، token های بهروز شده نیز برگردان:
|
|
```json
|
|
{
|
|
"data": {
|
|
"profile": { "uuid": "...", "name": "..." },
|
|
"access_token": "eyJ...",
|
|
"refresh_token": "eyJ..."
|
|
},
|
|
"message": "پروفایل با موفقیت ذخیره شد"
|
|
}
|
|
```
|
|
|
|
## اعتبارسنجی blood_type
|
|
مقادیر مجاز:
|
|
```php
|
|
#[Assert\Choice(choices: [
|
|
'a_positive', 'a_negative',
|
|
'b_positive', 'b_negative',
|
|
'ab_positive', 'ab_negative',
|
|
'o_positive', 'o_negative'
|
|
])]
|
|
```
|
|
|
|
## اعتبارسنجی gender
|
|
```php
|
|
#[Assert\Choice(choices: ['male', 'female', 'other'])]
|
|
```
|
|
|
|
## اعتبارسنجی education
|
|
```php
|
|
#[Assert\Choice(choices: [
|
|
'primary', 'secondary', 'diploma',
|
|
'associate', 'bachelor', 'master',
|
|
'postgraduate_diploma', 'doctorate'
|
|
])]
|
|
```
|
|
|
|
## Partial Update (PATCH)
|
|
endpoint PATCH باید فقط فیلدهایی که ارسال شده را آپدیت کند.
|
|
→ از `$request->request->has('field')` یا DTO با nullable fields استفاده کن.
|
|
→ مثال: اگر فقط `diseases` در body باشد، بقیه فیلدها تغییر نکنند.
|
|
|
|
## مجوزها
|
|
```
|
|
POST /api/v1/user-profile → کاربر احراز هویتشده (برای خودش)
|
|
GET /api/v1/user-profile/{uuid} → owner یا ROLE_ADMIN یا ROLE_DOCTOR (دکتر مرتبط)
|
|
PATCH /api/v1/user-profile/{uuid} → owner یا ROLE_ADMIN
|
|
DELETE /api/v1/user-profile/{uuid} → فقط ROLE_ADMIN
|
|
```
|
|
|
|
## نکته UUID در URL
|
|
در Drupal از UUID واقعی در URL استفاده میشد.
|
|
در Symfony نیز همان رویکرد حفظ میشود.
|
|
ParamConverter میتواند UUID را به Entity تبدیل کند:
|
|
```php
|
|
#[Route('/api/v1/user-profile/{uuid}', methods: ['GET'])]
|
|
public function get(UserProfile $userProfile): Response
|
|
// Doctrine ParamConverter به طور خودکار uuid را به UserProfile تبدیل میکند
|
|
```
|