Files
hamed de1a78a235 feat: Implement SMS sending functionality with KavehNegar and Rangineh providers
- 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.
2026-06-09 22:00:34 +03:30

2.4 KiB

نکات پیاده‌سازی — تسک ۰۳: ماژول پروفایل کاربر

جریان بعد از ذخیره پروفایل

طبق مستندات Drupal، بعد از ذخیره پروفایل باید:

  1. POST /oauth/token با refresh_token اجرا شود (دریافت access_token جدید)
  2. GET /oauth/userinfo اجرا شود

در Symfony این جریان در سمت کلاینت انجام می‌شود، نه سرور. → در پاسخ POST /api/v1/user-profile، token های به‌روز شده نیز برگردان:

{
  "data": {
    "profile": { "uuid": "...", "name": "..." },
    "access_token": "eyJ...",
    "refresh_token": "eyJ..."
  },
  "message": "پروفایل با موفقیت ذخیره شد"
}

اعتبارسنجی blood_type

مقادیر مجاز:

#[Assert\Choice(choices: [
    'a_positive', 'a_negative',
    'b_positive', 'b_negative',
    'ab_positive', 'ab_negative',
    'o_positive', 'o_negative'
])]

اعتبارسنجی gender

#[Assert\Choice(choices: ['male', 'female', 'other'])]

اعتبارسنجی education

#[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 تبدیل کند:

#[Route('/api/v1/user-profile/{uuid}', methods: ['GET'])]
public function get(UserProfile $userProfile): Response
// Doctrine ParamConverter به طور خودکار uuid را به UserProfile تبدیل می‌کند