mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 15:57:50 +08:00
fix : first finish
This commit is contained in:
@@ -10,12 +10,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin;
|
||||
|
||||
use App\Exception\ErrException;
|
||||
use App\Lib\Jwt\RequestScopedTokenTrait;
|
||||
use App\Lib\Return\AdminReturn;
|
||||
use Hyperf\Context\Context;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
|
||||
abstract class BaseAdminService
|
||||
{
|
||||
@@ -36,20 +36,27 @@ abstract class BaseAdminService
|
||||
protected AdminReturn $adminReturn;
|
||||
|
||||
/**
|
||||
* 管理员 id
|
||||
* @var int
|
||||
* @param string $name
|
||||
* @return \current_admin_id|mixed
|
||||
*/
|
||||
protected int $adminId = 0;
|
||||
|
||||
/**
|
||||
* 主构造函数
|
||||
*/
|
||||
public function __construct()
|
||||
public function __get(string $name)
|
||||
{
|
||||
$this->adminId = (int) $this->getToken()?->claims()?->get(RegisteredClaims::ID) ?? 0;
|
||||
if ($this->adminId > 0) Context::set('current_admin_id', $this->adminId);
|
||||
if ($name === 'adminId') return Context::get('current_admin_id',0);
|
||||
|
||||
if (!property_exists($this, $name)) throw new ErrException('属性未定义');
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 主构造函数
|
||||
// */
|
||||
// public function __construct()
|
||||
// {
|
||||
// $this->adminId = Context::get('current_admin_id',0);
|
||||
// var_dump('BaseAdminService获取到的'.$this->adminId);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 主函数抽象类
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user