# معماری — تسک ۱۲: ماژول امتیاز و نظرات

## ساختار فایل‌ها
```
src/Module/Rating/
├── Controller/
│   ├── RatingController.php
│   └── CommentController.php
├── Service/
│   ├── RatingService.php         ← آپدیت average_rating دکتر
│   └── CommentService.php
├── Repository/
│   ├── RatingRepository.php
│   └── CommentRepository.php
├── Entity/
│   ├── Rating.php
│   └── Comment.php
├── DTO/
│   ├── Request/
│   │   ├── CreateRatingRequest.php
│   │   ├── CreateCommentRequest.php
│   │   └── ConfirmCommentRequest.php
│   └── Response/
│       ├── RatingResponse.php
│       └── CommentResponse.php
└── Voter/
    ├── RatingVoter.php
    └── CommentVoter.php
```

## Entity: Rating
```php
#[ORM\Entity]
#[ORM\Table(name: 'ratings')]
class Rating
{
    #[ORM\Id, ORM\GeneratedValue, ORM\Column]
    private int $id;

    #[ORM\Column(type: UuidType::NAME, unique: true)]
    private Uuid $uuid;

    #[ORM\ManyToOne(targetEntity: User::class)]
    private User $patient;

    #[ORM\ManyToOne(targetEntity: Doctor::class)]
    private Doctor $doctor;

    #[ORM\Column(type: 'integer')]
    private int $score;  // 1 تا 5

    #[ORM\OneToOne(targetEntity: Appointment::class, nullable: true)]
    private ?Appointment $appointment;

    // TimestampableTrait
}
```

## Entity: Comment
```php
#[ORM\Entity]
#[ORM\Table(name: 'comments')]
class Comment
{
    #[ORM\Id, ORM\GeneratedValue, ORM\Column]
    private int $id;

    #[ORM\Column(type: UuidType::NAME, unique: true)]
    private Uuid $uuid;

    #[ORM\ManyToOne(targetEntity: User::class)]
    private User $author;

    #[ORM\ManyToOne(targetEntity: Doctor::class)]
    private Doctor $doctor;

    #[ORM\Column(type: 'text')]
    private string $text;

    // pending, approved, rejected
    #[ORM\Column(length: 20, default: 'pending')]
    private string $status;

    #[ORM\ManyToOne(targetEntity: Rating::class, nullable: true)]
    private ?Rating $rating;

    // TimestampableTrait
}
```
