正在显示
1 个修改的文件
包含
67 行增加
和
0 行删除
| @@ -9,6 +9,7 @@ use App\Models\News\News; | @@ -9,6 +9,7 @@ use App\Models\News\News; | ||
| 9 | use App\Models\News\NewsCategory; | 9 | use App\Models\News\NewsCategory; |
| 10 | use App\Models\News\NewsCategory as NewsCategoryModel; | 10 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 11 | use App\Models\RouteMap\RouteMap; | 11 | use App\Models\RouteMap\RouteMap; |
| 12 | +use App\Models\Template\BTemplate; | ||
| 12 | use App\Services\CosService; | 13 | use App\Services\CosService; |
| 13 | use Illuminate\Support\Facades\DB; | 14 | use Illuminate\Support\Facades\DB; |
| 14 | use mysql_xdevapi\Exception; | 15 | use mysql_xdevapi\Exception; |
| @@ -454,4 +455,70 @@ class NewsLogic extends BaseLogic | @@ -454,4 +455,70 @@ class NewsLogic extends BaseLogic | ||
| 454 | } | 455 | } |
| 455 | return $this->success(); | 456 | return $this->success(); |
| 456 | } | 457 | } |
| 458 | + | ||
| 459 | + /** | ||
| 460 | + * @remark :复制新闻 | ||
| 461 | + * @name :copyNewsInfo | ||
| 462 | + * @author :lyh | ||
| 463 | + * @method :post | ||
| 464 | + * @time :2024/4/28 14:51 | ||
| 465 | + */ | ||
| 466 | + public function copyNewsInfo(){ | ||
| 467 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 468 | + $param = [ | ||
| 469 | + 'name'=>$info['name']."-copy", | ||
| 470 | + 'status'=>$info['status'], | ||
| 471 | + 'sort'=>$info['sort'], | ||
| 472 | + 'category_id'=>$info['category_id'], | ||
| 473 | + 'text'=>$info['text'], | ||
| 474 | + 'remark'=>$info['remark'], | ||
| 475 | + 'url'=>$info['url'], | ||
| 476 | + 'image'=>$info['image'], | ||
| 477 | + 'project_id'=>$info['project_id'], | ||
| 478 | + 'operator_id'=>$this->user['id'], | ||
| 479 | + 'create_id'=>$this->user['id'], | ||
| 480 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 481 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 482 | + ]; | ||
| 483 | + $save_id = $this->model->insertGetId($param); | ||
| 484 | + $route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_NEWS, $save_id, $this->user['project_id']); | ||
| 485 | + $this->model->edit(['url'=>$route],['id'=>$save_id]); | ||
| 486 | + //同步可视化装修数据 | ||
| 487 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 488 | + return $this->success(['id'=>$save_id]); | ||
| 489 | + } | ||
| 490 | + | ||
| 491 | + /** | ||
| 492 | + * @remark :同步模版数据 | ||
| 493 | + * @name :copyTemplate | ||
| 494 | + * @author :lyh | ||
| 495 | + * @method :post | ||
| 496 | + * @time :2023/7/29 15:53 | ||
| 497 | + */ | ||
| 498 | + public function copyTemplate($id,$project_id,$save_id){ | ||
| 499 | + $BTemplateModel = new BTemplate(); | ||
| 500 | + $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_NEWS,'source_id'=>$id,'project_id'=>$project_id]); | ||
| 501 | + if(!empty($list)){ | ||
| 502 | + $data = []; | ||
| 503 | + foreach ($list as $v){ | ||
| 504 | + $data[] = [ | ||
| 505 | + 'html'=>$v['html'], | ||
| 506 | + 'project_id'=>$project_id, | ||
| 507 | + 'source'=>$v['source'], | ||
| 508 | + 'source_id'=>$save_id, | ||
| 509 | + 'template_id'=>$v['template_id'], | ||
| 510 | + 'section_list_id'=>$v['section_list_id'], | ||
| 511 | + 'main_html'=>$v['main_html'], | ||
| 512 | + 'main_css'=>$v['main_css'], | ||
| 513 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 514 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 515 | + ]; | ||
| 516 | + } | ||
| 517 | + $rs = $BTemplateModel->insert($data); | ||
| 518 | + if($rs === false){ | ||
| 519 | + $this->fail('error'); | ||
| 520 | + } | ||
| 521 | + } | ||
| 522 | + return $this->success(); | ||
| 523 | + } | ||
| 457 | } | 524 | } |
-
请 注册 或 登录 后发表评论