Commit bbffb18c by feixiang

user实体优化

redis 新增扩展
parent d0a2203d
......@@ -11,11 +11,8 @@
namespace Hdll\Services\Common\Entity;
use Hdll\Services\Auth\Enum\AuthError;
use Hdll\Services\Auth\Exception\AuthException;
use Swoft\App;
use Hdll\Services\Common\Lib\Redis;
use Swoft\Bean\Annotation\Bean;
use Swoft\Cache\Cache;
use Swoft\Redis\Redis;
/**
* 用户实体
......@@ -38,8 +35,6 @@ class User
private $token;
private $cmId;
private $sessionKey;
private $scope;
......@@ -132,16 +127,6 @@ class User
$this->token = $value;
}
public function setCmId($value)
{
$this->cmId = $value;
}
public function getCmId()
{
return $this->cmId;
}
public function fill($arr)
{
......@@ -190,8 +175,10 @@ class User
/**
* @var Redis $redis
*/
$redis = App::getBean(Redis::class);
$info = $redis->get('AUTH:'.$token);
$redis = new Redis();
$redis->setPrefix("AUTH:");
$info = $redis->get($token);
if ( empty($info) ) {
return [false,AuthError::NOT_FOUND_USER];
}
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/20
* Time: 16:34
*/
namespace Hdll\Services\Common\Lib;
use Swoft\App;
use Swoft\Redis\Operator\Processor\PrefixProcessor;
class Redis extends \Swoft\Redis\Redis
{
/**
* 设置redis前缀
* @param $prefix
*/
public function setPrefix($prefix)
{
$config = App::getBean(PrefixProcessor::class);
$config->setPrefix($prefix);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment