Skip to content

Commit

Permalink
Merge pull request #1713 from sspanel-uim/dev
Browse files Browse the repository at this point in the history
Dev 20221212
  • Loading branch information
M1Screw committed Dec 11, 2022
2 parents ca733a3 + 2e59e25 commit 2f1d769
Show file tree
Hide file tree
Showing 13 changed files with 476 additions and 159 deletions.
19 changes: 17 additions & 2 deletions app/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,25 @@
$this->get('', App\Controllers\UserController::class . ':index');
$this->get('/', App\Controllers\UserController::class . ':index');

// 签到
$this->post('/checkin', App\Controllers\UserController::class . ':doCheckin');

// 公告
$this->get('/announcement', App\Controllers\UserController::class . ':announcement');

// 文档
$this->get('/docs', App\Controllers\UserController::class . ':docs');

//流媒体解锁
$this->get('/media', App\Controllers\UserController::class . ':media');

$this->get('/profile', App\Controllers\UserController::class . ':profile');
$this->get('/invite', App\Controllers\UserController::class . ':invite');

// 封禁
$this->get('/banned', App\Controllers\UserController::class . ':banned');

// 节点
$this->get('/server', App\Controllers\User\ServerController::class . ':userServerPage');

// 审计
Expand All @@ -51,6 +59,7 @@
$this->post('/buy', App\Controllers\User\ShopController::class . ':buy');
$this->post('/buy_traffic_package', App\Controllers\User\ShopController::class . ':buyTrafficPackage');

// 工单
$this->get('/ticket', App\Controllers\User\TicketController::class . ':ticket');
$this->get('/ticket/create', App\Controllers\User\TicketController::class . ':ticketCreate');
$this->post('/ticket', App\Controllers\User\TicketController::class . ':ticketAdd');
Expand All @@ -70,7 +79,6 @@
$this->post('/mail', App\Controllers\UserController::class . ':updateMail');
$this->post('/passwd_reset', App\Controllers\UserController::class . ':resetPasswd');
$this->post('/method', App\Controllers\UserController::class . ':updateMethod');
$this->get('/trafficlog', App\Controllers\UserController::class . ':trafficLog');
$this->get('/kill', App\Controllers\UserController::class . ':kill');
$this->post('/kill', App\Controllers\UserController::class . ':handleKill');
$this->get('/logout', App\Controllers\UserController::class . ':logout');
Expand Down Expand Up @@ -239,6 +247,12 @@
$this->post('/setting', App\Controllers\Admin\SettingController::class . ':save');
$this->post('/setting/email', App\Controllers\Admin\SettingController::class . ':test');
$this->post('/setting/payment', App\Controllers\Admin\SettingController::class . ':payment');

// 礼品卡
$this->get('/giftcard', App\Controllers\Admin\GiftCardController::class . ':index');
$this->post('/giftcard', App\Controllers\Admin\GiftCardController::class . ':add');
$this->post('/giftcard/ajax', App\Controllers\Admin\GiftCardController::class . ':ajax');
$this->delete('/giftcard/{id}', App\Controllers\Admin\GiftCardController::class . ':delete');
})->add(new Admin());

if ($_ENV['enableAdminApi']) {
Expand Down Expand Up @@ -276,11 +290,12 @@
$this->post('/nodes/{id}/info', App\Controllers\WebAPI\NodeController::class . ':info');
})->add(new NodeToken());

// 传统订阅(SS/V2Ray/Trojan)
$app->group('/link', function (): void {
$this->get('/{token}', App\Controllers\LinkController::class . ':getContent');
});

//通用訂閲
// 通用订阅(Json/Clash)
$app->group('/sub', function (): void {
$this->get('/{token}/{subtype}', App\Controllers\SubController::class . ':getContent');
});
Expand Down
49 changes: 13 additions & 36 deletions db/migrations/20000101000000_init_database.php.new
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ final class InitDatabase extends AbstractMigration
->addColumn('node_bandwidth_limit', 'biginteger', [ 'default' => 0 ])
->addColumn('bandwidthlimit_resetday', 'integer', [ 'default' => 0 ])
->addColumn('node_heartbeat', 'biginteger', [ 'default' => 0 ])
->addColumn('online_user', 'integer', [ 'comment' => '节点在线用户', 'default' => 0 ])
->addColumn('node_ip', 'string', [ 'default' => null ])
->addColumn('node_group', 'integer', [ 'default' => 0 ])
->addColumn('mu_only', 'boolean', [ 'default' => false ])
Expand Down Expand Up @@ -262,15 +263,6 @@ final class InitDatabase extends AbstractMigration
->addForeignKey('user_id', 'user', 'id', [ 'delete' => 'CASCADE', 'update' => 'CASCADE' ])
->create();

