正在显示
3 个修改的文件
包含
13 行增加
和
16 行删除
| @@ -135,11 +135,12 @@ class BaseLogic extends Logic | @@ -135,11 +135,12 @@ class BaseLogic extends Logic | ||
| 135 | foreach ($data as $v){ | 135 | foreach ($data as $v){ |
| 136 | $this->set_num($model,$v,$type,$num); | 136 | $this->set_num($model,$v,$type,$num); |
| 137 | } | 137 | } |
| 138 | - } | ||
| 139 | - if($type == 'del'){ | ||
| 140 | - $model::where('id',$data)->decrement('num',$num); | ||
| 141 | }else{ | 138 | }else{ |
| 142 | - $model::where('id',$data)->increment('num',$num); | 139 | + if($type == 'del'){ |
| 140 | + $model::where('id',$data)->decrement('num',$num); | ||
| 141 | + }else{ | ||
| 142 | + $model::where('id',$data)->increment('num',$num); | ||
| 143 | + } | ||
| 143 | } | 144 | } |
| 144 | return true; | 145 | return true; |
| 145 | } | 146 | } |
| @@ -196,12 +196,10 @@ class BlogLogic extends BaseLogic | @@ -196,12 +196,10 @@ class BlogLogic extends BaseLogic | ||
| 196 | $str = $this->get_category_id($ids); | 196 | $str = $this->get_category_id($ids); |
| 197 | DB::beginTransaction(); | 197 | DB::beginTransaction(); |
| 198 | try { | 198 | try { |
| 199 | - if(!empty($str)){ | ||
| 200 | - $category_data = explode(',',$str); | ||
| 201 | - $this->set_num(BlogCategoryModel::class,$category_data,'del'); | ||
| 202 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 203 | - $this->del($this->param,$ids); | ||
| 204 | - } | 199 | + $category_data = explode(',',$str); |
| 200 | + $this->set_num(BlogCategoryModel::class,$category_data,'del'); | ||
| 201 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 202 | + $this->del($this->param,$ids); | ||
| 205 | DB::commit(); | 203 | DB::commit(); |
| 206 | }catch (Exception $e){ | 204 | }catch (Exception $e){ |
| 207 | DB::rollBack(); | 205 | DB::rollBack(); |
| @@ -186,12 +186,10 @@ class NewsLogic extends BaseLogic | @@ -186,12 +186,10 @@ class NewsLogic extends BaseLogic | ||
| 186 | $str = $this->get_category_id($ids); | 186 | $str = $this->get_category_id($ids); |
| 187 | DB::beginTransaction(); | 187 | DB::beginTransaction(); |
| 188 | try { | 188 | try { |
| 189 | - if(!empty($str)){ | ||
| 190 | - $category_data = explode(',',$str); | ||
| 191 | - $this->set_num(NewsCategoryModel::class,$category_data,'del'); | ||
| 192 | - $this->param['id'] = ['in',$this->param['id']]; | ||
| 193 | - $this->del($this->param,$ids); | ||
| 194 | - } | 189 | + $category_data = explode(',',$str); |
| 190 | + $this->set_num(NewsCategoryModel::class,$category_data,'del'); | ||
| 191 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 192 | + $this->del($this->param,$ids); | ||
| 195 | DB::commit(); | 193 | DB::commit(); |
| 196 | }catch (Exception $e){ | 194 | }catch (Exception $e){ |
| 197 | DB::rollBack(); | 195 | DB::rollBack(); |
-
请 注册 或 登录 后发表评论