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.
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Category\Controller;
|
||||
|
||||
use App\Category\Entity\Category;
|
||||
use App\Category\Repository\CategoryRepository;
|
||||
use App\Category\Service\CategoryService;
|
||||
use App\Shared\Constant\ErrorCodes;
|
||||
use App\Shared\Controller\BaseController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class CategoryController extends BaseController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CategoryRepository $repository,
|
||||
private readonly CategoryService $service,
|
||||
) {}
|
||||
|
||||
#[Route('/api/v1/categorys/tag', methods: ['GET'])]
|
||||
public function listTags(): JsonResponse
|
||||
{
|
||||
return $this->success(['data' => $this->service->listByBundle('tag')]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/categorys/supplementary_insurance', methods: ['GET'])]
|
||||
public function listSupplementaryInsurance(): JsonResponse
|
||||
{
|
||||
return $this->success(['data' => $this->service->listByBundle('supplementary_insurance')]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/categorys/insurance_type', methods: ['GET'])]
|
||||
public function listInsuranceType(): JsonResponse
|
||||
{
|
||||
return $this->success(['data' => $this->service->listByBundle('insurance_type')]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/categorys/state', methods: ['GET'])]
|
||||
public function listStates(): JsonResponse
|
||||
{
|
||||
return $this->success(['data' => $this->service->listByBundle('state')]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/categorys/city', methods: ['GET'])]
|
||||
public function listCities(Request $request): JsonResponse
|
||||
{
|
||||
$stateId = $request->query->get('state_id');
|
||||
$parentId = $stateId !== null ? (int) $stateId : null;
|
||||
|
||||
return $this->success(['data' => $this->service->listByBundle('city', $parentId)]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/categorys/specially_doctor', methods: ['GET'])]
|
||||
public function listSpecialties(): JsonResponse
|
||||
{
|
||||
return $this->success(['data' => $this->service->listByBundle('specially_doctor')]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/categorys/doctor_services', methods: ['GET'])]
|
||||
public function listDoctorServices(): JsonResponse
|
||||
{
|
||||
return $this->success(['data' => $this->service->listByBundle('doctor_services')]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/category', methods: ['POST'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function create(Request $request): JsonResponse
|
||||
{
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
$bundle = trim($data['bundle'] ?? '');
|
||||
$label = trim($data['label'] ?? '');
|
||||
|
||||
if (!in_array($bundle, Category::BUNDLES, true)) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_001, 'bundle نامعتبر است', 422, 'bundle');
|
||||
}
|
||||
|
||||
if ($label === '') {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_001, 'label الزامی است', 422, 'label');
|
||||
}
|
||||
|
||||
$category = $this->service->create($bundle, $label, $data);
|
||||
|
||||
return $this->success(['data' => $category->toArray()], 201);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/category/{id}', methods: ['PATCH'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function update(int $id, Request $request): JsonResponse
|
||||
{
|
||||
$category = $this->repository->find($id);
|
||||
|
||||
if ($category === null) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'دستهبندی یافت نشد', 404);
|
||||
}
|
||||
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
|
||||
if (isset($data['bundle']) && !in_array($data['bundle'], Category::BUNDLES, true)) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_001, 'bundle نامعتبر است', 422, 'bundle');
|
||||
}
|
||||
|
||||
$category = $this->service->update($category, $data);
|
||||
|
||||
return $this->success(['data' => $category->toArray()]);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/category/{id}', methods: ['DELETE'])]
|
||||
#[IsGranted('ROLE_ADMIN')]
|
||||
public function delete(int $id): JsonResponse
|
||||
{
|
||||
$category = $this->repository->find($id);
|
||||
|
||||
if ($category === null) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'دستهبندی یافت نشد', 404);
|
||||
}
|
||||
|
||||
$this->service->delete($category);
|
||||
|
||||
return $this->success(['message' => 'دستهبندی با موفقیت حذف شد']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user