feat : config
This commit is contained in:
38
app/Service/Api/Login/LogOutService.php
Normal file
38
app/Service/Api/Login/LogOutService.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Api\Login;
|
||||
|
||||
use App\Cache\Redis\Api\UserCache;
|
||||
use App\Service\Api\BaseService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class LogOutService extends BaseService
|
||||
{
|
||||
/**
|
||||
* @var UserCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserCache $userCache;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): array
|
||||
{
|
||||
$this->userCache->removeUserToken($this->userId);
|
||||
|
||||
return $this->return->success();
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
namespace App\Service\Api\Login;
|
||||
|
||||
use App\Cache\Redis\Api\ApiRedisKey;
|
||||
use App\Cache\Redis\Api\UserCache;
|
||||
use App\Cache\Redis\Common\ConfigCache;
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Constants\Common\CouponCode;
|
||||
@@ -73,6 +74,12 @@ abstract class LoginBaseService extends BaseService
|
||||
#[Inject]
|
||||
protected UserInvite $userInviteModel;
|
||||
|
||||
/**
|
||||
* @var UserCache
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserCache $userCache;
|
||||
|
||||
|
||||
/**
|
||||
* 锁定注册
|
||||
@@ -134,7 +141,8 @@ abstract class LoginBaseService extends BaseService
|
||||
/**
|
||||
* 返回值
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function getReturn():array
|
||||
{
|
||||
@@ -147,6 +155,7 @@ abstract class LoginBaseService extends BaseService
|
||||
];
|
||||
|
||||
$loginReturn['token'] = $this->cryptoFactory->cryptoClass('jwt', json_encode($loginReturn))->encrypt();
|
||||
$this->userCache->setUserToken($this->userId, $loginReturn['token']);
|
||||
|
||||
|
||||
return $loginReturn;
|
||||
|
||||
Reference in New Issue
Block a user