Exemplo n.º 1
0
 /**
  * 删除\恢复问题
  * @date: 2016年1月19日 
  * @author: futao
  */
 public function setStateAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $state = intval($req->getPost('state', null, -10000));
         if ($state == -1) {
             $info = CosPointquestion::findFirst("q_id = {$id}");
             if ($info) {
                 return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '已推荐首页!');
             }
         }
         if (!in_array($state, [-1, 0, 1])) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         $info = Question::findFirst('question_id=' . $id);
         if ($info) {
             $info->update(['question_state' => $state]);
         }
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }