62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace app\admin\controller\auth;
|
||
|
||
use Throwable;
|
||
use app\common\controller\Backend;
|
||
use app\admin\model\AdminLog as AdminLogModel;
|
||
use support\Response;
|
||
use Webman\Http\Request;
|
||
|
||
class AdminLog extends Backend
|
||
{
|
||
protected ?object $model = null;
|
||
|
||
protected string|array $preExcludeFields = ['create_time', 'admin_id', 'username'];
|
||
|
||
protected string|array $quickSearchField = ['title'];
|
||
|
||
protected function initController(Request $request): void
|
||
{
|
||
$this->model = new AdminLogModel();
|
||
}
|
||
|
||
public function index(Request $request): Response
|
||
{
|
||
$response = $this->initializeBackend($request);
|
||
if ($response !== null) return $response;
|
||
|
||
if ($request->get('select') ?? $request->post('select')) {
|
||
$selectRes = $this->select($request);
|
||
if ($selectRes !== null) return $selectRes;
|
||
}
|
||
|
||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
||
if (!$this->auth->isSuperAdmin()) {
|
||
$where[] = ['admin_id', '=', $this->auth->id];
|
||
}
|
||
$res = $this->model
|
||
->withJoin($this->withJoinTable, $this->withJoinType)
|
||
->alias($alias)
|
||
->where($where)
|
||
->order($order)
|
||
->paginate($limit);
|
||
|
||
return $this->success('', [
|
||
'list' => $res->items(),
|
||
'total' => $res->total(),
|
||
'remark' => get_route_remark(),
|
||
]);
|
||
}
|
||
|
||
/**
|
||
* 远程下拉(AdminLog 无自定义,返回 null 走默认列表)
|
||
*/
|
||
protected function select(Request $request): ?Response
|
||
{
|
||
return null;
|
||
}
|
||
}
|