Перевод на доменную архитектуру
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Application\Reports\ReportSavePathService;
|
||||
use App\Models\Department;
|
||||
use App\Models\MedicalHistorySnapshot;
|
||||
use App\Models\MetrikaResult;
|
||||
@@ -17,7 +18,8 @@ class AutoReportService
|
||||
{
|
||||
public function __construct(
|
||||
protected ReportService $reportService,
|
||||
protected DateRangeService $dateRangeService
|
||||
protected DateRangeService $dateRangeService,
|
||||
protected ReportSavePathService $reportSavePathService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -81,25 +83,13 @@ class AutoReportService
|
||||
$this->deleteExistingReport($existingReport);
|
||||
}
|
||||
|
||||
// Получаем данные для отчета
|
||||
$reportData = $this->prepareReportData($scopedUser, $department, $dateRange);
|
||||
|
||||
// Создаем отчет
|
||||
DB::transaction(function () use ($scopedUser, $reportData) {
|
||||
$this->reportService->storeReport($reportData, $scopedUser, true);
|
||||
DB::transaction(function () use ($scopedUser, $department, $dateRange) {
|
||||
$this->reportSavePathService->saveAutoFill($scopedUser, $department, $dateRange);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Подготовить данные для отчета
|
||||
*/
|
||||
private function prepareReportData(User $user, Department $department, DateRange $dateRange): array
|
||||
{
|
||||
return $this->reportService->buildAutoFillReportPayload($user, $department, $dateRange);
|
||||
}
|
||||
|
||||
private function scopeUserToDepartment(User $user, Department $department): User
|
||||
{
|
||||
$scopedUser = clone $user;
|
||||
|
||||
Reference in New Issue
Block a user