184 lines
8.4 KiB
PHP
184 lines
8.4 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\Api\Setting\SettingController;
|
|
use App\Http\Controllers\Api\Client\ClientController;
|
|
use App\Http\Controllers\Api\Client\Service\ServiceController as ClientServiceController;
|
|
use App\Http\Controllers\Api\Service\OrderController;
|
|
use App\Http\Controllers\Api\Service\ProductCategoryController;
|
|
use App\Http\Controllers\Api\Service\ServiceController;
|
|
use App\Http\Controllers\Api\Service\SnapshotController;
|
|
use App\Http\Controllers\Api\Service\VmController;
|
|
use App\Http\Controllers\Api\Service\VmRebuildController;
|
|
use App\Http\Controllers\Api\Transaction\TransactionController;
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
Route::prefix('v1')
|
|
->as('api.')
|
|
->group(function () {
|
|
// Auth
|
|
Route::prefix('client')
|
|
->as('client.')
|
|
->group(function () {
|
|
Route::controller(ClientController::class)->group(function () {
|
|
Route::post('login', 'login')->name('login');
|
|
Route::post('register', 'register')->name('register');
|
|
Route::post('refresh', 'refresh')->name('refresh');
|
|
|
|
Route::group(['middleware' => ['api.auth']], function () {
|
|
Route::get('me', 'me')->name('me');
|
|
Route::post('logout', 'logout')->name('logout');
|
|
Route::put('update', 'update')->name('update');
|
|
});
|
|
});
|
|
|
|
Route::middleware(['api.auth'])
|
|
->controller(OrderController::class)
|
|
->group(function () {
|
|
Route::get('orders', 'getClientOrders')->name('orders.list');
|
|
Route::get('orders/{id}', 'getClientOrderDetail')->name('orders.detail');
|
|
Route::post('orders/{id}/retry', 'retryOrderProvisioning')->name('orders.retry');
|
|
Route::get('invoices', 'getClientInvoices')->name('invoices.list');
|
|
Route::get('invoices/{id}', 'getClientInvoiceDetail')->name('invoices.detail');
|
|
Route::get('invoices/order/{orderNum}', 'getClientInvoiceDetailByOrderNum')->name(
|
|
'invoices.detailByOrderNum',
|
|
);
|
|
Route::get('dich-vu', 'getClientServices')->name('services.list');
|
|
Route::patch('dich-vu/{id}/auto-renew', 'updateClientServiceAutoRenew')->name(
|
|
'services.autoRenew.update',
|
|
);
|
|
Route::post('dich-vu/{id}/renew', 'renewService')->name('services.renew');
|
|
});
|
|
|
|
Route::middleware(['api.auth'])
|
|
->prefix('client-service')
|
|
->controller(ClientServiceController::class)
|
|
->as('client-service.')
|
|
->group(function () {
|
|
Route::get('/', 'getService')->name('list');
|
|
Route::get('{uuid}', 'getDetail')->name('detail');
|
|
Route::get('{uuid}/console-ticket', 'getConsoleTicket')->name('console-ticket');
|
|
});
|
|
|
|
Route::middleware(['api.auth'])
|
|
->get('get-ticket-console', [ClientServiceController::class, 'getTicketByOrderNum'])
|
|
->name('console-ticket');
|
|
|
|
Route::middleware(['api.auth'])
|
|
->prefix('service')
|
|
->controller(ServiceController::class)
|
|
->as('service.')
|
|
->group(function () {
|
|
Route::get('/', 'getService')->name('list');
|
|
Route::get('{uuid}', 'getDetailServiceCustomer')->name('detail');
|
|
});
|
|
|
|
Route::middleware(['api.auth'])
|
|
->controller(TransactionController::class)
|
|
->group(function () {
|
|
Route::get('payment-history', 'getClientPaymentHistory')->name('payment-history.list');
|
|
});
|
|
});
|
|
|
|
// Services (Products) - Public & Protected Routes
|
|
Route::prefix('services')
|
|
->as('services.')
|
|
->group(function () {
|
|
Route::controller(ServiceController::class)->group(function () {
|
|
Route::get('get-list', 'getService')->name('getList');
|
|
Route::get('{product:slug}', 'getDetailService')->name('detail');
|
|
});
|
|
});
|
|
|
|
Route::middleware(['api.auth'])
|
|
->prefix('orders')
|
|
->as('orders.')
|
|
->group(function () {
|
|
Route::controller(OrderController::class)->group(function () {
|
|
Route::get('/', 'getList')->name('list');
|
|
Route::post('/', 'storeOrder')->name('store');
|
|
Route::post('{id}/pay', 'payOrder')->name('pay');
|
|
});
|
|
});
|
|
|
|
Route::prefix('setting')
|
|
->as('setting.')
|
|
->group(function () {
|
|
Route::controller(SettingController::class)->group(function () {
|
|
Route::get('/', 'getSetting')->name('get');
|
|
});
|
|
});
|
|
|
|
// Product Categories - Public Routes (no auth required)
|
|
Route::prefix('group')
|
|
->as('product-categories.')
|
|
->group(function () {
|
|
Route::controller(ProductCategoryController::class)->group(function () {
|
|
Route::get('get-list', 'getCategories')->name('getList');
|
|
Route::get('{product_categories:slug}', 'getDetailCategory')->name('detail');
|
|
Route::get('{parentSlug}/{childSlug}', 'getChildCategoryWithParent')->name('childWithParent');
|
|
});
|
|
});
|
|
|
|
// Addons - Get available addons for a product
|
|
Route::prefix('products')
|
|
->as('products.')
|
|
->group(function () {
|
|
Route::get('{productId}/addons', [ServiceController::class, 'getProductAddons'])->name('addons');
|
|
});
|
|
|
|
Route::middleware(['api.auth'])
|
|
->prefix('transaction')
|
|
->as('transaction.')
|
|
->group(function () {
|
|
Route::controller(TransactionController::class)->group(function () {
|
|
Route::get('get-list', 'getTransactions')->name('getList');
|
|
Route::post('pay', 'handle')->name('pay');
|
|
Route::get('verify', 'verifyPayment')->name('verify');
|
|
Route::get('detail-by-code', 'getByPublicCode')->name('detailByCode');
|
|
});
|
|
});
|
|
});
|
|
|
|
Route::get('v1/payment/vnpay/return', [TransactionController::class, 'returnCallback']);
|
|
|
|
Route::prefix('v1/system')
|
|
->middleware(['api.auth'])
|
|
->group(function () {
|
|
// VM power & network operations
|
|
Route::controller(VmController::class)->group(function () {
|
|
Route::post('vm-power-on', 'powerOn')->name('vm.power-on');
|
|
Route::post('vm-power-off', 'powerOff')->name('vm.power-off');
|
|
Route::post('vm-change-ip', 'changeIp')->name('vm.change-ip');
|
|
Route::post('vm-change-port', 'changePort')->name('vm.change-port');
|
|
Route::get('get-ticket-console', 'consoleTicket')->name('vm.console-ticket');
|
|
Route::post('vm-restart', 'restart')->name('vm.restart');
|
|
});
|
|
|
|
// VM Snapshot operations
|
|
Route::controller(SnapshotController::class)->group(function () {
|
|
Route::get('vm-snapshots', 'index')->name('vm.snapshots');
|
|
Route::post('vm-create-snapshot', 'store')->name('vm.create-snapshot');
|
|
Route::post('vm-revert-snapshot', 'revert')->name('vm.revert-snapshot');
|
|
Route::post('vm-delete-snapshot', 'destroy')->name('vm.delete-snapshot');
|
|
});
|
|
|
|
// VM Rebuild & Addon operations
|
|
Route::controller(VmRebuildController::class)->group(function () {
|
|
Route::get('vm-rebuild-options', 'options')->name('vm.rebuild-options');
|
|
Route::post('vm-rebuild', 'rebuild')->name('vm.rebuild');
|
|
Route::get('vm-addon-options', 'addonOptions')->name('vm.addon-options');
|
|
Route::post('vm-upgrade-addons', 'upgradeAddons')->name('vm.upgrade-addons');
|
|
});
|
|
});
|
|
|
|
Route::any('{any}', function () {
|
|
return response()->json(
|
|
[
|
|
'error' => true,
|
|
'status' => 404,
|
|
'message' => 'API Route not found',
|
|
],
|
|
404,
|
|
);
|
|
})->where('any', '^v1/.*');
|