|
...
|
...
|
@@ -135,6 +135,7 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
public function categoryEdit(){
|
|
|
|
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
|
|
|
|
$this->param['id'], $this->user['project_id']);
|
|
|
|
$this->editHandleCategory($this->param['id'],$this->param['pid']);
|
|
|
|
$this->editNewsRoute($this->param['id'],$route);
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
if($rs === false){
|
|
...
|
...
|
@@ -153,12 +154,12 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
public function editHandleCategory($id,$pid){
|
|
|
|
$info = $this->model->read(['id'=>$id],['id','pid']);
|
|
|
|
if($info['pid'] != $pid){
|
|
|
|
//修改勒上级,先查看上级是否拥有博客
|
|
|
|
//修改勒上级,先查看上级是否拥有产品
|
|
|
|
$contentModel = new CustomModuleContent();
|
|
|
|
$newsCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
|
|
|
|
//随机获取最后一级id
|
|
|
|
$replacement = $this->getLastId($id);
|
|
|
|
if($newsCount > 0){
|
|
|
|
$contentCount = $contentModel->formatQuery(['category_id'=>['like','%,'.$pid.',%']])->count();
|
|
|
|
if($contentCount > 0){
|
|
|
|
//随机获取最后一级id
|
|
|
|
$replacement = $this->getLastId($id);
|
|
|
|
//存在博客时,移动所有博客到当前分类最后一级
|
|
|
|
$contentModel->where('category_id', 'like', '%,' . $pid . ',%')->where('category_id', 'like', '%,' . $replacement . ',%')
|
|
|
|
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
|
|
...
|
...
|
@@ -170,6 +171,22 @@ class CustomModuleCategoryLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :随机获取当前id下最后一级的id
|
|
|
|
* @name :getLastId
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/20 9:45
|
|
|
|
*/
|
|
|
|
public function getLastId($id){
|
|
|
|
$info = $this->model->read(['pid'=>$id],['id']);
|
|
|
|
if($info !== false){
|
|
|
|
return $this->getLastId($info['id']);
|
|
|
|
}else{
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :查看是否编辑路由
|
|
|
|
* @name :editCategoryRoute
|
|
|
|
* @author :lyh
|
...
|
...
|
|