feat: Reimplement order and invoice management with new service and repository layers, introduce compression middleware, and update database schema.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\System;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\CompressionService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CompressionTestController extends Controller
|
||||
{
|
||||
/**
|
||||
* Test compression with large dataset
|
||||
*/
|
||||
public function test(Request $request): JsonResponse
|
||||
{
|
||||
// Generate large test data
|
||||
$testData = [
|
||||
'message' => 'Compression test response',
|
||||
'timestamp' => now()->toISOString(),
|
||||
'client_capabilities' => CompressionService::getClientCapabilities($request),
|
||||
'large_data' => $this->generateTestData(),
|
||||
'meta' => [
|
||||
'total_items' => 1000,
|
||||
'page' => 1,
|
||||
'per_page' => 50,
|
||||
'compression_enabled' => true,
|
||||
]
|
||||
];
|
||||
|
||||
$content = json_encode($testData);
|
||||
$compressionInfo = CompressionService::getCompressionInfo($content);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $testData,
|
||||
'compression_analysis' => $compressionInfo,
|
||||
'response_size' => CompressionService::formatBytes(strlen($content))
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get compression statistics
|
||||
*/
|
||||
public function stats(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'client_capabilities' => CompressionService::getClientCapabilities($request),
|
||||
'server_capabilities' => [
|
||||
'gzip' => function_exists('gzencode'),
|
||||
'deflate' => function_exists('gzdeflate'),
|
||||
'brotli' => function_exists('brotli_compress'),
|
||||
],
|
||||
'middleware_enabled' => true,
|
||||
'min_compression_size' => '1KB',
|
||||
'compression_level' => 6,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate large test data for compression testing
|
||||
*/
|
||||
private function generateTestData(): array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
// Generate repeated patterns that compress well
|
||||
for ($i = 1; $i <= 100; $i++) {
|
||||
$data[] = [
|
||||
'id' => $i,
|
||||
'name' => "Test Item Number {$i}",
|
||||
'description' => 'This is a test description that contains repetitive text to demonstrate compression effectiveness. Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
|
||||
'status' => $i % 2 === 0 ? 'active' : 'inactive',
|
||||
'created_at' => now()->subDays($i)->toISOString(),
|
||||
'metadata' => [
|
||||
'category' => 'test-category-' . ($i % 5),
|
||||
'tags' => ['test', 'compression', 'api', 'laravel'],
|
||||
'properties' => [
|
||||
'property_1' => 'Repeated property value',
|
||||
'property_2' => 'Another repeated property value',
|
||||
'property_3' => 'Yet another repeated property value',
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user