mirror of
https://gitee.com/ctexthuang/hyperf-micro-svc.git
synced 2026-02-08 10:20:16 +08:00
65 lines
1.4 KiB
PHP
65 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\AdminUser;
|
|
|
|
use App\Cache\Redis\Lua\RateLimit;
|
|
use App\Cache\Redis\RedisCache;
|
|
use App\Lib\Jwt\RequestScopedTokenTrait;
|
|
use App\Repository\AdminUserRepository;
|
|
use App\Service\Admin\BaseAdminService;
|
|
use App\Service\BaseTokenService;
|
|
use App\Trait\AdminUserTrait;
|
|
use Hyperf\Collection\Arr;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Lcobucci\JWT\Token\RegisteredClaims;
|
|
|
|
class UserService extends BaseAdminService
|
|
{
|
|
use AdminUserTrait;
|
|
|
|
/**
|
|
* @var BaseTokenService
|
|
*/
|
|
#[Inject]
|
|
protected BaseTokenService $tokenService;
|
|
|
|
#[Inject]
|
|
protected RedisCache $redisCache;
|
|
|
|
public function handle(): array
|
|
{
|
|
$this->redisCache->with()->set('123',1);
|
|
$this->redisCache->with()->lua(RateLimit::class)->check('user:123', 10, 60);
|
|
|
|
return $this->adminReturn->success(
|
|
'success',
|
|
Arr::only(
|
|
$this->getAdminUserInfo($this->adminId) ?: [],
|
|
['username', 'nickname', 'avatar', 'signed', 'backend_setting', 'phone', 'email']
|
|
)
|
|
);
|
|
}
|
|
|
|
private function user()
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function logout(): array
|
|
{
|
|
$this->tokenService->setJwt('admin')->getJwt()->addBlackList($this->getToken());
|
|
|
|
return $this->adminReturn->success();
|
|
}
|
|
} |