正在显示
4 个修改的文件
包含
24 行增加
和
52 行删除
| @@ -4,8 +4,11 @@ namespace App\Http\Logic\Bside\Blog; | @@ -4,8 +4,11 @@ namespace App\Http\Logic\Bside\Blog; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Translate; | 5 | use App\Helper\Translate; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | +use App\Models\Blog\Blog; | ||
| 7 | use App\Models\Blog\Blog as BlogModel; | 8 | use App\Models\Blog\Blog as BlogModel; |
| 9 | +use App\Models\Blog\BlogCategory; | ||
| 8 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 10 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 11 | +use App\Models\News\NewsCategory as NewsCategoryModel; | ||
| 9 | use App\Models\RouteMap\RouteMap; | 12 | use App\Models\RouteMap\RouteMap; |
| 10 | use Illuminate\Support\Facades\DB; | 13 | use Illuminate\Support\Facades\DB; |
| 11 | 14 | ||
| @@ -90,32 +93,13 @@ class BlogCategoryLogic extends BaseLogic | @@ -90,32 +93,13 @@ class BlogCategoryLogic extends BaseLogic | ||
| 90 | */ | 93 | */ |
| 91 | public function delBlogCategory(){ | 94 | public function delBlogCategory(){ |
| 92 | foreach ($this->param['id'] as $id){ | 95 | foreach ($this->param['id'] as $id){ |
| 93 | - $this->verifyIsDelete($id); | ||
| 94 | //删除路由 | 96 | //删除路由 |
| 95 | $this->delRoute($id); | 97 | $this->delRoute($id); |
| 96 | $this->model->del(['id'=>$id]); | 98 | $this->model->del(['id'=>$id]); |
| 97 | - } | ||
| 98 | - return $this->success(); | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - /** | ||
| 102 | - * @remark :验证是否可删除 | ||
| 103 | - * @name :VerifyIsDelete | ||
| 104 | - * @author :lyh | ||
| 105 | - * @method :post | ||
| 106 | - * @time :2023/9/7 14:40 | ||
| 107 | - */ | ||
| 108 | - public function verifyIsDelete($id){ | ||
| 109 | - //查询是否有子分类 | ||
| 110 | - $rs = $this->model->read(['pid'=>$id],['id']); | ||
| 111 | - if($rs !== false){ | ||
| 112 | - $this->response('当前分类拥有子分类不允许删除'); | ||
| 113 | - } | ||
| 114 | - //查看当前分内下是否有博客 | ||
| 115 | - $blogModel = new BlogModel(); | ||
| 116 | - $rs = $blogModel->read(['category_id'=>['like','%,'.$id.',%']],['id']); | ||
| 117 | - if($rs !== false){ | ||
| 118 | - $this->response('当前分类拥有博客,不允许删除'); | 99 | + //同步删除产品字段category_id |
| 100 | + $blogModel = new Blog(); | ||
| 101 | + $blogModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]); | ||
| 102 | + $blogModel->edit(['category_id'=>null],['category_id'=>',']); | ||
| 119 | } | 103 | } |
| 120 | return $this->success(); | 104 | return $this->success(); |
| 121 | } | 105 | } |
| @@ -189,18 +189,13 @@ class CustomModuleCategoryLogic extends BaseLogic | @@ -189,18 +189,13 @@ class CustomModuleCategoryLogic extends BaseLogic | ||
| 189 | public function categoryDel(){ | 189 | public function categoryDel(){ |
| 190 | $ids = $this->param['id']; | 190 | $ids = $this->param['id']; |
| 191 | foreach ($ids as $id){ | 191 | foreach ($ids as $id){ |
| 192 | - $info = $this->model->read(['pid'=>$id],['id']); | ||
| 193 | - if($info !== false){ | ||
| 194 | - $this->fail('分类id:'.$id.'拥有子集不允许删除'); | ||
| 195 | - } | ||
| 196 | - $contentModel = new CustomModuleContent(); | ||
| 197 | - $contentInfo = $contentModel->read(['category_id'=>['like','%,'.$id.',%']]); | ||
| 198 | - if($contentInfo !== false){ | ||
| 199 | - $this->fail('当前分类拥有产品不允许删除'); | ||
| 200 | - } | ||
| 201 | //删除路由 | 192 | //删除路由 |
| 202 | $this->delRoute($id); | 193 | $this->delRoute($id); |
| 203 | $this->model->del(['id'=>$id]); | 194 | $this->model->del(['id'=>$id]); |
| 195 | + //同步删除产品字段category_id | ||
| 196 | + $contentModel = new CustomModuleContent(); | ||
| 197 | + $contentModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]); | ||
| 198 | + $contentModel->edit(['category_id'=>null],['category_id'=>',']); | ||
| 204 | } | 199 | } |
| 205 | return $this->success(); | 200 | return $this->success(); |
| 206 | } | 201 | } |
| @@ -4,8 +4,10 @@ namespace App\Http\Logic\Bside\News; | @@ -4,8 +4,10 @@ namespace App\Http\Logic\Bside\News; | ||
| 4 | 4 | ||
| 5 | use App\Helper\Translate; | 5 | use App\Helper\Translate; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | +use App\Models\News\News; | ||
| 7 | use App\Models\News\News as NewsModel; | 8 | use App\Models\News\News as NewsModel; |
| 8 | use App\Models\News\NewsCategory as NewsCategoryModel; | 9 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 10 | +use App\Models\Product\Product; | ||
| 9 | use App\Models\RouteMap\RouteMap; | 11 | use App\Models\RouteMap\RouteMap; |
| 10 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| 11 | 13 | ||
| @@ -88,19 +90,12 @@ class NewsCategoryLogic extends BaseLogic | @@ -88,19 +90,12 @@ class NewsCategoryLogic extends BaseLogic | ||
| 88 | */ | 90 | */ |
| 89 | public function del_news_category(){ | 91 | public function del_news_category(){ |
| 90 | foreach ($this->param['id'] as $id){ | 92 | foreach ($this->param['id'] as $id){ |
| 91 | - //查询是否有子分类 | ||
| 92 | - $rs = $this->model->read(['pid'=>$id],['id']); | ||
| 93 | - if($rs !== false){ | ||
| 94 | - $this->fail('当前分类拥有子分类不允许删除'); | ||
| 95 | - } | ||
| 96 | - //查看当前分内下是否有商品 | ||
| 97 | - $newsModel = new NewsModel(); | ||
| 98 | - $rs = $newsModel->read(['category_id'=>$id],['id']); | ||
| 99 | - if($rs !== false){ | ||
| 100 | - $this->fail('当前分类拥有商品,不允许删除'); | ||
| 101 | - } | ||
| 102 | $this->delRoute($id); | 93 | $this->delRoute($id); |
| 103 | $this->model->del(['id'=>$id]); | 94 | $this->model->del(['id'=>$id]); |
| 95 | + //同步删除产品字段category_id | ||
| 96 | + $newsModel = new NewsModel(); | ||
| 97 | + $newsModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]); | ||
| 98 | + $newsModel->edit(['category_id'=>null],['category_id'=>',']); | ||
| 104 | } | 99 | } |
| 105 | return $this->success(); | 100 | return $this->success(); |
| 106 | } | 101 | } |
| @@ -168,18 +168,16 @@ class CategoryLogic extends BaseLogic | @@ -168,18 +168,16 @@ class CategoryLogic extends BaseLogic | ||
| 168 | public function categoryDelete(){ | 168 | public function categoryDelete(){ |
| 169 | $ids = $this->param['ids']; | 169 | $ids = $this->param['ids']; |
| 170 | foreach ($ids as $id){ | 170 | foreach ($ids as $id){ |
| 171 | - $info = $this->model->read(['pid'=>$id],['id']); | ||
| 172 | - if($info !== false){ | ||
| 173 | - $this->fail('分类id:'.$id.'拥有子集不允许删除'); | ||
| 174 | - } | ||
| 175 | - $productModel = new Product(); | ||
| 176 | - $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]); | ||
| 177 | - if($product_info !== false){ | ||
| 178 | - $this->fail('当前分类拥有产品不允许删除'); | ||
| 179 | - } | ||
| 180 | //删除路由 | 171 | //删除路由 |
| 181 | $this->delRoute($id); | 172 | $this->delRoute($id); |
| 182 | $this->model->del(['id'=>$id]); | 173 | $this->model->del(['id'=>$id]); |
| 174 | + //同步删除关联表 | ||
| 175 | + $categoryRelatedModel = new CategoryRelated(); | ||
| 176 | + $categoryRelatedModel->del(['cate_id'=>$id]); | ||
| 177 | + //同步删除产品字段category_id | ||
| 178 | + $productModel = new Product(); | ||
| 179 | + $productModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]); | ||
| 180 | + $productModel->edit(['category_id'=>null],['category_id'=>',']); | ||
| 183 | } | 181 | } |
| 184 | //清除缓存 | 182 | //清除缓存 |
| 185 | Common::del_user_cache('product_category',$this->user['project_id']); | 183 | Common::del_user_cache('product_category',$this->user['project_id']); |
-
请 注册 或 登录 后发表评论