作者 lyh

gx

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