正在显示
1 个修改的文件
包含
68 行增加
和
0 行删除
| @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; | @@ -6,6 +6,7 @@ use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | use App\Models\Blog\Blog; | 6 | use App\Models\Blog\Blog; |
| 7 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 7 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 8 | use App\Models\RouteMap\RouteMap; | 8 | use App\Models\RouteMap\RouteMap; |
| 9 | +use App\Models\Template\BTemplate; | ||
| 9 | use App\Services\CosService; | 10 | use App\Services\CosService; |
| 10 | use Illuminate\Support\Facades\DB; | 11 | use Illuminate\Support\Facades\DB; |
| 11 | 12 | ||
| @@ -410,4 +411,71 @@ class BlogLogic extends BaseLogic | @@ -410,4 +411,71 @@ class BlogLogic extends BaseLogic | ||
| 410 | } | 411 | } |
| 411 | return $this->success(); | 412 | return $this->success(); |
| 412 | } | 413 | } |
| 414 | + | ||
| 415 | + /** | ||
| 416 | + * @remark :复制新闻 | ||
| 417 | + * @name :copyNewsInfo | ||
| 418 | + * @author :lyh | ||
| 419 | + * @method :post | ||
| 420 | + * @time :2024/4/28 14:51 | ||
| 421 | + */ | ||
| 422 | + public function copyBlogInfo(){ | ||
| 423 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 424 | + $param = [ | ||
| 425 | + 'name'=>$info['name']."-copy", | ||
| 426 | + 'status'=>$info['status'], | ||
| 427 | + 'sort'=>$info['sort'], | ||
| 428 | + 'category_id'=>$info['category_id'], | ||
| 429 | + 'text'=>$info['text'], | ||
| 430 | + 'remark'=>$info['remark'], | ||
| 431 | + 'url'=>$info['url'], | ||
| 432 | + 'label_id'=>$info['label_id'], | ||
| 433 | + 'image'=>$info['image'], | ||
| 434 | + 'project_id'=>$info['project_id'], | ||
| 435 | + 'operator_id'=>$this->user['id'], | ||
| 436 | + 'create_id'=>$this->user['id'], | ||
| 437 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 438 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 439 | + ]; | ||
| 440 | + $save_id = $this->model->insertGetId($param); | ||
| 441 | + $route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_BLOG, $save_id, $this->user['project_id']); | ||
| 442 | + $this->model->edit(['url'=>$route],['id'=>$save_id]); | ||
| 443 | + //同步可视化装修数据 | ||
| 444 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 445 | + return $this->success(['id'=>$save_id]); | ||
| 446 | + } | ||
| 447 | + | ||
| 448 | + /** | ||
| 449 | + * @remark :同步模版数据 | ||
| 450 | + * @name :copyTemplate | ||
| 451 | + * @author :lyh | ||
| 452 | + * @method :post | ||
| 453 | + * @time :2023/7/29 15:53 | ||
| 454 | + */ | ||
| 455 | + public function copyTemplate($id,$project_id,$save_id){ | ||
| 456 | + $BTemplateModel = new BTemplate(); | ||
| 457 | + $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_BLOG,'source_id'=>$id,'project_id'=>$project_id]); | ||
| 458 | + if(!empty($list)){ | ||
| 459 | + $data = []; | ||
| 460 | + foreach ($list as $v){ | ||
| 461 | + $data[] = [ | ||
| 462 | + 'html'=>$v['html'], | ||
| 463 | + 'project_id'=>$project_id, | ||
| 464 | + 'source'=>$v['source'], | ||
| 465 | + 'source_id'=>$save_id, | ||
| 466 | + 'template_id'=>$v['template_id'], | ||
| 467 | + 'section_list_id'=>$v['section_list_id'], | ||
| 468 | + 'main_html'=>$v['main_html'], | ||
| 469 | + 'main_css'=>$v['main_css'], | ||
| 470 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 471 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 472 | + ]; | ||
| 473 | + } | ||
| 474 | + $rs = $BTemplateModel->insert($data); | ||
| 475 | + if($rs === false){ | ||
| 476 | + $this->fail('error'); | ||
| 477 | + } | ||
| 478 | + } | ||
| 479 | + return $this->success(); | ||
| 480 | + } | ||
| 413 | } | 481 | } |
-
请 注册 或 登录 后发表评论