|
...
|
...
|
@@ -333,32 +333,25 @@ class BlogCategoryLogic extends BaseLogic |
|
|
|
$return = [];
|
|
|
|
|
|
|
|
$cate_arr = explode('/',$category);
|
|
|
|
$p_cate = $cate_arr[0];
|
|
|
|
$c_cate = $cate_arr[1]??'';
|
|
|
|
|
|
|
|
$p_category = $this->model->read(['name'=>$p_cate,'pid'=>0]);
|
|
|
|
if(!$p_category){
|
|
|
|
$p_id = $this->model->addReturnId(['name'=>$p_cate,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
|
|
|
|
$pid = 0;
|
|
|
|
foreach ($cate_arr as $v){
|
|
|
|
if($v){
|
|
|
|
$category_info = $this->model->read(['name'=>$v,'pid'=>$pid]);
|
|
|
|
if(!$category_info){
|
|
|
|
$id = $this->model->addReturnId(['name'=>$v,'pid'=>$pid,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
|
|
|
|
|
|
|
|
$route = RouteMap::setRoute($p_cate, RouteMap::SOURCE_BLOG_CATE, $p_id, $project_id);
|
|
|
|
$this->model->edit(['alias'=>$route],['id'=>$p_id]);
|
|
|
|
$route = RouteMap::setRoute($v, RouteMap::SOURCE_BLOG_CATE, $id, $project_id);
|
|
|
|
$this->model->edit(['alias'=>$route],['id'=>$id]);
|
|
|
|
}else{
|
|
|
|
$p_id = $p_category['id'];
|
|
|
|
$id = $category_info['id'];
|
|
|
|
}
|
|
|
|
$return[] = $p_id;
|
|
|
|
|
|
|
|
if($c_cate){
|
|
|
|
$c_category = $this->model->read(['name'=>$c_cate,'pid'=>$p_id]);
|
|
|
|
if(!$c_category){
|
|
|
|
$c_id = $this->model->addReturnId(['name'=>$c_cate,'pid'=>$p_id,'project_id'=>$project_id,'operator_id'=>$user_id,'create_id'=>$user_id]);
|
|
|
|
|
|
|
|
$route = RouteMap::setRoute($c_cate, RouteMap::SOURCE_BLOG_CATE, $c_id, $project_id);
|
|
|
|
$this->model->edit(['alias'=>$route],['id'=>$c_id]);
|
|
|
|
}else{
|
|
|
|
$c_id = $c_category['id'];
|
|
|
|
$return[] = $id;
|
|
|
|
$pid = $id;
|
|
|
|
}
|
|
|
|
$return[] = $c_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->getLastCategory($return);
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|