chore: initial import for test contour

This commit is contained in:
sova-bootstrap
2026-05-27 19:36:32 +03:00
commit 166cdb148e
282 changed files with 84872 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace App\Service;
use Doctrine\ORM\EntityManagerInterface;
/**
* Импорт акций из материализованного представления (Bitrix view).
*
* См. PromoController + CrudResponder для CRUD; этот сервис — только syncFromView*.
*/
final class PromoCrudService
{
public function __construct(
private EntityManagerInterface $em,
) {
}
public function syncFromViewPromo(string $viewName = 'public.view_promo'): int
{
if (!preg_match('/^[A-Za-z0-9_\.]+$/', $viewName)) {
throw new \InvalidArgumentException('Invalid view name');
}
$sql = sprintf(
'INSERT INTO promo (
id,
name,
active,
region_id,
alias,
anons,
content,
update_at,
clinics,
timer,
timer_bg,
short_name,
link_services,
link_staff,
period,
photos
)
SELECT
id,
name,
active,
region_id,
alias,
anons,
content,
update_at,
clinics,
timer,
timer_bg,
short_name,
link_services,
link_staff,
period,
photos
FROM %s
ON CONFLICT (id) DO UPDATE SET
name = EXCLUDED.name,
active = EXCLUDED.active,
region_id = EXCLUDED.region_id,
alias = EXCLUDED.alias,
anons = EXCLUDED.anons,
content = EXCLUDED.content,
update_at = EXCLUDED.update_at,
clinics = EXCLUDED.clinics,
timer = EXCLUDED.timer,
timer_bg = EXCLUDED.timer_bg,
short_name = EXCLUDED.short_name,
link_services = EXCLUDED.link_services,
link_staff = EXCLUDED.link_staff,
period = EXCLUDED.period,
photos = EXCLUDED.photos',
$viewName
);
return (int) $this->em->getConnection()->executeStatement($sql);
}
}