feat(Phase 2): add Base controller + extend all admin controllers, add BaseService

refactor/vr-ticket-20260416
Council 2026-04-15 13:08:56 +08:00
parent 3949f91622
commit d0a2a1193c
5 changed files with 110 additions and 3 deletions

View File

@ -0,0 +1,37 @@
<?php
/**
* VR票务插件 - Admin 基础控制器
*
* 所有 admin 控制器继承此类,自动完成登录校验
*
* @package vr_ticket\admin\controller
*/
namespace app\plugins\vr_ticket\admin\controller;
use app\service\AdminService;
abstract class Base
{
/** @var array|null 管理员信息 */
protected $admin;
public function __construct()
{
$this->admin = AdminService::LoginInfo();
if (empty($this->admin)) {
if (IS_AJAX) {
exit(json_encode([
'code' => -400,
'msg' => '登录失效,请重新登录',
'data' => [
'login' => MyUrl('admin/admin/logininfo'),
'logout' => MyUrl('admin/admin/logout'),
]
]));
} else {
die('<script type="text/javascript">window.location.href="' . MyUrl('admin/admin/logininfo') . '";</script>');
}
}
}
}

View File

@ -7,8 +7,13 @@
namespace app\plugins\vr_ticket\admin\controller;
class Ticket
class Ticket extends Base
{
public function __construct()
{
parent::__construct();
}
/**
* 电子票列表
*/

View File

@ -7,8 +7,13 @@
namespace app\plugins\vr_ticket\admin\controller;
class Verification
class Verification extends Base
{
public function __construct()
{
parent::__construct();
}
/**
* 核销记录列表
*/

View File

@ -7,8 +7,13 @@
namespace app\plugins\vr_ticket\admin\controller;
class Verifier
class Verifier extends Base
{
public function __construct()
{
parent::__construct();
}
/**
* 核销员列表
*/

View File

@ -152,4 +152,59 @@ class BaseService
$log_func($tag . $message . $ctx);
}
}
/**
* 插件后台权限菜单
*
* ShopXO 通过 PluginsService::PluginsAdminPowerMenu() 调用此方法
* 返回格式:二维数组,每项代表一个菜单分组
*
* @return array
*/
public static function AdminPowerMenu()
{
return [
// 座位模板
[
'name' => '座位模板',
'control' => 'seat_template',
'action' => 'list',
'item' => [
['name' => '座位模板', 'action' => 'list'],
['name' => '添加模板', 'action' => 'save'],
],
],
// 电子票
[
'name' => '电子票',
'control' => 'ticket',
'action' => 'list',
'item' => [
['name' => '电子票列表', 'action' => 'list'],
['name' => '票详情', 'action' => 'detail'],
['name' => '手动核销', 'action' => 'verify'],
['name' => '导出票', 'action' => 'export'],
],
],
// 核销员
[
'name' => '核销员',
'control' => 'verifier',
'action' => 'list',
'item' => [
['name' => '核销员列表', 'action' => 'list'],
['name' => '添加核销员', 'action' => 'save'],
],
],
// 核销记录
[
'name' => '核销记录',
'control' => 'verification',
'action' => 'list',
'item' => [
['name' => '核销记录', 'action' => 'list'],
],
],
];
}
}