feat(admin): IP pool allocation, billing exports, service attachments
- IP pool: sheet import (xlsx/csv) matched by address, bulk allocate/revoke with notification email (ip_allocated/ip_revoked), ip_pool_logs history. - Orders/invoices: Excel export on branded template (BrandedReportWriter), shared billing filters, order item service info in list responses. - Web design quote Excel export; activity log export. - Service attachments with copy-to-invoice; deployment invoice attachments. - Customer email attachments stored on disk and attached by path. - Admin password change endpoint; user.fullname backfill migration; orders.user_id backfill from logs. - Disable deploy workflow until CI/CD is set up. - Ignore stored customer email and service attachment uploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ea5697cb81
commit
46aa138eec
@@ -2,15 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers\Api\Admin\IpPool\Concerns;
|
||||
|
||||
use App\Imports\IpPoolImport;
|
||||
use App\Services\IpPool\IpPoolSheetImporter;
|
||||
use App\Models\IpPool;
|
||||
use App\Models\ModuleIpAddress;
|
||||
use App\Models\ModuleNetwork;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Maatwebsite\Excel\Validators\ValidationException;
|
||||
|
||||
trait ManagesIpPoolBulkActions
|
||||
{
|
||||
@@ -94,39 +92,24 @@ trait ManagesIpPoolBulkActions
|
||||
]);
|
||||
}
|
||||
|
||||
public function import(Request $request): JsonResponse
|
||||
public function importPreview(Request $request, IpPoolSheetImporter $importer): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'file' => 'required|file|mimes:csv,txt|max:10240',
|
||||
]);
|
||||
$request->validate(['file' => self::IMPORT_FILE_RULE]);
|
||||
|
||||
$countBefore = IpPool::withTrashed()->count();
|
||||
return response()->json(['error' => false, 'data' => $importer->preview($request->file('file'))]);
|
||||
}
|
||||
|
||||
try {
|
||||
Excel::import(new IpPoolImport(), $request->file('file'));
|
||||
} catch (ValidationException $e) {
|
||||
$errors = [];
|
||||
foreach ($e->failures() as $failure) {
|
||||
$errors[] = 'Dòng ' . $failure->row() . ': ' . implode(', ', $failure->errors());
|
||||
}
|
||||
public function import(Request $request, IpPoolSheetImporter $importer): JsonResponse
|
||||
{
|
||||
$request->validate(['file' => self::IMPORT_FILE_RULE]);
|
||||
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => 'Import thất bại',
|
||||
'errors' => $errors,
|
||||
], 422);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['error' => true, 'message' => 'Import thất bại: ' . $e->getMessage()], 500);
|
||||
}
|
||||
|
||||
$countAfter = IpPool::withTrashed()->count();
|
||||
|
||||
IpPool::resyncAllContacts();
|
||||
$summary = $importer->import($request->file('file'));
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => 'Import thành công',
|
||||
'created' => max(0, $countAfter - $countBefore),
|
||||
'message' => "Đã thêm {$summary['create']}, cập nhật {$summary['update']} IP"
|
||||
. ($summary['error_count'] ? ", bỏ qua {$summary['error_count']} dòng lỗi" : ''),
|
||||
'data' => $summary,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -142,7 +125,7 @@ trait ManagesIpPoolBulkActions
|
||||
$updated = 0;
|
||||
$hostByNet = ModuleNetwork::pluck('module_host_id', 'id');
|
||||
|
||||
IpPool::chunkById(500, function ($pools) use (&$created, &$updated, $hostByNet) {
|
||||
IpPool::whereNotNull('module_network_id')->chunkById(500, function ($pools) use (&$created, &$updated, $hostByNet) {
|
||||
foreach ($pools as $pool) {
|
||||
$hostId = $hostByNet[$pool->module_network_id] ?? null;
|
||||
$netmask = $pool->netmask ?: '255.255.255.0';
|
||||
|
||||
Reference in New Issue
Block a user