fix : first finish

This commit is contained in:
2025-09-17 16:17:55 +08:00
parent 21331655f9
commit 082c15d697
15 changed files with 82 additions and 48 deletions

View File

@@ -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);
// }
/**
* 主函数抽象类
*/