正在显示
1 个修改的文件
包含
18 行增加
和
8 行删除
| @@ -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 | - //把所有上级博客移动到下级 | ||
| 124 | - $associationCateModel = new AssociationCate(); | ||
| 125 | - $associationCateModel->list(['type'=>$associationCateModel::BLOG_CATE,]); | ||
| 126 | - $data = [ | ||
| 127 | - 'type'=>$associationCateModel::BLOG_CATE, | ||
| 128 | - 'type_id'=> | ||
| 129 | - ]; | ||
| 130 | - $associationCateModel->a(['category_id'=>$id],['category_id'=>$this->param['pid'],$associationCateModel::BLOG_CATE]); | 123 | + //查看当前上级分类下是否有其他下级 |
| 124 | + $otherInfo = $this->model->read(['pid'=>$this->param['pid'],'id'=>['!=',$id]]); | ||
| 125 | + if($otherInfo === false){ | ||
| 126 | + //无其他下级时,查看当前上级分类下是否有博客 | ||
| 127 | + $associationCateModel = new AssociationCate(); | ||
| 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[] = [ | ||
| 133 | + 'type'=>$associationCateModel::BLOG_CATE, | ||
| 134 | + 'type_id'=>$v, | ||
| 135 | + 'category_id'=>$id, | ||
| 136 | + ]; | ||
| 137 | + } | ||
| 138 | + $associationCateModel->insert($data); | ||
| 139 | + } | ||
| 140 | + } | ||
| 131 | } | 141 | } |
| 132 | }catch (\Exception $e){ | 142 | }catch (\Exception $e){ |
| 133 | $this->fail('系统错误请联系管理员'); | 143 | $this->fail('系统错误请联系管理员'); |
-
请 注册 或 登录 后发表评论