mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 10:12:11 +08:00
79 lines
1.4 KiB
PHP
79 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Admin;
|
|
|
|
use App\Lib\Jwt\RequestScopedTokenTrait;
|
|
use App\Lib\Return\AdminReturn;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
use Lcobucci\JWT\Token\RegisteredClaims;
|
|
|
|
abstract class BaseAdminService
|
|
{
|
|
use RequestScopedTokenTrait;
|
|
|
|
/**
|
|
* 请求对象注入
|
|
* @var RequestInterface
|
|
*/
|
|
#[Inject]
|
|
protected RequestInterface $request;
|
|
|
|
/**
|
|
* 返回对象注入
|
|
* @var AdminReturn
|
|
*/
|
|
#[Inject]
|
|
protected AdminReturn $adminReturn;
|
|
|
|
/**
|
|
* 管理员 id
|
|
* @var int
|
|
*/
|
|
protected int $adminId = 0;
|
|
|
|
/**
|
|
* 主构造函数
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->adminId = (int) $this->getToken()?->claims()?->get(RegisteredClaims::ID) ?? 0;
|
|
}
|
|
|
|
/**
|
|
* 主函数抽象类
|
|
*/
|
|
abstract public function handle();
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
protected function getCurrentPage(): int
|
|
{
|
|
return (int) $this->request->input('page', 1);
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
protected function getPageSize(): int
|
|
{
|
|
return (int) $this->request->input('page_size', 20);
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function getRequestData(): array
|
|
{
|
|
return $this->request->all();
|
|
}
|
|
} |