Files
clinicpro/docs/tasks/task-12-rating-comment/database.md
T
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

3.7 KiB

پایگاه داده — تسک ۱۲: ماژول امتیاز و نظرات

مهم: نام فیلد از DB

فیلد ستاره در Drupal field_starts است (نه field_stars!) — از config تأیید شد.

جدول: ratings

(entity_type=clinic_pro_comment, bundle=rate)

ستون نوع نام Drupal توضیح
id INT UNSIGNED AUTO_INCREMENT PK id
uuid CHAR(36) UNIQUE NOT NULL uuid
user_id INT FK → users.id NOT NULL uid امتیاز‌دهنده
doctor_id INT FK → doctors.id NOT NULL field_doctor_id entity ref → clinic_pro
doctor_behavior INT NOT NULL field_doctor_behavior برخورد مناسب (0-100)
accuracy_of_diagnosis INT NOT NULL field_accuracy_of_diagnosis تشخیص درست (0-100)
waiting_time_at_clinic INT NOT NULL field_waiting_time_at_clinic زمان انتظار (0-100)
doctor_expertise INT NOT NULL field_doctor_expertise مهارت (0-100)
clinic_cleanliness INT NOT NULL field_clinic_cleanliness نظافت (0-100)
starts DECIMAL(10,2) NOT NULL field_starts ستاره محاسبه‌شده (0-5) — ⚠️ starts نه stars!
percent FLOAT NOT NULL field_percent درصد محاسبه‌شده (0-100)
created_at INT NOT NULL created Unix timestamp
updated_at INT NOT NULL changed Unix timestamp

جدول: comments

(entity_type=clinic_pro_comment, bundle=comments)

ستون نوع نام Drupal توضیح
id INT UNSIGNED AUTO_INCREMENT PK id
uuid CHAR(36) UNIQUE NOT NULL uuid
user_id INT FK → users.id NOT NULL uid نویسنده
doctor_id INT FK → doctors.id NOT NULL field_doctor_id دکتر
comment LONGTEXT NOT NULL field_comment متن نظر
approved TINYINT(1) DEFAULT 0 field_approved تأیید شده (نه ENUM بلکه boolean)
parent_id INT FK → comments.id NULL field_parent نظر پدر (پاسخ به نظر)
created_at INT NOT NULL created Unix timestamp
updated_at INT NOT NULL changed Unix timestamp

جدول: likes

(entity_type=clinic_pro_comment, bundle=like)

ستون نوع نام Drupal توضیح
id INT UNSIGNED AUTO_INCREMENT PK id
uuid CHAR(36) UNIQUE NOT NULL uuid
user_id INT FK → users.id NOT NULL uid کاربر
comment_id INT FK → comments.id NOT NULL field_comment_id نظر مورد لایک
is_like TINYINT(1) NOT NULL field_like لایک (1) یا دیس‌لایک (0)
created_at INT NOT NULL created Unix timestamp
updated_at INT NOT NULL changed Unix timestamp

ایندکس‌ها

-- هر کاربر فقط یک امتیاز برای هر دکتر
CREATE UNIQUE INDEX idx_ratings_user_doctor ON ratings(user_id, doctor_id);

-- هر کاربر فقط یک لایک/دیس‌لایک برای هر نظر
CREATE UNIQUE INDEX idx_likes_user_comment ON likes(user_id, comment_id);

CREATE INDEX idx_ratings_doctor ON ratings(doctor_id);
CREATE INDEX idx_comments_doctor_approved ON comments(doctor_id, approved);
CREATE INDEX idx_comments_parent ON comments(parent_id);

نکته‌های مهم

  • فیلد ستاره starts است (نه stars) — همان‌طور که در config تأیید شد
  • approved boolean است (0/1)، نه ENUM
  • percent نوع FLOAT است (نه DECIMAL) — از config تأیید شد
  • starts نوع DECIMAL(10,2) است — از config تأیید شد
  • comment.status در جدول پایه Drupal وجود دارد (tinyint) اما از field_approved استفاده می‌شود