feat(appointment): add booking services endpoint and update security configuration for public access
This commit is contained in:
@@ -193,6 +193,38 @@ class AppointmentController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* عمومی: روش نوبتدهی پزشک + سرویسهای قابلانتخاب برای نوبتگیری سرویسی.
|
||||
* سایت با این پاسخ تصمیم میگیرد مرحلهٔ انتخاب سرویس را نشان دهد یا جریان اسلاتی.
|
||||
*
|
||||
* GET /api/v1/appointment-booking-services/{doctorUuid}
|
||||
*/
|
||||
#[Route('/api/v1/appointment-booking-services/{doctorUuid}', methods: ['GET'])]
|
||||
public function bookingServices(string $doctorUuid): JsonResponse
|
||||
{
|
||||
$doctor = $this->doctorRepo->findByUuid($doctorUuid);
|
||||
if ($doctor === null) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'دکتر یافت نشد', 404);
|
||||
}
|
||||
|
||||
$schedule = $this->scheduleRepo->findByDoctor($doctor);
|
||||
$meta = $schedule ? $schedule->getMeta() : WeeklySchedule::DEFAULT_META;
|
||||
|
||||
$services = array_map(fn(\App\ClinicService\Entity\ServiceItem $i) => [
|
||||
'uuid' => $i->getUuid(),
|
||||
'name' => $i->getName(),
|
||||
'duration_minutes' => $i->getDurationMinutes(),
|
||||
'price_rials' => $i->getPriceRials(),
|
||||
], $this->itemRepo->findBookableByEntity('doctor', $doctor->getId()));
|
||||
|
||||
return $this->success([
|
||||
'doctor_uuid' => $doctorUuid,
|
||||
'booking_mode' => $meta['booking_mode'],
|
||||
'buffer_minutes' => (int) $meta['buffer_minutes'],
|
||||
'services' => $services,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/appointment-settings/month-availability/{doctorUuid}', methods: ['GET'])]
|
||||
public function monthAvailability(string $doctorUuid, Request $request): JsonResponse
|
||||
{
|
||||
|
||||
@@ -76,6 +76,27 @@ class ServiceItemRepository extends ServiceEntityRepository
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* سرویسهای فعالِ «نمایش در نوبتدهی» (bookable) یک entity — برای نمایش عمومیِ
|
||||
* انتخاب سرویس در نوبتگیری آنلاین.
|
||||
*
|
||||
* @return ServiceItem[]
|
||||
*/
|
||||
public function findBookableByEntity(string $entityType, int $entityId): array
|
||||
{
|
||||
return $this->createQueryBuilder('i')
|
||||
->join('i.section', 's')
|
||||
->where('s.entityType = :type')
|
||||
->andWhere('s.entityId = :id')
|
||||
->andWhere('i.bookable = true')
|
||||
->andWhere('i.active = true')
|
||||
->setParameter('type', $entityType)
|
||||
->setParameter('id', $entityId)
|
||||
->orderBy('i.name', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function save(ServiceItem $item): void
|
||||
{
|
||||
$this->getEntityManager()->persist($item);
|
||||
|
||||
Reference in New Issue
Block a user