public function login()
 {
     $dataPost = $this->request->getJsonRawBody();
     $usuario = $dataPost->login;
     $senha = md5($dataPost->senha);
     $query = Funcionario::query()->where('login = :login:'******'senha = :senha:')->bind(['login' => $usuario, 'senha' => $senha])->execute();
     if ($query->count() == 1) {
         $result = $query[0];
         $token = base64_encode(uniqid("user_id={$result->getId()}", true));
         $m = $this->getDI()->get('memcached');
         $memCacheResult = $m->set($token, ['login' => $result->getLogin(), 'nome' => $result->getNome()], time() + Settings::LOGIN_EXPIRATION);
         if (!$memCacheResult) {
             throw new \Exception("Erro ao armazenar token: " . \Memcached::getResultCode(), StatusCodes::ERRO_SERVIDOR);
         }
         return ['success' => true, 'token' => $token, 'usuario' => ['login' => $result->getLogin(), 'nome' => $result->getNome()]];
     } else {
         throw new \Exception("Usuário e/ou senha incorretos", StatusCodes::NAO_AUTORIZADO);
     }
 }
 public function index()
 {
     $query = Funcionario::query();
     if ($this->request->getQuery('search_id')) {
         $query->andWhere('id = :id:')->bind(['id' => $this->request->getQuery('search_id')]);
     } else {
         $binds = [];
         if ($this->request->getQuery('search_nome')) {
             $query->andWhere('nome ILIKE :nome:');
             $binds['nome'] = "%{$this->request->getQuery('search_nome')}%";
         }
         if ($this->request->getQuery('search_status')) {
             $query->andWhere('status = :status:');
             $binds['status'] = $this->request->getQuery('search_status');
         }
         if (count($binds)) {
             $query->bind($binds);
         }
     }
     if ($this->request->getQuery(DefaultParams::ORDER)) {
         $query->order($this->request->getQuery(DefaultParams::ORDER));
     }
     return GetResponse::createResponse($this->request, $query->execute()->toArray());
 }