正在显示
4 个修改的文件
包含
55 行增加
和
1 行删除
| @@ -287,4 +287,25 @@ class BlogController extends BaseController | @@ -287,4 +287,25 @@ class BlogController extends BaseController | ||
| 287 | $logic->setAllSort(); | 287 | $logic->setAllSort(); |
| 288 | $this->response('success'); | 288 | $this->response('success'); |
| 289 | } | 289 | } |
| 290 | + | ||
| 291 | + /** | ||
| 292 | + * @remark :批量设置产品分类及状态 | ||
| 293 | + * @name :batchSetCategory | ||
| 294 | + * @author :lyh | ||
| 295 | + * @method :post | ||
| 296 | + * @time :2023/8/15 17:51 | ||
| 297 | + */ | ||
| 298 | + public function batchSetCategory(BlogLogic $logic){ | ||
| 299 | + $this->request->validate([ | ||
| 300 | + 'id'=>'required', | ||
| 301 | + 'category_id'=>'required', | ||
| 302 | + 'status'=>'required' | ||
| 303 | + ],[ | ||
| 304 | + 'id.required' => '产品ID不能为空', | ||
| 305 | + 'category_id.required' => '分类ID不能为空', | ||
| 306 | + 'status.required'=>'状态不能为空' | ||
| 307 | + ]); | ||
| 308 | + $logic->batchSetCategory(); | ||
| 309 | + $this->response('success'); | ||
| 310 | + } | ||
| 290 | } | 311 | } |
| @@ -287,9 +287,11 @@ class NewsController extends BaseController | @@ -287,9 +287,11 @@ class NewsController extends BaseController | ||
| 287 | $this->request->validate([ | 287 | $this->request->validate([ |
| 288 | 'id'=>'required', | 288 | 'id'=>'required', |
| 289 | 'category_id'=>'required', | 289 | 'category_id'=>'required', |
| 290 | + 'status'=>'required' | ||
| 290 | ],[ | 291 | ],[ |
| 291 | 'id.required' => '产品ID不能为空', | 292 | 'id.required' => '产品ID不能为空', |
| 292 | 'category_id.required' => '分类ID不能为空', | 293 | 'category_id.required' => '分类ID不能为空', |
| 294 | + 'status.required'=>'状态不能为空' | ||
| 293 | ]); | 295 | ]); |
| 294 | $logic->batchSetCategory(); | 296 | $logic->batchSetCategory(); |
| 295 | $this->response('success'); | 297 | $this->response('success'); |
| @@ -362,4 +362,32 @@ class BlogLogic extends BaseLogic | @@ -362,4 +362,32 @@ class BlogLogic extends BaseLogic | ||
| 362 | 362 | ||
| 363 | return false; | 363 | return false; |
| 364 | } | 364 | } |
| 365 | + | ||
| 366 | + /** | ||
| 367 | + * @remark :批量设置产品分类及状态 | ||
| 368 | + * @name :batchSetCategory | ||
| 369 | + * @author :lyh | ||
| 370 | + * @method :post | ||
| 371 | + * @time :2023/8/15 17:53 | ||
| 372 | + */ | ||
| 373 | + public function batchSetCategory(){ | ||
| 374 | + if(isset($this->param['category_id']) && !empty($this->param['category_id'])) { | ||
| 375 | + DB::connection('custom_mysql')->beginTransaction(); | ||
| 376 | + $this->param['category_id'] = ','.implode(',',$this->param['category_id']).','; | ||
| 377 | + try { | ||
| 378 | + //批量 | ||
| 379 | + $param = [ | ||
| 380 | + 'category_id'=>$this->param['category_id'], | ||
| 381 | + 'status'=>$this->param['status'] | ||
| 382 | + ]; | ||
| 383 | + $this->model->edit($param,['id'=>['in',$this->param['id']]]); | ||
| 384 | + DB::connection('custom_mysql')->commit(); | ||
| 385 | + //对应添加关联表 | ||
| 386 | + }catch (\Exception $e){ | ||
| 387 | + DB::connection('custom_mysql')->rollBack(); | ||
| 388 | + $this->fail('系统错误,请联系管理员'); | ||
| 389 | + } | ||
| 390 | + } | ||
| 391 | + return $this->success(); | ||
| 392 | + } | ||
| 365 | } | 393 | } |
| @@ -410,7 +410,10 @@ class NewsLogic extends BaseLogic | @@ -410,7 +410,10 @@ class NewsLogic extends BaseLogic | ||
| 410 | $this->param['category_id'] = ','.implode(',',$this->param['category_id']).','; | 410 | $this->param['category_id'] = ','.implode(',',$this->param['category_id']).','; |
| 411 | try { | 411 | try { |
| 412 | //批量 | 412 | //批量 |
| 413 | - $param = ['category_id'=>$this->param['category_id']]; | 413 | + $param = [ |
| 414 | + 'category_id'=>$this->param['category_id'], | ||
| 415 | + 'status'=>$this->param['status'] | ||
| 416 | + ]; | ||
| 414 | $this->model->edit($param,['id'=>['in',$this->param['id']]]); | 417 | $this->model->edit($param,['id'=>['in',$this->param['id']]]); |
| 415 | DB::connection('custom_mysql')->commit(); | 418 | DB::connection('custom_mysql')->commit(); |
| 416 | //对应添加关联表 | 419 | //对应添加关联表 |
-
请 注册 或 登录 后发表评论