chore: initial import for test contour with k3s CI
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\AlertSms;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method AlertSms|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method AlertSms|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method AlertSms[] findAll()
|
||||
* @method AlertSms[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class AlertSmsRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, AlertSms::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Banner;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Banner|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Banner|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Banner[] findAll()
|
||||
* @method Banner[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class BannerRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Banner::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\CategoryPage;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method CategoryPage|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method CategoryPage|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method CategoryPage[] findAll()
|
||||
* @method CategoryPage[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class CategoryPageRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, CategoryPage::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\City;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<City>
|
||||
*
|
||||
* @method City|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method City|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method City[] findAll()
|
||||
* @method City[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class CityRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, City::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function add(City $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->persist($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function remove(City $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->remove($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
public function all()
|
||||
{
|
||||
return $this->createQueryBuilder('c')
|
||||
->select('c.id, c.name')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Department;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Department|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Department|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Department[] findAll()
|
||||
* @method Department[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class DepartmentRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Department::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\DirectCompany;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<DirectCompany>
|
||||
*
|
||||
* @method DirectCompany|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method DirectCompany|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method DirectCompany[] findAll()
|
||||
* @method DirectCompany[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class DirectCompanyRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, DirectCompany::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function add(DirectCompany $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->persist($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function remove(DirectCompany $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->remove($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\DirectReport;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<DirectReport>
|
||||
*
|
||||
* @method DirectReport|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method DirectReport|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method DirectReport[] findAll()
|
||||
* @method DirectReport[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class DirectReportRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, DirectReport::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function add(DirectReport $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->persist($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function remove(DirectReport $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->remove($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Filial;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Filial|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Filial|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Filial[] findAll()
|
||||
* @method Filial[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class FilialRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Filial::class);
|
||||
}
|
||||
|
||||
public function findByRegion(string $region): array
|
||||
{
|
||||
return $this->createQueryBuilder('filial')
|
||||
->where('filial.address LIKE :address')
|
||||
->setParameter('address', '%' . $region . '%')
|
||||
->orderBy('filial.id')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\LocationView;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Location|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Location|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Location[] findAll()
|
||||
* @method Location[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class LocationViewRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, LocationView::class);
|
||||
}
|
||||
|
||||
public function findBySpecialistId(
|
||||
int $specialistId,
|
||||
bool $onlineMode = false,
|
||||
?int $department = null,
|
||||
?\DateTimeInterface $startDate = null,
|
||||
?\DateTimeInterface $endDate = null
|
||||
): array {
|
||||
// Основной запрос
|
||||
$qb = $this->createQueryBuilder('l')
|
||||
->select('l.id, l.dcode, l.department, l.onlineMode, l.filial, l.active, l.nearestDate, d.name')
|
||||
->leftJoin('App\Entity\Department', 'd', 'WITH', 'd.did = l.department')
|
||||
->where('l.specialistId = :specialistId')
|
||||
->setParameter('specialistId', $specialistId)
|
||||
->andWhere('l.active = true')
|
||||
->andWhere('l.onlineMode = :onlineMode')
|
||||
->setParameter('onlineMode', $onlineMode);
|
||||
|
||||
// Фильтр по отделению (специализации), если указано
|
||||
if ($department !== null && $department > 0) {
|
||||
$qb->andWhere('l.department = :department')
|
||||
->setParameter('department', $department);
|
||||
}
|
||||
|
||||
// Фильтр по дате приема (диапазон дат), если указано
|
||||
if ($startDate !== null) {
|
||||
$qb->andWhere('l.nearestDate >= :startDate')
|
||||
->setParameter('startDate', $startDate);
|
||||
}
|
||||
|
||||
if ($endDate !== null) {
|
||||
$qb->andWhere('l.nearestDate <= :endDate')
|
||||
->setParameter('endDate', $endDate);
|
||||
}
|
||||
|
||||
// Сортировка по ближайшему приему: сначала ближайшие даты (ASC), NULL значения в конце
|
||||
$qb->orderBy('CASE WHEN l.nearestDate IS NULL THEN 1 ELSE 0 END', 'ASC')
|
||||
->addOrderBy('l.nearestDate', 'ASC');
|
||||
|
||||
$mainQuery = $qb->getQuery()->getResult();
|
||||
|
||||
if (empty($mainQuery)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Получаем все уникальные filialId из основного запроса
|
||||
$filialIds = array_filter(array_unique(array_column($mainQuery, 'filial')));
|
||||
|
||||
if (empty($filialIds)) {
|
||||
return $mainQuery;
|
||||
}
|
||||
|
||||
// Запрос для получения данных Filial через EntityManager
|
||||
$entityManager = $this->getEntityManager();
|
||||
$filialQuery = $entityManager->createQueryBuilder()
|
||||
->select('f.fid, f.address, f.company, f.addressName')
|
||||
->from('App\Entity\Filial', 'f')
|
||||
->where('f.fid IN (:filialIds)')
|
||||
->setParameter('filialIds', $filialIds)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
// Создаем мапу для быстрого доступа к данным Filial
|
||||
$filialMap = [];
|
||||
foreach ($filialQuery as $filial) {
|
||||
$filialMap[$filial['fid']] = [
|
||||
'address' => $filial['address'],
|
||||
'company' => $filial['company'],
|
||||
'addressName' => $filial['addressName']
|
||||
];
|
||||
}
|
||||
|
||||
// Объединяем данные
|
||||
foreach ($mainQuery as &$record) {
|
||||
$filialId = $record['filial'];
|
||||
if ($filialId && isset($filialMap[$filialId])) {
|
||||
$record = array_merge($record, $filialMap[$filialId]);
|
||||
} else {
|
||||
// Добавляем пустые значения если filial не найден
|
||||
$record['address'] = null;
|
||||
$record['company'] = null;
|
||||
$record['addressName'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $mainQuery;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Page;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Page|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Page|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Page[] findAll()
|
||||
* @method Page[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PageRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Page::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PriceDepartment;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method PriceDepartment|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PriceDepartment|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PriceDepartment[] findAll()
|
||||
* @method PriceDepartment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PriceDepartmentRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PriceDepartment::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\PriceList;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
/**
|
||||
* @method PriceList|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method PriceList|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method PriceList[] findAll()
|
||||
* @method PriceList[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PriceListRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, PriceList::class);
|
||||
}
|
||||
|
||||
public function createFilteredQueryBuilder(array $filters): QueryBuilder
|
||||
{
|
||||
$qb = $this->createQueryBuilder('p')
|
||||
->addOrderBy('p.filial, p.schname', 'ASC');
|
||||
|
||||
if (!empty($filters['kodoper'])) {
|
||||
$kodoper = match (true) {
|
||||
is_array($filters['kodoper']) => array_filter(
|
||||
array_map('trim', array_filter($filters['kodoper'], 'is_string')),
|
||||
function($code) { return $code !== ''; }
|
||||
),
|
||||
is_string($filters['kodoper']) && trim($filters['kodoper']) !== '' => [trim($filters['kodoper'])],
|
||||
default => []
|
||||
};
|
||||
|
||||
if (!empty($kodoper)) {
|
||||
// Логируем значения kodoper для отладки
|
||||
error_log('PriceListRepository: filtering by kodoper=' . json_encode($kodoper));
|
||||
|
||||
$qb->andWhere('p.kodoper IN (:codes)')
|
||||
->setParameter('codes', $kodoper);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filters['schname']) && trim($filters['schname']) !== '') {
|
||||
$qb->andWhere($qb->expr()->like('LOWER(p.schname)', 'LOWER(:schname)'))
|
||||
->setParameter('schname', '%' . trim($filters['schname']) . '%');
|
||||
}
|
||||
|
||||
if (!empty($filters['filial'])) {
|
||||
$filialIds = match (true) {
|
||||
is_array($filters['filial']) => array_filter($filters['filial'], function($id) {
|
||||
return $id !== null && $id !== '';
|
||||
}),
|
||||
is_string($filters['filial']) && $filters['filial'] !== '' => [$filters['filial']],
|
||||
is_numeric($filters['filial']) => [(int)$filters['filial']],
|
||||
default => []
|
||||
};
|
||||
|
||||
if (!empty($filialIds)) {
|
||||
$qb->andWhere('p.filial IN (:filial)')
|
||||
->setParameter('filial', $filialIds);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filters['actual'])) {
|
||||
if ($filters['actual']) {
|
||||
$qb->andWhere('p.dateUpdate >= :dateUpdate')
|
||||
->setParameter('dateUpdate', (new \DateTime())
|
||||
->modify('-2 day')
|
||||
->format('Y-m-d 00:00:00')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($filters['groupId'])) {
|
||||
$qb->andWhere('p.groupId = :groupId')
|
||||
->setParameter('groupId', (int) $filters['groupId']);
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Price;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Price|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Price|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Price[] findAll()
|
||||
* @method Price[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class PriceRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Price::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Record;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Record|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Record|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Record[] findAll()
|
||||
* @method Record[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class RecordRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Record::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Review;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method Review|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Review|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Review[] findAll()
|
||||
* @method Review[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ReviewRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Review::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\ReviewSource;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<ReviewSource>
|
||||
*
|
||||
* @method ReviewSource|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method ReviewSource|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ReviewSource[] findAll()
|
||||
* @method ReviewSource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ReviewSourceRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, ReviewSource::class);
|
||||
}
|
||||
|
||||
public function findAll()
|
||||
{
|
||||
return $this->findBy([], ['name' => 'ASC']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function add(ReviewSource $entity, bool $flush = true): void
|
||||
{
|
||||
if (! $entity->getDateCreate()) {
|
||||
$entity->setDateCreate(new \DateTime());
|
||||
}
|
||||
|
||||
$this->_em->persist($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function remove(ReviewSource $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->remove($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
public function findByCity($cityId)
|
||||
{
|
||||
return $this->createQueryBuilder('r')
|
||||
->select('r.name, SUM(r.countRow) AS count_row_total, (SUM(r.rating) / COUNT(r.id)) AS rating_total')
|
||||
->distinct()
|
||||
->where('r.city in (:city)')
|
||||
->setParameter('city', $cityId)
|
||||
->groupBy('r.name')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\SpecialistView;
|
||||
use App\Support\OnlineMode;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
class SpecialistViewRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, SpecialistView::class);
|
||||
}
|
||||
|
||||
public function createFilteredQueryBuilder(array $filters): QueryBuilder
|
||||
{
|
||||
$qb = $this->createQueryBuilder('s')
|
||||
->andWhere('s.active = true');
|
||||
|
||||
$this->applyFilters($qb, $filters);
|
||||
$this->applyOrderBy($qb, $filters['order_by'] ?? null);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
private function applyFilters(QueryBuilder $qb, array $filters): void
|
||||
{
|
||||
foreach ($filters as $key => $value) {
|
||||
// onlineMode=0 — валидный фильтр; empty(0) в PHP === true, поэтому обрабатываем отдельно.
|
||||
if ($key === 'onlineMode') {
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
$this->applyOnlineModeFilter($qb, OnlineMode::isOnline($value));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match ($key) {
|
||||
'regionId' => $this->applyRegionFilter($qb, $value),
|
||||
'alias' => $this->applyAliasFilter($qb, $value),
|
||||
'filial' => $this->applyFilialFilter($qb, $value),
|
||||
'dcode' => $this->applyDcodeFilter($qb, $value),
|
||||
'kinder' => $this->applyKinderFilter($qb, $value),
|
||||
'category' => $this->applyCategoryFilter($qb, $value),
|
||||
'department' => $this->applyDepartmentFilter($qb, $value),
|
||||
'depAlias' => $this->applyDepAliasFilter($qb, $value),
|
||||
'name' => $this->applyNameFilter($qb, $value),
|
||||
'current_date' => $this->applyCurrentDateFilter($qb, $value),
|
||||
default => null // Игнорируем неизвестные фильтры
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private function applyKinderFilter(QueryBuilder $qb, $sType): void
|
||||
{
|
||||
$sType = match (true) {
|
||||
is_array($sType) => array_map('intval', $sType),
|
||||
is_string($sType) => [(int) $sType],
|
||||
is_numeric($sType) => [$sType],
|
||||
default => []
|
||||
};
|
||||
|
||||
$qb->andWhere('s.sType in (:sType)')
|
||||
->setParameter('sType', $sType);
|
||||
}
|
||||
|
||||
private function applyOnlineModeFilter(QueryBuilder $qb, bool $onlineMode): void
|
||||
{
|
||||
$qb->andWhere('EXISTS (
|
||||
SELECT 1 FROM App\Entity\LocationView l
|
||||
WHERE l.specialistId = s.id AND l.onlineMode = :onlineMode
|
||||
)')->setParameter('onlineMode', $onlineMode);
|
||||
}
|
||||
|
||||
private function applyRegionFilter(QueryBuilder $qb, $regionId): void
|
||||
{
|
||||
$qb->andWhere('s.regionId in (:regionId)')
|
||||
->setParameter('regionId', $regionId);
|
||||
}
|
||||
|
||||
private function applyAliasFilter(QueryBuilder $qb, string $alias): void
|
||||
{
|
||||
$qb->andWhere('s.alias = :alias')
|
||||
->setParameter('alias', $alias);
|
||||
}
|
||||
|
||||
private function applyFilialFilter(QueryBuilder $qb, $filial): void
|
||||
{
|
||||
$filialIds = array_map('intval', (array)$filial);
|
||||
|
||||
$qb->andWhere('EXISTS (
|
||||
SELECT 1 FROM App\Entity\LocationView l2
|
||||
WHERE l2.specialistId = s.id AND l2.filial in (:filial)
|
||||
)')->setParameter('filial', $filialIds);
|
||||
}
|
||||
|
||||
private function applyDcodeFilter(QueryBuilder $qb, $dcode): void
|
||||
{
|
||||
$dcode = match (true) {
|
||||
is_array($dcode) => array_map('intval', $dcode),
|
||||
is_string($dcode) => [(int) $dcode],
|
||||
is_numeric($dcode) => [$dcode],
|
||||
default => []
|
||||
};
|
||||
|
||||
if (!empty($dcode)) {
|
||||
$qb->andWhere('EXISTS (
|
||||
SELECT 1 FROM App\Entity\LocationView l3
|
||||
WHERE l3.specialistId = s.id AND l3.dcode in (:dcode)
|
||||
)')->setParameter('dcode', $dcode);
|
||||
}
|
||||
}
|
||||
|
||||
private function applyCategoryFilter(QueryBuilder $qb, $category): void
|
||||
{
|
||||
$qb->andWhere('s.category = :category')
|
||||
->setParameter('category', $category);
|
||||
}
|
||||
|
||||
private function applyDepartmentFilter(QueryBuilder $qb, $department): void
|
||||
{
|
||||
$qb->andWhere('EXISTS (
|
||||
SELECT 1 FROM App\Entity\LocationView l4
|
||||
WHERE l4.specialistId = s.id AND l4.department = :department
|
||||
)')->setParameter('department', (int) $department);
|
||||
}
|
||||
|
||||
private function applyDepAliasFilter(QueryBuilder $qb, string $depAlias): void
|
||||
{
|
||||
$qb->andWhere('EXISTS (
|
||||
SELECT 1 FROM App\Entity\LocationView l5
|
||||
JOIN App\Entity\Department d WITH d.did = l5.department
|
||||
WHERE l5.specialistId = s.id AND d.alias = :depAlias
|
||||
)')->setParameter('depAlias', $depAlias);
|
||||
}
|
||||
|
||||
private function applyNameFilter(QueryBuilder $qb, string $name): void
|
||||
{
|
||||
$qb->andWhere($qb->expr()->like('LOWER(s.name)', 'LOWER(:search)'))
|
||||
->setParameter('search', '%' . trim($name) . '%');
|
||||
}
|
||||
|
||||
private function applyCurrentDateFilter(QueryBuilder $qb, $currentDate): void
|
||||
{
|
||||
if (empty($currentDate)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Парсим дату: формат "13.01.2026 - 20.01.2026" (с пробелами вокруг дефиса)
|
||||
// Также поддерживаем варианты: "13.01.2026+-+20.01.2026" или "13.01.2026-20.01.2026"
|
||||
$dateString = trim($currentDate);
|
||||
|
||||
// Разделяем по дефису с пробелами или без
|
||||
// Используем регулярное выражение для более точного парсинга
|
||||
if (preg_match('/^(.+?)\s*[-+]\s*(.+)$/', $dateString, $matches)) {
|
||||
$startDateStr = trim($matches[1]);
|
||||
$endDateStr = trim($matches[2]);
|
||||
} else {
|
||||
// Если не удалось распарсить, пробуем просто разделить по дефису
|
||||
$parts = preg_split('/\s*[-+]\s*/', $dateString, 2);
|
||||
if (count($parts) < 2) {
|
||||
return;
|
||||
}
|
||||
$startDateStr = trim($parts[0]);
|
||||
$endDateStr = trim($parts[1]);
|
||||
}
|
||||
|
||||
// Парсим дату из формата "dd.mm.yyyy" или "yyyy-mm-dd"
|
||||
$startDate = $this->parseDate($startDateStr);
|
||||
$endDate = $this->parseDate($endDateStr);
|
||||
|
||||
if (!$startDate || !$endDate) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Фильтруем специалистов, у которых есть локации с nearestDate в указанном диапазоне
|
||||
$qb->andWhere('EXISTS (
|
||||
SELECT 1 FROM App\Entity\LocationView l_date
|
||||
WHERE l_date.specialistId = s.id
|
||||
AND l_date.active = true
|
||||
AND l_date.nearestDate >= :startDate
|
||||
AND l_date.nearestDate <= :endDate
|
||||
)')
|
||||
->setParameter('startDate', $startDate)
|
||||
->setParameter('endDate', $endDate);
|
||||
}
|
||||
|
||||
private function parseDate(string $dateStr): ?\DateTime
|
||||
{
|
||||
$dateStr = trim($dateStr);
|
||||
|
||||
// Пробуем формат "dd.mm.yyyy"
|
||||
if (preg_match('/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/', $dateStr, $matches)) {
|
||||
$day = (int)$matches[1];
|
||||
$month = (int)$matches[2];
|
||||
$year = (int)$matches[3];
|
||||
try {
|
||||
return new \DateTime(sprintf('%04d-%02d-%02d', $year, $month, $day));
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Пробуем формат "yyyy-mm-dd"
|
||||
if (preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $dateStr, $matches)) {
|
||||
$year = (int)$matches[1];
|
||||
$month = (int)$matches[2];
|
||||
$day = (int)$matches[3];
|
||||
try {
|
||||
return new \DateTime(sprintf('%04d-%02d-%02d', $year, $month, $day));
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Пробуем стандартный формат
|
||||
try {
|
||||
return new \DateTime($dateStr);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function applyOrderBy(QueryBuilder $qb, ?string $orderBy): void
|
||||
{
|
||||
$orderConfig = match ($orderBy) {
|
||||
'sort-abc.asc' => ['field' => 's.name', 'direction' => 'ASC'],
|
||||
'sort-abc.desc' => ['field' => 's.name', 'direction' => 'DESC'],
|
||||
'sort-time.asc' => $this->createTimeOrderConfig('ASC'),
|
||||
'sort-time.desc' => $this->createTimeOrderConfig('DESC'),
|
||||
default => ['field' => 's.name', 'direction' => 'ASC']
|
||||
};
|
||||
|
||||
if (isset($orderConfig['join'])) {
|
||||
$qb->leftJoin('App\Entity\LocationView', 'l_sort', 'WITH', 'l_sort.specialistId = s.id');
|
||||
}
|
||||
|
||||
$qb->addOrderBy($orderConfig['field'], $orderConfig['direction']);
|
||||
}
|
||||
|
||||
private function createTimeOrderConfig(string $direction): array
|
||||
{
|
||||
return [
|
||||
'field' => 'l_sort.nearestDate',
|
||||
'direction' => $direction,
|
||||
'join' => true
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
/**
|
||||
* @method User|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method User|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method User[] findAll()
|
||||
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to upgrade (rehash) the user's password automatically over time.
|
||||
*/
|
||||
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||
}
|
||||
|
||||
$user->setPassword($newEncodedPassword);
|
||||
$this->_em->persist($user);
|
||||
$this->_em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Находит неактивных пользователей с только ROLE_USER для удаления
|
||||
* Удаляются пользователи, у которых последняя активность (или дата создания, если активности нет) была до указанной даты
|
||||
*
|
||||
* @param \DateTimeInterface $beforeDate Дата, до которой должна быть последняя активность
|
||||
* @return User[]
|
||||
*/
|
||||
public function findUsersToCleanup(\DateTimeInterface $beforeDate): array
|
||||
{
|
||||
// Ищем пользователей, у которых либо lastActivityAt < beforeDate, либо (lastActivityAt IS NULL AND createdAt < beforeDate)
|
||||
$users = $this->createQueryBuilder('u')
|
||||
->where('(u.lastActivityAt IS NOT NULL AND u.lastActivityAt < :beforeDate) OR (u.lastActivityAt IS NULL AND u.createdAt IS NOT NULL AND u.createdAt < :beforeDate)')
|
||||
->setParameter('beforeDate', $beforeDate)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
// Фильтруем пользователей, у которых только ROLE_USER
|
||||
return array_filter($users, function (User $user) {
|
||||
// Если массив ролей пуст, значит у пользователя только ROLE_USER (который добавляется автоматически)
|
||||
return empty($user->getActualRoles());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Usrlog;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
use Doctrine\ORM\ORMException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Usrlog>
|
||||
*
|
||||
* @method Usrlog|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Usrlog|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Usrlog[] findAll()
|
||||
* @method Usrlog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class UsrlogRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Usrlog::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function add(Usrlog $entity, bool $flush = true): void
|
||||
{
|
||||
if (!$entity->getCreatedAt()) {
|
||||
$entity->setCreatedAt(new \DateTime());
|
||||
}
|
||||
|
||||
$this->_em->persist($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ORMException
|
||||
* @throws OptimisticLockException
|
||||
*/
|
||||
public function remove(Usrlog $entity, bool $flush = true): void
|
||||
{
|
||||
$this->_em->remove($entity);
|
||||
if ($flush) {
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\WidgetFormInput;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method WidgetFormInput|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method WidgetFormInput|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method WidgetFormInput[] findAll()
|
||||
* @method WidgetFormInput[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class WidgetFormInputRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, WidgetFormInput::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\WidgetForm;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @method WidgetForm|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method WidgetForm|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method WidgetForm[] findAll()
|
||||
* @method WidgetForm[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class WidgetFormRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, WidgetForm::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user