feat: 공통 모듈 추가 (엑셀 내보내기, 계정과목 일괄변경)
Phase 0 - 공통 모듈: - ExportService.php 생성 (Maatwebsite/Excel 기반 엑셀 내보내기) - BulkUpdateAccountCodeRequest.php 생성 (계정과목 일괄변경 유효성 검사) Phase 1 - 계정과목 일괄변경: - WithdrawalController/Service: bulkUpdateAccountCode 메서드 추가 - DepositController/Service: bulkUpdateAccountCode 메서드 추가 - POST /v1/withdrawals/bulk-update-account-code - POST /v1/deposits/bulk-update-account-code Phase 2 - 엑셀 내보내기: - AttendanceController/Service: export, getExportData 메서드 추가 - SalaryController/Service: export, getExportData 메서드 추가 - GET /v1/attendances/export - GET /v1/salaries/export Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,12 +11,17 @@
|
||||
use App\Http\Requests\Attendance\StoreRequest;
|
||||
use App\Http\Requests\Attendance\UpdateRequest;
|
||||
use App\Services\AttendanceService;
|
||||
use App\Services\ExportService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class AttendanceController extends Controller
|
||||
{
|
||||
public function __construct(private AttendanceService $service) {}
|
||||
public function __construct(
|
||||
private AttendanceService $service,
|
||||
private ExportService $exportService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 근태 목록 조회
|
||||
@@ -121,4 +126,32 @@ public function monthlyStats(MonthlyStatsRequest $request): JsonResponse
|
||||
return $this->service->monthlyStats($request->validated());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 근태 엑셀 내보내기
|
||||
* GET /v1/attendances/export
|
||||
*/
|
||||
public function export(Request $request): BinaryFileResponse
|
||||
{
|
||||
$params = $request->only([
|
||||
'user_id',
|
||||
'date',
|
||||
'date_from',
|
||||
'date_to',
|
||||
'status',
|
||||
'department_id',
|
||||
'sort_by',
|
||||
'sort_dir',
|
||||
]);
|
||||
|
||||
$exportData = $this->service->getExportData($params);
|
||||
$filename = '근태현황_'.date('Ymd_His');
|
||||
|
||||
return $this->exportService->download(
|
||||
$exportData['data'],
|
||||
$exportData['headings'],
|
||||
$filename,
|
||||
'근태현황'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user