/** * logout */ public function actionAuthorizeView($appkey, $clientid) { $sessionid = session_id(); $map = $this->getRestMap(); /** * @var AccessToken $token */ try { Assert::hasText($appkey, "appkey传递参数为空!"); Assert::hasText($clientid, "clientid传递参数为空!"); $token = BCacheHelper::getToken($clientid, 'model'); Assert::hasText($token, "token 查询结果为空!"); //data $map["appkey"] = $token->appkey; $map["clientid"] = $token->clientid; $map["tokenid"] = $token->tokenid; $map[AjaxStatus::PROPERTY_MESSAGES] = "操作成功"; $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_SUCCESSFUL; $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_OK; } catch (IllegalArgumentException $e) { $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED; $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503; $map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage(); } catch (Exception $e) { $map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED; $map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503; $map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage(); } echo SnapshotHelper::encodeArray($map); }
public static function testModel($returnType = 'array', $refresh = false, $autoset = true) { $cachekey = 'test-array-model'; if ($refresh) { BCacheHelper::delete($cachekey); } $data = self::get($cachekey, function () { $users = User::model()->findAll(array('condition' => 'isdelete=0', 'limit' => 10)); $users = BArrayHelper::getModelIndexArray($users, 'userid', BCacheHelper::getPreChar()); return $users; }, $autoset); return $data; }
/** * 获取用户数组 * @author wjh * @date 2014-5-27 * @param array $ids userid array * @return string */ public static function getUsers($ids) { BDataHelper::addHeaderUTF8(); if (!is_array($ids)) { $ids = array($ids); } $data = BCacheHelper::getUser($ids); //User::model()->findAllByPk($ids); return BArrayHelper::array_column($data, 'name', 'userid'); }
public static function getTokens($returnType = 'array', $refresh = false, $autoset = true, $condition = null) { if ($refresh) { BCacheHelper::delete(self::CACHETYPE_TOKENS); } $data = self::get(self::CACHETYPE_TOKENS, self::_getTokens(), $autoset); if (!empty($condition) && is_callable($condition)) { $data = array_filter($data, function ($v) use($condition) { return $condition($v); }); } if ($returnType == 'model') { array_walk($data, function (&$v) { $v = BCacheHelper::getModel('AccessToken', $v); }); } return $data; }