feat : config

This commit is contained in:
2025-03-20 15:27:53 +08:00
parent ef9f663fb2
commit d3d0cda616
9 changed files with 164 additions and 3 deletions

View 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();
}
}

View File

@@ -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;