作者 lyh

gx

@@ -120,14 +120,24 @@ class BlogCategoryLogic extends BaseLogic @@ -120,14 +120,24 @@ class BlogCategoryLogic extends BaseLogic
120 $id = $this->model->addReturnId($this->param); 120 $id = $this->model->addReturnId($this->param);
121 //非顶级菜单处理子集 121 //非顶级菜单处理子集
122 if($this->param['pid'] != 0){ 122 if($this->param['pid'] != 0){
123 - //把所有上级博客移动到下级 123 + //查看当前上级分类下是否有其他下级
  124 + $otherInfo = $this->model->read(['pid'=>$this->param['pid'],'id'=>['!=',$id]]);
  125 + if($otherInfo === false){
  126 + //无其他下级时,查看当前上级分类下是否有博客
124 $associationCateModel = new AssociationCate(); 127 $associationCateModel = new AssociationCate();
125 - $associationCateModel->list(['type'=>$associationCateModel::BLOG_CATE,]);  
126 - $data = [ 128 + $id_arr = $associationCateModel->where(['type'=>$associationCateModel::BLOG_CATE,'category_id'=>$this->param['id']])->pluck('type_id')->toArray();
  129 + if(!empty($id_arr)){
  130 + $data = [];
  131 + foreach ($id_arr as $v){
  132 + $data[] = [
127 'type'=>$associationCateModel::BLOG_CATE, 133 'type'=>$associationCateModel::BLOG_CATE,
128 - 'type_id'=> 134 + 'type_id'=>$v,
  135 + 'category_id'=>$id,
129 ]; 136 ];
130 - $associationCateModel->a(['category_id'=>$id],['category_id'=>$this->param['pid'],$associationCateModel::BLOG_CATE]); 137 + }
  138 + $associationCateModel->insert($data);
  139 + }
  140 + }
131 } 141 }
132 }catch (\Exception $e){ 142 }catch (\Exception $e){
133 $this->fail('系统错误请联系管理员'); 143 $this->fail('系统错误请联系管理员');