|
...
|
...
|
@@ -4,8 +4,11 @@ namespace App\Http\Logic\Bside\Blog; |
|
|
|
|
|
|
|
use App\Helper\Translate;
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Blog\Blog;
|
|
|
|
use App\Models\Blog\Blog as BlogModel;
|
|
|
|
use App\Models\Blog\BlogCategory;
|
|
|
|
use App\Models\Blog\BlogCategory as BlogCategoryModel;
|
|
|
|
use App\Models\News\NewsCategory as NewsCategoryModel;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
...
|
...
|
@@ -90,32 +93,13 @@ class BlogCategoryLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function delBlogCategory(){
|
|
|
|
foreach ($this->param['id'] as $id){
|
|
|
|
$this->verifyIsDelete($id);
|
|
|
|
//删除路由
|
|
|
|
$this->delRoute($id);
|
|
|
|
$this->model->del(['id'=>$id]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :验证是否可删除
|
|
|
|
* @name :VerifyIsDelete
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/7 14:40
|
|
|
|
*/
|
|
|
|
public function verifyIsDelete($id){
|
|
|
|
//查询是否有子分类
|
|
|
|
$rs = $this->model->read(['pid'=>$id],['id']);
|
|
|
|
if($rs !== false){
|
|
|
|
$this->response('当前分类拥有子分类不允许删除');
|
|
|
|
}
|
|
|
|
//查看当前分内下是否有博客
|
|
|
|
$blogModel = new BlogModel();
|
|
|
|
$rs = $blogModel->read(['category_id'=>['like','%,'.$id.',%']],['id']);
|
|
|
|
if($rs !== false){
|
|
|
|
$this->response('当前分类拥有博客,不允许删除');
|
|
|
|
//同步删除产品字段category_id
|
|
|
|
$blogModel = new Blog();
|
|
|
|
$blogModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
|
|
|
|
$blogModel->edit(['category_id'=>null],['category_id'=>',']);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
...
|
...
|
|