This commit is contained in:
root 2019-12-02 17:07:44 +08:00
parent e7618018f6
commit 5a917e04e7
2 changed files with 68 additions and 26 deletions

View File

@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Models\Plan;
use App\Models\Server;
use App\Utils\Helper;
class AppController extends Controller
{
public function data (Request $request) {
$user = $request->user;
$nodes = [];
if ($user->plan_id) {
$user['plan'] = Plan::find($user->plan_id);
if (!$user['plan']) {
abort(500, '订阅计划不存在');
}
if ($user->expired_at > time()) {
$servers = Server::where('show', 1)->get();
foreach ($servers as $item) {
$groupId = json_decode($item['group_id']);
if (in_array($user->group_id, $groupId)) {
array_push($nodes, $item);
}
}
}
}
return response([
'nodes' => $nodes,
'u' => $user->u,
'd' => $user->d,
'transfer_enable' => $user->transfer_enable,
'expired_time' => $user->expired_at
]);
}
}

View File

@ -20,27 +20,27 @@ Route::prefix('v1')
->middleware('admin') ->middleware('admin')
->group(function () { ->group(function () {
// Config // Config
Route::get('config', 'Admin\\ConfigController@index'); Route::get ('config', 'Admin\\ConfigController@index');
Route::post('config/save', 'Admin\\ConfigController@save'); Route::post('config/save', 'Admin\\ConfigController@save');
// Plan // Plan
Route::get('plan', 'Admin\\PlanController@index'); Route::get ('plan', 'Admin\\PlanController@index');
Route::post('plan/save', 'Admin\\PlanController@save'); Route::post('plan/save', 'Admin\\PlanController@save');
Route::post('plan/drop', 'Admin\\PlanController@drop'); Route::post('plan/drop', 'Admin\\PlanController@drop');
Route::post('plan/update', 'Admin\\PlanController@update'); Route::post('plan/update', 'Admin\\PlanController@update');
// Server // Server
Route::get('server', 'Admin\\ServerController@index'); Route::get ('server', 'Admin\\ServerController@index');
Route::post('server/save', 'Admin\\ServerController@save'); Route::post('server/save', 'Admin\\ServerController@save');
Route::get('server/group', 'Admin\\ServerController@group'); Route::get ('server/group', 'Admin\\ServerController@group');
Route::post('server/group/save', 'Admin\\ServerController@groupSave'); Route::post('server/group/save', 'Admin\\ServerController@groupSave');
Route::post('server/group/drop', 'Admin\\ServerController@groupDrop'); Route::post('server/group/drop', 'Admin\\ServerController@groupDrop');
Route::post('server/drop', 'Admin\\ServerController@drop'); Route::post('server/drop', 'Admin\\ServerController@drop');
Route::post('server/update', 'Admin\\ServerController@update'); Route::post('server/update', 'Admin\\ServerController@update');
// Order // Order
Route::get('order', 'Admin\\OrderController@index'); Route::get ('order', 'Admin\\OrderController@index');
Route::post('order/repair', 'Admin\\OrderController@repair'); Route::post('order/repair', 'Admin\\OrderController@repair');
Route::post('order/update', 'Admin\\OrderController@update'); Route::post('order/update', 'Admin\\OrderController@update');
// User // User
Route::get('user', 'Admin\\UserController@index'); Route::get ('user', 'Admin\\UserController@index');
Route::post('user/update', 'Admin\\UserController@update'); Route::post('user/update', 'Admin\\UserController@update');
}); });
// User // User
@ -48,29 +48,29 @@ Route::prefix('v1')
->middleware('user') ->middleware('user')
->group(function () { ->group(function () {
// User // User
Route::get('resetSecurity', 'UserController@resetSecurity'); Route::get ('resetSecurity', 'UserController@resetSecurity');
Route::get('dashboard', 'UserController@dashboard'); Route::get ('dashboard', 'UserController@dashboard');
Route::get('subscribe', 'UserController@subscribe'); Route::get ('subscribe', 'UserController@subscribe');
Route::get('logout', 'UserController@logout'); Route::get ('logout', 'UserController@logout');
Route::get('info', 'UserController@info'); Route::get ('info', 'UserController@info');
Route::post('changePassword', 'UserController@changePassword'); Route::post('changePassword', 'UserController@changePassword');
Route::post('update', 'UserController@update'); Route::post('update', 'UserController@update');
// Order // Order
Route::get('order', 'OrderController@index'); Route::get ('order', 'OrderController@index');
Route::post('order/save', 'OrderController@save'); Route::post('order/save', 'OrderController@save');
Route::post('order/checkout', 'OrderController@checkout'); Route::post('order/checkout', 'OrderController@checkout');
Route::get('order/check', 'OrderController@check'); Route::get ('order/check', 'OrderController@check');
Route::get('order/details', 'OrderController@details'); Route::get ('order/details', 'OrderController@details');
Route::get('order/getPaymentMethod', 'OrderController@getPaymentMethod'); Route::get ('order/getPaymentMethod', 'OrderController@getPaymentMethod');
// Plan // Plan
Route::post('plan/info', 'PlanController@info'); Route::post('plan/info', 'PlanController@info');
// Invite // Invite
Route::get('invite', 'InviteController@index'); Route::get ('invite', 'InviteController@index');
Route::get('invite/save', 'InviteController@save'); Route::get ('invite/save', 'InviteController@save');
Route::get('invite/details', 'InviteController@details'); Route::get ('invite/details', 'InviteController@details');
// Tutorial // Tutorial
Route::get('tutorial/getSubscribeUrl', 'TutorialController@getSubscribeUrl'); Route::get ('tutorial/getSubscribeUrl', 'TutorialController@getSubscribeUrl');
Route::get('tutorial/getAppleID', 'TutorialController@getAppleID'); Route::get ('tutorial/getAppleID', 'TutorialController@getAppleID');
}); });
// Passport // Passport
@ -79,7 +79,7 @@ Route::prefix('v1')
// Register // Register
Route::post('register', 'Passport\\RegisterController@index'); Route::post('register', 'Passport\\RegisterController@index');
// Comm // Comm
Route::get('config', 'Passport\\CommController@config'); Route::get ('config', 'Passport\\CommController@config');
Route::post('sendEmailVerify', 'Passport\\CommController@sendEmailVerify'); Route::post('sendEmailVerify', 'Passport\\CommController@sendEmailVerify');
// Login // Login
Route::post('login', 'Passport\\LoginController@index'); Route::post('login', 'Passport\\LoginController@index');
@ -90,25 +90,27 @@ Route::prefix('v1')
Route::prefix('guest') Route::prefix('guest')
->group(function () { ->group(function () {
// Plan // Plan
Route::get('plan', 'Guest\\PlanController@index'); Route::get ('plan', 'Guest\\PlanController@index');
// Order // Order
Route::post('order/alipayNotify', 'Guest\\OrderController@alipayNotify'); Route::post('order/alipayNotify', 'Guest\\OrderController@alipayNotify');
Route::post('order/stripeNotify', 'Guest\\OrderController@stripeNotify'); Route::post('order/stripeNotify', 'Guest\\OrderController@stripeNotify');
Route::get('order/stripeReturn', 'Guest\\OrderController@stripeReturn'); Route::get ('order/stripeReturn', 'Guest\\OrderController@stripeReturn');
}); });
// Client // Client
Route::prefix('client') Route::prefix('client')
->middleware('client') ->middleware('client')
->group(function () { ->group(function () {
// Client // Client
Route::get('subscribe', 'ClientController@subscribe'); Route::get ('subscribe', 'ClientController@subscribe');
// App
Route::get ('app/data', 'AppController@data');
}); });
// Server // Server
Route::prefix('server') Route::prefix('server')
->group(function () { ->group(function () {
// Deepbwork // Deepbwork
Route::get('deepbwork/user', 'Server\\DeepbworkController@user'); Route::get ('deepbwork/user', 'Server\\DeepbworkController@user');
Route::get('deepbwork/config', 'Server\\DeepbworkController@config'); Route::get ('deepbwork/config', 'Server\\DeepbworkController@config');
Route::post('deepbwork/submit', 'Server\\DeepbworkController@submit'); Route::post('deepbwork/submit', 'Server\\DeepbworkController@submit');
}); });
}); });