正在显示
6 个修改的文件
包含
166 行增加
和
2 行删除
| @@ -307,4 +307,21 @@ class BlogController extends BaseController | @@ -307,4 +307,21 @@ class BlogController extends BaseController | ||
| 307 | $logic->batchSetCategory(); | 307 | $logic->batchSetCategory(); |
| 308 | $this->response('success'); | 308 | $this->response('success'); |
| 309 | } | 309 | } |
| 310 | + | ||
| 311 | + /** | ||
| 312 | + * @remark :复制新闻 | ||
| 313 | + * @name :copyNews | ||
| 314 | + * @author :lyh | ||
| 315 | + * @method :post | ||
| 316 | + * @time :2024/4/28 11:53 | ||
| 317 | + */ | ||
| 318 | + public function copyBlog(BlogLogic $blog){ | ||
| 319 | + $this->request->validate([ | ||
| 320 | + 'id'=>'required', | ||
| 321 | + ],[ | ||
| 322 | + 'id.required' => 'id不能为空', | ||
| 323 | + ]); | ||
| 324 | + $blog->copyBlogInfo(); | ||
| 325 | + $this->response('success'); | ||
| 326 | + } | ||
| 310 | } | 327 | } |
| @@ -338,7 +338,13 @@ class NewsController extends BaseController | @@ -338,7 +338,13 @@ class NewsController extends BaseController | ||
| 338 | * @method :post | 338 | * @method :post |
| 339 | * @time :2024/4/28 11:53 | 339 | * @time :2024/4/28 11:53 |
| 340 | */ | 340 | */ |
| 341 | - public function copyNews(NewsModel $news){ | ||
| 342 | - | 341 | + public function copyNews(NewsLogic $news){ |
| 342 | + $this->request->validate([ | ||
| 343 | + 'id'=>'required', | ||
| 344 | + ],[ | ||
| 345 | + 'id.required' => 'id不能为空', | ||
| 346 | + ]); | ||
| 347 | + $news->copyNewsInfo(); | ||
| 348 | + $this->response('success'); | ||
| 343 | } | 349 | } |
| 344 | } | 350 | } |
| @@ -433,6 +433,11 @@ class ProductController extends BaseController | @@ -433,6 +433,11 @@ class ProductController extends BaseController | ||
| 433 | * @time :2023/7/29 14:59 | 433 | * @time :2023/7/29 14:59 |
| 434 | */ | 434 | */ |
| 435 | public function copyProduct(ProductLogic $logic){ | 435 | public function copyProduct(ProductLogic $logic){ |
| 436 | + $this->request->validate([ | ||
| 437 | + 'id'=>'required', | ||
| 438 | + ],[ | ||
| 439 | + 'id.required' => 'id不能为空', | ||
| 440 | + ]); | ||
| 436 | $data = $logic->setCopyProduct(); | 441 | $data = $logic->setCopyProduct(); |
| 437 | $this->response('success',Code::SUCCESS,$data); | 442 | $this->response('success',Code::SUCCESS,$data); |
| 438 | } | 443 | } |
| @@ -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 | ||
| @@ -399,4 +400,70 @@ class BlogLogic extends BaseLogic | @@ -399,4 +400,70 @@ class BlogLogic extends BaseLogic | ||
| 399 | } | 400 | } |
| 400 | return $this->success(); | 401 | return $this->success(); |
| 401 | } | 402 | } |
| 403 | + | ||
| 404 | + /** | ||
| 405 | + * @remark :复制新闻 | ||
| 406 | + * @name :copyNewsInfo | ||
| 407 | + * @author :lyh | ||
| 408 | + * @method :post | ||
| 409 | + * @time :2024/4/28 14:51 | ||
| 410 | + */ | ||
| 411 | + public function copyBlogInfo(){ | ||
| 412 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 413 | + $param = [ | ||
| 414 | + 'name'=>$info['name']."-copy", | ||
| 415 | + 'status'=>$info['status'], | ||
| 416 | + 'sort'=>$info['sort'], | ||
| 417 | + 'category_id'=>$info['category_id'], | ||
| 418 | + 'text'=>$info['text'], | ||
| 419 | + 'remark'=>$info['remark'], | ||
| 420 | + 'url'=>$info['url'], | ||
| 421 | + 'image'=>$info['image'], | ||
| 422 | + 'project_id'=>$info['project_id'], | ||
| 423 | + 'operator_id'=>$this->user['id'], | ||
| 424 | + 'create_id'=>$this->user['id'], | ||
| 425 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 426 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 427 | + ]; | ||
| 428 | + $save_id = $this->model->insertGetId($param); | ||
| 429 | + $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_BLOG, $save_id, $this->user['project_id']); | ||
| 430 | + $this->model->edit(['route'=>$route],['id'=>$save_id]); | ||
| 431 | + //同步可视化装修数据 | ||
| 432 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 433 | + return $this->success(['id'=>$save_id]); | ||
| 434 | + } | ||
| 435 | + | ||
| 436 | + /** | ||
| 437 | + * @remark :同步模版数据 | ||
| 438 | + * @name :copyTemplate | ||
| 439 | + * @author :lyh | ||
| 440 | + * @method :post | ||
| 441 | + * @time :2023/7/29 15:53 | ||
| 442 | + */ | ||
| 443 | + public function copyTemplate($id,$project_id,$save_id){ | ||
| 444 | + $BTemplateModel = new BTemplate(); | ||
| 445 | + $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_BLOG,'source_id'=>$id,'project_id'=>$project_id]); | ||
| 446 | + if(!empty($list)){ | ||
| 447 | + $data = []; | ||
| 448 | + foreach ($list as $v){ | ||
| 449 | + $data[] = [ | ||
| 450 | + 'html'=>$v['html'], | ||
| 451 | + 'project_id'=>$project_id, | ||
| 452 | + 'source'=>$v['source'], | ||
| 453 | + 'source_id'=>$save_id, | ||
| 454 | + 'template_id'=>$v['template_id'], | ||
| 455 | + 'section_list_id'=>$v['section_list_id'], | ||
| 456 | + 'main_html'=>$v['main_html'], | ||
| 457 | + 'main_css'=>$v['main_css'], | ||
| 458 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 459 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 460 | + ]; | ||
| 461 | + } | ||
| 462 | + $rs = $BTemplateModel->insert($data); | ||
| 463 | + if($rs === false){ | ||
| 464 | + $this->fail('error'); | ||
| 465 | + } | ||
| 466 | + } | ||
| 467 | + return $this->success(); | ||
| 468 | + } | ||
| 402 | } | 469 | } |
| @@ -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; |
| @@ -444,4 +445,70 @@ class NewsLogic extends BaseLogic | @@ -444,4 +445,70 @@ class NewsLogic extends BaseLogic | ||
| 444 | } | 445 | } |
| 445 | return $this->success(); | 446 | return $this->success(); |
| 446 | } | 447 | } |
| 448 | + | ||
| 449 | + /** | ||
| 450 | + * @remark :复制新闻 | ||
| 451 | + * @name :copyNewsInfo | ||
| 452 | + * @author :lyh | ||
| 453 | + * @method :post | ||
| 454 | + * @time :2024/4/28 14:51 | ||
| 455 | + */ | ||
| 456 | + public function copyNewsInfo(){ | ||
| 457 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 458 | + $param = [ | ||
| 459 | + 'name'=>$info['name']."-copy", | ||
| 460 | + 'status'=>$info['status'], | ||
| 461 | + 'sort'=>$info['sort'], | ||
| 462 | + 'category_id'=>$info['category_id'], | ||
| 463 | + 'text'=>$info['text'], | ||
| 464 | + 'remark'=>$info['remark'], | ||
| 465 | + 'url'=>$info['url'], | ||
| 466 | + 'image'=>$info['image'], | ||
| 467 | + 'project_id'=>$info['project_id'], | ||
| 468 | + 'operator_id'=>$this->user['id'], | ||
| 469 | + 'create_id'=>$this->user['id'], | ||
| 470 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 471 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 472 | + ]; | ||
| 473 | + $save_id = $this->model->insertGetId($param); | ||
| 474 | + $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_NEWS, $save_id, $this->user['project_id']); | ||
| 475 | + $this->model->edit(['route'=>$route],['id'=>$save_id]); | ||
| 476 | + //同步可视化装修数据 | ||
| 477 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 478 | + return $this->success(['id'=>$save_id]); | ||
| 479 | + } | ||
| 480 | + | ||
| 481 | + /** | ||
| 482 | + * @remark :同步模版数据 | ||
| 483 | + * @name :copyTemplate | ||
| 484 | + * @author :lyh | ||
| 485 | + * @method :post | ||
| 486 | + * @time :2023/7/29 15:53 | ||
| 487 | + */ | ||
| 488 | + public function copyTemplate($id,$project_id,$save_id){ | ||
| 489 | + $BTemplateModel = new BTemplate(); | ||
| 490 | + $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_NEWS,'source_id'=>$id,'project_id'=>$project_id]); | ||
| 491 | + if(!empty($list)){ | ||
| 492 | + $data = []; | ||
| 493 | + foreach ($list as $v){ | ||
| 494 | + $data[] = [ | ||
| 495 | + 'html'=>$v['html'], | ||
| 496 | + 'project_id'=>$project_id, | ||
| 497 | + 'source'=>$v['source'], | ||
| 498 | + 'source_id'=>$save_id, | ||
| 499 | + 'template_id'=>$v['template_id'], | ||
| 500 | + 'section_list_id'=>$v['section_list_id'], | ||
| 501 | + 'main_html'=>$v['main_html'], | ||
| 502 | + 'main_css'=>$v['main_css'], | ||
| 503 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 504 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 505 | + ]; | ||
| 506 | + } | ||
| 507 | + $rs = $BTemplateModel->insert($data); | ||
| 508 | + if($rs === false){ | ||
| 509 | + $this->fail('error'); | ||
| 510 | + } | ||
| 511 | + } | ||
| 512 | + return $this->success(); | ||
| 513 | + } | ||
| 447 | } | 514 | } |
| @@ -84,6 +84,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -84,6 +84,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 84 | //新闻 | 84 | //新闻 |
| 85 | Route::any('/', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('news_category_lists'); | 85 | Route::any('/', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('news_category_lists'); |
| 86 | Route::any('/newsNoPage', [\App\Http\Controllers\Bside\News\NewsController::class, 'newsNoPage'])->name('news_newsNoPage'); | 86 | Route::any('/newsNoPage', [\App\Http\Controllers\Bside\News\NewsController::class, 'newsNoPage'])->name('news_newsNoPage'); |
| 87 | + Route::any('/copyNews', [\App\Http\Controllers\Bside\News\NewsController::class, 'copyNews'])->name('news_copyNews'); | ||
| 87 | Route::any('/get_category_list', [\App\Http\Controllers\Bside\News\NewsController::class, 'get_category_list'])->name('news_get_category_list'); | 88 | Route::any('/get_category_list', [\App\Http\Controllers\Bside\News\NewsController::class, 'get_category_list'])->name('news_get_category_list'); |
| 88 | Route::any('/add', [\App\Http\Controllers\Bside\News\NewsController::class, 'save'])->name('news_add'); | 89 | Route::any('/add', [\App\Http\Controllers\Bside\News\NewsController::class, 'save'])->name('news_add'); |
| 89 | Route::any('/edit_seo', [\App\Http\Controllers\Bside\News\NewsController::class, 'edit_seo'])->name('news_edit_seo'); | 90 | Route::any('/edit_seo', [\App\Http\Controllers\Bside\News\NewsController::class, 'edit_seo'])->name('news_edit_seo'); |
| @@ -112,6 +113,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -112,6 +113,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 112 | Route::any('/sort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'sort'])->name('blog_sort'); | 113 | Route::any('/sort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'sort'])->name('blog_sort'); |
| 113 | Route::any('/allSort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'allSort'])->name('blog_allSort'); | 114 | Route::any('/allSort', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'allSort'])->name('blog_allSort'); |
| 114 | Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'batchSetCategory'])->name('blog_batchSetCategory'); | 115 | Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'batchSetCategory'])->name('blog_batchSetCategory'); |
| 116 | + Route::any('/copyBlog', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'copyBlog'])->name('blog_copyBlog'); | ||
| 115 | Route::any('/statusNum', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'getStatusNumber'])->name('blog_statusNum'); | 117 | Route::any('/statusNum', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'getStatusNumber'])->name('blog_statusNum'); |
| 116 | //分类 | 118 | //分类 |
| 117 | Route::any('/category/', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'lists'])->name('blog_category_lists'); | 119 | Route::any('/category/', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'lists'])->name('blog_category_lists'); |
-
请 注册 或 登录 后发表评论