Exemple #1
0
 public function updateAction()
 {
     $req = $this->request;
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $title = $req->getPost('title', null, null);
         if (empty($title)) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
         }
         // 查询是否存在了
         if ($this->getTagIsExist($title)) {
             return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_ERROR, '此标签名称已经存在!');
         }
         $info = BeautyParlorTagInfo::findFirst('tag_id=' . $id);
         if ($info) {
             $info->update(['tag_title' => $title]);
         }
         return (new ResponseResult())->sendResult('ok');
     } else {
         return (new ResponseResult())->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '请求异常');
     }
 }
 /**
  * 修改标签信息
  * @date: 2016年1月19日 
  * @author: futao
  */
 public function updateAction()
 {
     $req = $this->request;
     $echo = function ($msg, $state = false) {
         echo '<script type="text/javascript">';
         echo 'parent.formResult("' . $msg . '", ' . ($state ? 1 : 0) . ')';
         echo '</script>';
     };
     if ($req->isPost()) {
         $id = intval($req->getPost('id', null, 0));
         $title = $req->getPost('tag_name', null, null);
         $parent_id = intval($req->getPost('parent_id', null, 0));
         if ($id < 0 || $parent_id < 0) {
             $echo("请求异常");
         }
         if (empty($title)) {
             $echo("请求异常");
         }
         // 查询是否存在了
         if ($this->getTagIsExist($title)) {
             $echo("此标签名称已经存在!");
         }
         $info = BeautyParlorTagInfo::findFirst('tag_id=' . $id);
         if ($info) {
             $info->update(['tag_title' => $title, 'parent_id' => $parent_id]);
         }
         $echo("ok", true);
     } else {
         if ($req->getQuery('id')) {
             $id = intval($req->getQuery('id', null, 0));
             if ($id < 1) {
                 echo "error!";
                 return;
             }
             $info = BeautyParlorTagInfo::findFirst("tag_id = {$id} and tag_state = 1");
             if (!$info) {
                 $echo("标签不存在或被删除!");
                 return;
             }
             $list = BeautyParlorTagInfo::find("tag_state = 1 and parent_id = 0");
             $this->view->setVar('list', $list);
             $this->view->setVar('info', $info);
             $this->view->pick('bptag/edit');
         } else {
             $echo("请求异常");
         }
     }
 }