Browse Source

新token

master
weigang 5 years ago
parent
commit
c315c9ee3f
  1. 12
      app/Service/v3/Implementations/ParamsTokenSsdbService.php

12
app/Service/v3/Implementations/ParamsTokenSsdbService.php

@ -31,13 +31,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$kvs = [];
foreach ($params as $key => $value) {
$kvs[] = $key;
$kvs[] = $value;
}
if(false === $ssdb->exec('multi_hset', SsdbKeys::PARAMS_TOKEN.$token, $kvs)) {
if(false === $ssdb->exec('hset', SsdbKeys::PARAMS_TOKEN, $token, json_encode($params))) {
throw new ErrorCodeException(ErrorCode::TOKEN_GENERATE_ERROR, 'token生成失败');
}
@ -51,7 +45,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface
public function analyze($token)
{
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$params = $ssdb->exec('hgetall', SsdbKeys::PARAMS_TOKEN.$token);
$params = $ssdb->exec('hget', SsdbKeys::PARAMS_TOKEN, $token);
if (false === $params) {
@ -62,7 +56,7 @@ class ParamsTokenSsdbService implements ParamsTokenServiceInterface
throw new ErrorCodeException(ErrorCode::TOKEN_NOT_EXISTS, 'token不存在');
}
return $params;
return json_decode($params, true);
}
}
Loading…
Cancel
Save