public function voteAction() { $re = array("returncode" => ReturnCode::$SUCCESS); $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $da = $this->get('we_data_access'); $conv_root_id = $request->get("conv_id"); $is_multi = $request->get("is_multi"); $optionids = $request->get("optionids"); try { if (empty($conv_root_id) || $optionids == "") { throw new \Exception("param is null"); } $conv = new \Justsy\BaseBundle\Business\Conv(); if ($is_multi == "1") { $optionids = array_map(function ($item) { return trim($item); }, $optionids == "" ? array() : explode(',', $optionids)); } //查询是否已投票 if ($conv->checkIsVoted($da, $conv_root_id, $user->getUserName()) || $is_multi == "1" && (!is_array($optionids) || count($optionids) == 0)) { } else { $conv->vote($da, $user, $conv_root_id, $is_multi, $optionids); } $re["conv"] = $this->getVote($da, $user, $conv_root_id, ""); } catch (\Exception $e) { $re["returncode"] = ReturnCode::$SYSERROR; $this->get('logger')->err($e); } $response = new Response($request->get('jsoncallback') ? $request->get('jsoncallback') . "(" . json_encode($re) . ");" : json_encode($re)); $response->headers->set('Content-Type', 'text/json'); return $response; }
public function voteAction() { $request = $this->getRequest(); $user = $this->get('security.context')->getToken()->getUser(); $vote_id = $request->get('vote_id'); $is_multi = $request->get('is_multi'); $optionids = $request->get('optionids'); $da = $this->get('we_data_access'); $conv = new \Justsy\BaseBundle\Business\Conv(); //查询是否已投票 if ($conv->checkIsVoted($da, $vote_id, $user->getUserName()) || $is_multi == "1" && (!is_array($optionids) || count($optionids) == 0)) { } else { $conv->vote($da, $user, $vote_id, $is_multi, $optionids); } //返回 return $this->getOneConv($vote_id); }