$this->table('node_online_log', [ 'id' => false, 'primary_key' => [ 'id' ]])
->addColumn('id', 'integer', [ 'identity' => true ])
->addColumn('node_id', 'integer', [])
->addColumn('online_user', 'integer', [])
->addColumn('log_time', 'integer', [])
->addIndex([ 'node_id' ])
->addForeignKey('node_id', 'node', 'id', [ 'delete' => 'CASCADE', 'update' => 'CASCADE' ])
->create();

$this->table('user_password_reset', [ 'id' => false, 'primary_key' => [ 'id' ]])
->addColumn('id', 'integer', [ 'identity' => true ])
->addColumn('email', 'string', [])
Expand Down Expand Up @@ -329,36 +321,21 @@ final class InitDatabase extends AbstractMigration
->addIndex([ 'user_id' ])
->addForeignKey('user_id', 'user', 'id', [ 'delete' => 'CASCADE', 'update' => 'CASCADE' ])
->create();

$this->table('gift_card', [ 'id' => false, 'primary_key' => [ 'id' ]])
->addColumn('id', 'biginteger', [ 'identity' => true,'signed' => false ])
->addColumn('card', 'text', array('comment' => '卡号'))
->addColumn('balance', 'integer', array('comment' => '余额'))
->addColumn('created_at', 'integer', array('comment' => '创建时间'))
->addColumn('status', 'integer', array('comment' => '使用状态'))
->addColumn('used_at', 'integer', array('comment' => '使用时间'))
->addColumn('use_user', 'integer', array('comment' => '使用用户'))
->create();
->addColumn('status', 'text', [ 'comment' => '订单状态' ])
->addIndex([ 'status' ])
}

public function down(): void
{
$this->table('user')->drop()->update();
$this->table('node')->drop()->update();
$this->table('alive_ip')->drop()->update();
$this->table('announcement')->drop()->update();
$this->table('bought')->drop()->update();
$this->table('code')->drop()->update();
$this->table('config')->drop()->update();
$this->table('coupon')->drop()->update();
$this->table('detect_ban_log')->drop()->update();
$this->table('detect_list')->drop()->update();
$this->table('detect_log')->drop()->update();
$this->table('email_queue')->drop()->update();
$this->table('email_verify')->drop()->update();
$this->table('gconfig')->drop()->update();
$this->table('link')->drop()->update();
$this->table('login_ip')->drop()->update();
$this->table('payback')->drop()->update();
$this->table('paylist')->drop()->update();
$this->table('shop')->drop()->update();
$this->table('user_invite_code')->drop()->update();
$this->table('node_online_log')->drop()->update();
$this->table('user_password_reset')->drop()->update();
$this->table('telegram_session')->drop()->update();
$this->table('ticket')->drop()->update();
$this->table('user_hourly_usage')->drop()->update();
$this->table('user_subscribe_log')->drop()->update();
$this->table('user_token')->drop()->update();
}
}
35 changes: 35 additions & 0 deletions db/migrations/20221211223600_merge_node_online_log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class MergeNodeOnlineLog extends AbstractMigration
{
public function up(): void
{
if ($this->hasTable('node_online_log')) {
$this->table('node_online_log')->drop()->update();
}
if (! $this->table('node')->hasColumn('online_user')) {
$this->table('node')
->addColumn('online_user', 'integer', [ 'comment' => '节点在线用户', 'default' => 0 ])
->save();
}
}

public function down(): void
{
$this->table('node_online_log', [ 'id' => false, 'primary_key' => [ 'id' ]])
->addColumn('id', 'integer', [ 'identity' => true ])
->addColumn('node_id', 'integer', [])
->addColumn('online_user', 'integer', [])
->addColumn('log_time', 'integer', [])
->addIndex([ 'node_id' ])
->addForeignKey('node_id', 'node', 'id', [ 'delete' => 'CASCADE', 'update' => 'CASCADE' ])
->create();
$this->table('node')
->removeColumn('online_user')
->save();
}
}
30 changes: 30 additions & 0 deletions db/migrations/20221211230900_gift_card_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class GiftCardTable extends AbstractMigration
{
public function up(): void
{
if (! $this->hasTable('gift_card')) {
$this->table('gift_card', [ 'id' => false, 'primary_key' => [ 'id' ]])
->addColumn('id', 'biginteger', [ 'identity' => true,'signed' => false ])
->addColumn('card', 'text', ['comment' => '卡号'])
->addColumn('balance', 'integer', ['comment' => '余额'])
->addColumn('create_time', 'integer', ['comment' => '创建时间'])
->addColumn('status', 'integer', ['comment' => '使用状态'])
->addColumn('use_time', 'integer', ['comment' => '使用时间'])
->addColumn('use_user', 'integer', ['comment' => '使用用户'])
->addIndex([ 'id' ])
->addIndex([ 'status' ])
->create();
}
}

public function down(): void
{
$this->table('gift_card')->drop()->update();
}
}
Loading

0 comments on commit 2f1d769

Please sign in to comment.