mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
list of "my evaluation near end"
This commit is contained in:
@@ -17,9 +17,14 @@ use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationRepository;
|
||||
use DateTimeImmutable;
|
||||
use DateInterval;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
@@ -28,20 +33,28 @@ use function in_array;
|
||||
|
||||
class AccompanyingPeriodWorkEvaluationApiController
|
||||
{
|
||||
private AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository;
|
||||
|
||||
private DocGeneratorTemplateRepository $docGeneratorTemplateRepository;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private SerializerInterface $serializer;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository,
|
||||
DocGeneratorTemplateRepository $docGeneratorTemplateRepository,
|
||||
SerializerInterface $serializer,
|
||||
PaginatorFactory $paginatorFactory
|
||||
PaginatorFactory $paginatorFactory,
|
||||
Security $security
|
||||
) {
|
||||
$this->accompanyingPeriodWorkEvaluationRepository = $accompanyingPeriodWorkEvaluationRepository;
|
||||
$this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository;
|
||||
$this->serializer = $serializer;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +89,28 @@ class AccompanyingPeriodWorkEvaluationApiController
|
||||
]
|
||||
), JsonResponse::HTTP_OK, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-period/work/evaluation/my-near-end")
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function myWorksNearEndDate(Request $request): JsonResponse
|
||||
{
|
||||
$total = $this->accompanyingPeriodWorkEvaluationRepository
|
||||
->countNearMaxDateByUser($this->security->getUser());
|
||||
$paginator = $this->paginatorFactory->create($total);
|
||||
$works = $this->accompanyingPeriodWorkEvaluationRepository
|
||||
->findNearMaxDateByUser($this->security->getUser(),
|
||||
$paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
|
||||
|
||||
$collection = new Collection($works, $paginator);
|
||||
|
||||
return new JsonResponse(
|
||||
$this->serializer->serialize($collection, 'json', ['groups' => 'read']),
|
||||
JsonResponse::HTTP_OK,
|
||||
[],
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user