Перевод на доменную архитектуру

This commit is contained in:
brusnitsyn
2026-04-26 23:37:50 +09:00
parent 75ca01ffd8
commit f107ebd167
70 changed files with 4656 additions and 2070 deletions

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Application\Reports;
use App\Application\Reports\DTO\GenerateReportResult;
use App\Models\Department;
use App\Models\Report;
use App\Models\User;
use App\Services\DateRange;
use App\Services\ReportService;
final readonly class ReportSavePathService
{
public function __construct(
private ReportFlowDecider $reportFlowDecider,
private ReportInputFactory $reportInputFactory,
private GenerateReportUseCase $generateReportUseCase,
private ReportService $reportService,
) {}
public function usesNewArchitecture(string $reportType = 'daily'): bool
{
return $this->reportFlowDecider->shouldUseNewArchitecture($reportType);
}
/**
* @param array<string, mixed> $validated
*/
public function saveManual(User $actor, array $validated, string $reportType = 'daily'): GenerateReportResult|Report
{
if (! $this->usesNewArchitecture($reportType)) {
return $this->reportService->storeReport($validated, $actor, false);
}
return $this->generateReportUseCase->handle(
$this->reportInputFactory->forManualSave($actor, $validated, $reportType)
);
}
public function saveAutoFill(
User $scopedUser,
Department $department,
DateRange $dateRange,
string $reportType = 'daily',
): GenerateReportResult|Report {
if (! $this->usesNewArchitecture($reportType)) {
$payload = $this->reportService->buildAutoFillReportPayload($scopedUser, $department, $dateRange);
return $this->reportService->storeReport($payload, $scopedUser, true);
}
return $this->generateReportUseCase->handle(
$this->reportInputFactory->forAutoFill($scopedUser, $department, $dateRange, $reportType)
);
}
}