移除旧版导出
This commit is contained in:
@@ -4,13 +4,11 @@ namespace App\Http\Controllers\Recon;
|
||||
|
||||
use App\Exceptions\RepositoryException;
|
||||
use App\Models\SettlementModel;
|
||||
use App\Services\ExportService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\AnnoRoute\Attribute\GetRoute;
|
||||
use Modules\AnnoRoute\Attribute\RequestAttribute;
|
||||
use Modules\Common\Http\Controllers\BaseController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* 结算表管理(D9 生成于对账结算,D10 导出下载存档)
|
||||
@@ -52,26 +50,4 @@ class SettlementController extends BaseController
|
||||
}
|
||||
return $this->success($settlement->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* D10 导出下载:?format=xlsx|pdf,成功后回写 file_path 存档标记
|
||||
*/
|
||||
#[GetRoute(route: '/{id}/download', authorize: 'download', where: ['id' => '[0-9]+'])]
|
||||
public function download(int $id, Request $request): Response
|
||||
{
|
||||
$settlement = SettlementModel::find($id);
|
||||
if (empty($settlement)) {
|
||||
throw new RepositoryException('结算表不存在');
|
||||
}
|
||||
$format = (string) $request->query('format', ExportService::FORMAT_XLSX);
|
||||
|
||||
$response = app(ExportService::class)->download('settlement', $settlement, $format);
|
||||
|
||||
// 同步流式下载不落盘,file_path 仅作存档标记(后续切队列导出时替换为真实文件路径)
|
||||
$extension = $format === ExportService::FORMAT_PDF ? 'pdf' : 'xlsx';
|
||||
$settlement->file_path = 'exports/settlement/' . $settlement->settlement_no . '.' . $extension;
|
||||
$settlement->save();
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user