正在显示
1 个修改的文件
包含
9 行增加
和
9 行删除
| @@ -30,24 +30,24 @@ class BlogLogic extends BaseLogic | @@ -30,24 +30,24 @@ class BlogLogic extends BaseLogic | ||
| 30 | */ | 30 | */ |
| 31 | public function blogSave(){ | 31 | public function blogSave(){ |
| 32 | //拼接参数 | 32 | //拼接参数 |
| 33 | -// DB::beginTransaction(); | ||
| 34 | -// try { | 33 | + DB::beginTransaction(); |
| 34 | + try { | ||
| 35 | $this->param = $this->paramProcessing($this->param); | 35 | $this->param = $this->paramProcessing($this->param); |
| 36 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 36 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 37 | $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); | 37 | $this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); |
| 38 | $route = $this->param['url']; | 38 | $route = $this->param['url']; |
| 39 | $this->edit($this->param,['id'=>$this->param['id']]); | 39 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 40 | }else{ | 40 | }else{ |
| 41 | -// $this->param['sort'] = $this->setNewsSort(); | 41 | + $this->param['sort'] = $this->setNewsSort(); |
| 42 | $id = $this->model->addReturnId($this->param); | 42 | $id = $this->model->addReturnId($this->param); |
| 43 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); | 43 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); |
| 44 | $this->edit(['url'=>$route],['id'=>$id]); | 44 | $this->edit(['url'=>$route],['id'=>$id]); |
| 45 | } | 45 | } |
| 46 | -// DB::commit(); | ||
| 47 | -// }catch (\Exception $e){ | ||
| 48 | -// DB::rollBack(); | ||
| 49 | -// $this->fail('error'); | ||
| 50 | -// } | 46 | + DB::commit(); |
| 47 | + }catch (\Exception $e){ | ||
| 48 | + DB::rollBack(); | ||
| 49 | + $this->fail('error'); | ||
| 50 | + } | ||
| 51 | $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route); | 51 | $this->addUpdateNotify(RouteMap::SOURCE_BLOG,$route); |
| 52 | $this->curlDelRoute(['new_route'=>$route]); | 52 | $this->curlDelRoute(['new_route'=>$route]); |
| 53 | return $this->success(); | 53 | return $this->success(); |
| @@ -62,7 +62,7 @@ class BlogLogic extends BaseLogic | @@ -62,7 +62,7 @@ class BlogLogic extends BaseLogic | ||
| 62 | */ | 62 | */ |
| 63 | public function setNewsSort(){ | 63 | public function setNewsSort(){ |
| 64 | $info = $this->model->select(['id','sort'])->orderBy('sort','desc')->first(); | 64 | $info = $this->model->select(['id','sort'])->orderBy('sort','desc')->first(); |
| 65 | - if($info === false){ | 65 | + if(empty($info)){ |
| 66 | return 1; | 66 | return 1; |
| 67 | } | 67 | } |
| 68 | return $info['sort']++; | 68 | return $info['sort']++; |
-
请 注册 或 登录 后发表评论