正在显示
3 个修改的文件
包含
51 行增加
和
0 行删除
| @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\CustomModule; | @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\CustomModule; | ||
| 12 | use App\Enums\Common\Code; | 12 | use App\Enums\Common\Code; |
| 13 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; | 14 | use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic; |
| 15 | +use App\Http\Logic\Bside\Product\ProductLogic; | ||
| 15 | use App\Models\CustomModule\CustomModule; | 16 | use App\Models\CustomModule\CustomModule; |
| 16 | use App\Models\CustomModule\CustomModuleCategory; | 17 | use App\Models\CustomModule\CustomModuleCategory; |
| 17 | use App\Models\CustomModule\CustomModuleContent; | 18 | use App\Models\CustomModule\CustomModuleContent; |
| @@ -325,4 +326,23 @@ class CustomModuleContentController extends BaseController | @@ -325,4 +326,23 @@ class CustomModuleContentController extends BaseController | ||
| 325 | } | 326 | } |
| 326 | $this->response('success',Code::SUCCESS,$info); | 327 | $this->response('success',Code::SUCCESS,$info); |
| 327 | } | 328 | } |
| 329 | + | ||
| 330 | + /** | ||
| 331 | + * @remark :批量设置产品分类 | ||
| 332 | + * @name :batchSetCategory | ||
| 333 | + * @author :lyh | ||
| 334 | + * @method :post | ||
| 335 | + * @time :2023/8/15 17:51 | ||
| 336 | + */ | ||
| 337 | + public function batchSetCategory(CustomModuleContentLogic $logic){ | ||
| 338 | + $this->request->validate([ | ||
| 339 | + 'id'=>'required', | ||
| 340 | + 'category_id'=>'required', | ||
| 341 | + ],[ | ||
| 342 | + 'id.required' => '产品ID不能为空', | ||
| 343 | + 'category_id.required' => '分类ID不能为空', | ||
| 344 | + ]); | ||
| 345 | + $logic->batchSetCategory(); | ||
| 346 | + $this->response('success'); | ||
| 347 | + } | ||
| 328 | } | 348 | } |
| @@ -485,4 +485,34 @@ class CustomModuleContentLogic extends BaseLogic | @@ -485,4 +485,34 @@ class CustomModuleContentLogic extends BaseLogic | ||
| 485 | ]; | 485 | ]; |
| 486 | return $this->success($param); | 486 | return $this->success($param); |
| 487 | } | 487 | } |
| 488 | + | ||
| 489 | + /** | ||
| 490 | + * @remark :批量设置产品分类及状态 | ||
| 491 | + * @name :batchSetCategory | ||
| 492 | + * @author :lyh | ||
| 493 | + * @method :post | ||
| 494 | + * @time :2023/8/15 17:53 | ||
| 495 | + */ | ||
| 496 | + public function batchSetCategory(){ | ||
| 497 | + if(!isset($this->param['category_id']) || empty($this->param['category_id'])){ | ||
| 498 | + $this->fail('请选择分类'); | ||
| 499 | + } | ||
| 500 | + try { | ||
| 501 | + if(!isset($this->param['is_cover']) || ($this->param['is_cover'] == 1)){ | ||
| 502 | + $category_ids = ','.implode(',',$this->param['category_id']).','; | ||
| 503 | + $this->model->edit(['category_id'=>$category_ids],['id'=>['in',$this->param['id']]]); | ||
| 504 | + }else{ | ||
| 505 | + foreach ($this->param['id'] as $id){ | ||
| 506 | + //获取当前产品的分类 | ||
| 507 | + $contentInfo = $this->model->read(['id'=>$id],['id','category_id']); | ||
| 508 | + $category_ids_arr = array_values(array_unique(array_merge($contentInfo['category_id'],$this->param['category_id']))); | ||
| 509 | + $category_ids = ','.implode(',',$category_ids_arr).','; | ||
| 510 | + $this->model->edit(['category_id'=>$category_ids],['id'=>$id]); | ||
| 511 | + } | ||
| 512 | + } | ||
| 513 | + }catch (\Exception $e){ | ||
| 514 | + $this->fail('设置分类失败,请联系管理员'); | ||
| 515 | + } | ||
| 516 | + return $this->success(); | ||
| 517 | + } | ||
| 488 | } | 518 | } |
| @@ -546,6 +546,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -546,6 +546,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 546 | Route::any('/copyModuleContent', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'copyModuleContent'])->name('custom_content_copyModuleContent'); | 546 | Route::any('/copyModuleContent', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'copyModuleContent'])->name('custom_content_copyModuleContent'); |
| 547 | Route::any('/setCustomSort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'setCustomSort'])->name('custom_content_setCustomSort'); | 547 | Route::any('/setCustomSort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'setCustomSort'])->name('custom_content_setCustomSort'); |
| 548 | Route::any('/getCustomSort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'getCustomSort'])->name('custom_content_getCustomSort'); | 548 | Route::any('/getCustomSort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'getCustomSort'])->name('custom_content_getCustomSort'); |
| 549 | + Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'batchSetCategory'])->name('custom_content_batchSetCategory'); | ||
| 549 | }); | 550 | }); |
| 550 | 551 | ||
| 551 | Route::prefix('extend')->group(function () { | 552 | Route::prefix('extend')->group(function () { |
-
请 注册 或 登录 后发表评论