作者 lyh

gx

@@ -274,4 +274,24 @@ class NewsController extends BaseController @@ -274,4 +274,24 @@ class NewsController extends BaseController
274 $newsLogic->setAllSort(); 274 $newsLogic->setAllSort();
275 $this->response('success'); 275 $this->response('success');
276 } 276 }
  277 +
  278 +
  279 + /**
  280 + * @remark :批量设置产品分类及状态
  281 + * @name :batchSetCategory
  282 + * @author :lyh
  283 + * @method :post
  284 + * @time :2023/8/15 17:51
  285 + */
  286 + public function batchSetCategory(NewsLogic $logic){
  287 + $this->request->validate([
  288 + 'id'=>'required',
  289 + 'category_id'=>'required',
  290 + ],[
  291 + 'id.required' => '产品ID不能为空',
  292 + 'category_id.required' => '分类ID不能为空',
  293 + ]);
  294 + $logic->batchSetCategory();
  295 + $this->response('success');
  296 + }
277 } 297 }
@@ -396,4 +396,29 @@ class NewsLogic extends BaseLogic @@ -396,4 +396,29 @@ class NewsLogic extends BaseLogic
396 396
397 return false; 397 return false;
398 } 398 }
  399 +
  400 + /**
  401 + * @remark :批量设置产品分类及状态
  402 + * @name :batchSetCategory
  403 + * @author :lyh
  404 + * @method :post
  405 + * @time :2023/8/15 17:53
  406 + */
  407 + public function batchSetCategory(){
  408 + if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
  409 + DB::connection('custom_mysql')->beginTransaction();
  410 + $this->param['category_id'] = ','.implode(',',$this->param['category_id']).',';
  411 + try {
  412 + //批量
  413 + $param = ['category_id'=>$this->param['category_id']];
  414 + $this->model->edit($param,['id'=>['in',$this->param['id']]]);
  415 + DB::connection('custom_mysql')->commit();
  416 + //对应添加关联表
  417 + }catch (\Exception $e){
  418 + DB::connection('custom_mysql')->rollBack();
  419 + $this->fail('系统错误,请联系管理员');
  420 + }
  421 + }
  422 + return $this->success();
  423 + }
399 } 424 }
@@ -75,6 +75,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -75,6 +75,7 @@ Route::middleware(['bloginauth'])->group(function () {
75 Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_status'); 75 Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_status');
76 Route::any('/sort', [\App\Http\Controllers\Bside\News\NewsController::class, 'sort'])->name('news_sort'); 76 Route::any('/sort', [\App\Http\Controllers\Bside\News\NewsController::class, 'sort'])->name('news_sort');
77 Route::any('/allSort', [\App\Http\Controllers\Bside\News\NewsController::class, 'allSort'])->name('news_allSort'); 77 Route::any('/allSort', [\App\Http\Controllers\Bside\News\NewsController::class, 'allSort'])->name('news_allSort');
  78 + Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\News\NewsController::class, 'batchSetCategory'])->name('news_batchSetCategory');
78 Route::any('/statusNum', [\App\Http\Controllers\Bside\News\NewsController::class, 'getStatusNumber'])->name('news_statusNum'); 79 Route::any('/statusNum', [\App\Http\Controllers\Bside\News\NewsController::class, 'getStatusNumber'])->name('news_statusNum');
79 }); 80 });
80 81