正在显示
6 个修改的文件
包含
100 行增加
和
31 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :DeleteProductCategory.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/5/16 14:59 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\DeleteCategory; | ||
| 11 | + | ||
| 12 | +use Illuminate\Console\Command; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :删除分类 | ||
| 16 | + * @name :DeleteProductCategory | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2024/5/16 15:00 | ||
| 20 | + */ | ||
| 21 | +class DeleteProductCategory extends Command | ||
| 22 | +{ | ||
| 23 | + /** | ||
| 24 | + * The name and signature of the console command. | ||
| 25 | + * | ||
| 26 | + * @var string | ||
| 27 | + */ | ||
| 28 | + protected $signature = 'delete_product_category'; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * The console command description. | ||
| 32 | + * | ||
| 33 | + * @var string | ||
| 34 | + */ | ||
| 35 | + protected $description = '删除产品关键字'; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Create a new command instance. | ||
| 39 | + * | ||
| 40 | + * @return void | ||
| 41 | + */ | ||
| 42 | + public function __construct() | ||
| 43 | + { | ||
| 44 | + parent::__construct(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * @remark :批量处理 | ||
| 49 | + * @name :handle | ||
| 50 | + * @author :lyh | ||
| 51 | + * @method :post | ||
| 52 | + * @time :2024/5/16 15:02 | ||
| 53 | + */ | ||
| 54 | + public function handle(){ | ||
| 55 | + | ||
| 56 | + } | ||
| 57 | +} |
| @@ -148,7 +148,6 @@ class BlogCategoryController extends BaseController | @@ -148,7 +148,6 @@ class BlogCategoryController extends BaseController | ||
| 148 | 'id.array' => 'ID为数组', | 148 | 'id.array' => 'ID为数组', |
| 149 | ]); | 149 | ]); |
| 150 | $blogCategoryLogic->delBlogCategory(); | 150 | $blogCategoryLogic->delBlogCategory(); |
| 151 | - //TODO::写入操作日志 | ||
| 152 | $this->response('success'); | 151 | $this->response('success'); |
| 153 | } | 152 | } |
| 154 | 153 |
| @@ -8,6 +8,7 @@ use App\Models\Blog\Blog; | @@ -8,6 +8,7 @@ use App\Models\Blog\Blog; | ||
| 8 | use App\Models\Blog\Blog as BlogModel; | 8 | use App\Models\Blog\Blog as BlogModel; |
| 9 | use App\Models\Blog\BlogCategory; | 9 | use App\Models\Blog\BlogCategory; |
| 10 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 10 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 11 | +use App\Models\Com\NoticeLog; | ||
| 11 | use App\Models\News\NewsCategory as NewsCategoryModel; | 12 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 12 | use App\Models\RouteMap\RouteMap; | 13 | use App\Models\RouteMap\RouteMap; |
| 13 | use App\Models\Template\BTemplate; | 14 | use App\Models\Template\BTemplate; |
| @@ -94,15 +95,18 @@ class BlogCategoryLogic extends BaseLogic | @@ -94,15 +95,18 @@ class BlogCategoryLogic extends BaseLogic | ||
| 94 | * @method | 95 | * @method |
| 95 | */ | 96 | */ |
| 96 | public function delBlogCategory(){ | 97 | public function delBlogCategory(){ |
| 97 | - foreach ($this->param['id'] as $id){ | ||
| 98 | - //删除路由 | ||
| 99 | - $this->delRoute($id); | ||
| 100 | - $this->model->del(['id'=>$id]); | ||
| 101 | - //同步删除产品字段category_id | ||
| 102 | - $blogModel = new Blog(); | ||
| 103 | - $blogModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]); | ||
| 104 | - $blogModel->edit(['category_id'=>null],['category_id'=>',']); | 98 | + $ids = $this->param['id']; |
| 99 | + foreach ($ids as $id){ | ||
| 100 | + $str = []; | ||
| 101 | + $this->getAllSub($id,$str); | ||
| 102 | + $str[] = $id; | ||
| 103 | + foreach ($str as $value){ | ||
| 104 | + //删除路由 | ||
| 105 | + $this->delRoute($value); | ||
| 106 | + $this->model->del(['id'=>$value]); | ||
| 107 | + } | ||
| 105 | } | 108 | } |
| 109 | + NoticeLog::createLog(NoticeLog::DELETE_BLOG_CATEGORY, ['project_id' => $this->user['project_id']]); | ||
| 106 | return $this->success(); | 110 | return $this->success(); |
| 107 | } | 111 | } |
| 108 | 112 |
| @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\News; | @@ -4,6 +4,7 @@ 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\Com\NoticeLog; | ||
| 7 | use App\Models\News\News; | 8 | use App\Models\News\News; |
| 8 | use App\Models\News\News as NewsModel; | 9 | use App\Models\News\News as NewsModel; |
| 9 | use App\Models\News\NewsCategory as NewsCategoryModel; | 10 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| @@ -83,22 +84,27 @@ class NewsCategoryLogic extends BaseLogic | @@ -83,22 +84,27 @@ class NewsCategoryLogic extends BaseLogic | ||
| 83 | $this->edit($this->param,['id'=>$this->param['id']]); | 84 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 84 | return $this->success(); | 85 | return $this->success(); |
| 85 | } | 86 | } |
| 87 | + | ||
| 86 | /** | 88 | /** |
| 87 | - * @name :删除新闻分类 | ||
| 88 | - * @return array | ||
| 89 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 90 | - * @author :liyuhang | ||
| 91 | - * @method | 89 | + * @remark :删除分类 |
| 90 | + * @name :del_news_category | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2024/5/16 14:58 | ||
| 92 | */ | 94 | */ |
| 93 | public function del_news_category(){ | 95 | public function del_news_category(){ |
| 94 | - foreach ($this->param['id'] as $id){ | ||
| 95 | - $this->delRoute($id); | ||
| 96 | - $this->model->del(['id'=>$id]); | ||
| 97 | - //同步删除产品字段category_id | ||
| 98 | - $newsModel = new NewsModel(); | ||
| 99 | - $newsModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]); | ||
| 100 | - $newsModel->edit(['category_id'=>null],['category_id'=>',']); | 96 | + $ids = $this->param['id']; |
| 97 | + foreach ($ids as $id){ | ||
| 98 | + $str = []; | ||
| 99 | + $this->getAllSub($id,$str); | ||
| 100 | + $str[] = $id; | ||
| 101 | + foreach ($str as $value){ | ||
| 102 | + //删除路由 | ||
| 103 | + $this->delRoute($value); | ||
| 104 | + $this->model->del(['id'=>$value]); | ||
| 105 | + } | ||
| 101 | } | 106 | } |
| 107 | + NoticeLog::createLog(NoticeLog::DELETE_NEWS_CATEGORY, ['project_id' => $this->user['project_id']]); | ||
| 102 | return $this->success(); | 108 | return $this->success(); |
| 103 | } | 109 | } |
| 104 | 110 |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Product; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Product; | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | use App\Helper\Common; | 6 | use App\Helper\Common; |
| 7 | use App\Http\Logic\Bside\BaseLogic; | 7 | use App\Http\Logic\Bside\BaseLogic; |
| 8 | +use App\Models\Com\NoticeLog; | ||
| 8 | use App\Models\Product\Category; | 9 | use App\Models\Product\Category; |
| 9 | use App\Models\Product\CategoryRelated; | 10 | use App\Models\Product\CategoryRelated; |
| 10 | use App\Models\Product\Product; | 11 | use App\Models\Product\Product; |
| @@ -163,17 +164,16 @@ class CategoryLogic extends BaseLogic | @@ -163,17 +164,16 @@ class CategoryLogic extends BaseLogic | ||
| 163 | public function categoryDelete(){ | 164 | public function categoryDelete(){ |
| 164 | $ids = $this->param['ids']; | 165 | $ids = $this->param['ids']; |
| 165 | foreach ($ids as $id){ | 166 | foreach ($ids as $id){ |
| 166 | - //删除路由 | ||
| 167 | - $this->delRoute($id); | ||
| 168 | - $this->model->del(['id'=>$id]); | ||
| 169 | - //同步删除关联表 | ||
| 170 | - $categoryRelatedModel = new CategoryRelated(); | ||
| 171 | - $categoryRelatedModel->del(['cate_id'=>$id]); | ||
| 172 | - //同步删除产品字段category_id | ||
| 173 | - $productModel = new Product(); | ||
| 174 | - $productModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]); | ||
| 175 | - $productModel->edit(['category_id'=>null],['category_id'=>',']); | 167 | + $str = []; |
| 168 | + $this->getAllSub($id,$str); | ||
| 169 | + $str[] = $id; | ||
| 170 | + foreach ($str as $value){ | ||
| 171 | + //删除路由 | ||
| 172 | + $this->delRoute($value); | ||
| 173 | + $this->model->del(['id'=>$value]); | ||
| 174 | + } | ||
| 176 | } | 175 | } |
| 176 | + NoticeLog::createLog(NoticeLog::DELETE_PRODUCT_CATEGORY, ['project_id' => $this->user['project_id']]); | ||
| 177 | //清除缓存 | 177 | //清除缓存 |
| 178 | Common::del_user_cache('product_category',$this->user['project_id']); | 178 | Common::del_user_cache('product_category',$this->user['project_id']); |
| 179 | return $this->success(); | 179 | return $this->success(); |
| @@ -13,6 +13,9 @@ class NoticeLog extends Model | @@ -13,6 +13,9 @@ class NoticeLog extends Model | ||
| 13 | const TYPE_RANK_DATA = 'rank_data'; | 13 | const TYPE_RANK_DATA = 'rank_data'; |
| 14 | const TYPE_INIT_PROJECT = 'init_project'; | 14 | const TYPE_INIT_PROJECT = 'init_project'; |
| 15 | const TYPE_INIT_KEYWORD = 'init_keyword'; | 15 | const TYPE_INIT_KEYWORD = 'init_keyword'; |
| 16 | + const DELETE_PRODUCT_CATEGORY = 'delete_product_category'; | ||
| 17 | + const DELETE_BLOG_CATEGORY = 'delete_blog_category'; | ||
| 18 | + const DELETE_NEWS_CATEGORY = 'delete_news_category'; | ||
| 16 | const STATUS_PENDING = 0; | 19 | const STATUS_PENDING = 0; |
| 17 | const STATUS_SUCCESS = 1; | 20 | const STATUS_SUCCESS = 1; |
| 18 | const STATUS_FAIL = 2; | 21 | const STATUS_FAIL = 2; |
-
请 注册 或 登录 后发表评论