正在显示
5 个修改的文件
包含
157 行增加
和
1 行删除
| @@ -255,4 +255,16 @@ class CustomModuleContentController extends BaseController | @@ -255,4 +255,16 @@ class CustomModuleContentController extends BaseController | ||
| 255 | $logic->setAllSort(); | 255 | $logic->setAllSort(); |
| 256 | $this->response('success'); | 256 | $this->response('success'); |
| 257 | } | 257 | } |
| 258 | + | ||
| 259 | + /** | ||
| 260 | + * @remark :复制扩展模块 | ||
| 261 | + * @name :copyModuleContent | ||
| 262 | + * @author :lyh | ||
| 263 | + * @method :post | ||
| 264 | + * @time :2024/4/28 16:31 | ||
| 265 | + */ | ||
| 266 | + public function copyModuleContent(CustomModuleContentLogic $logic){ | ||
| 267 | + $logic->copyModuleContentInfo(); | ||
| 268 | + $this->response('success'); | ||
| 269 | + } | ||
| 258 | } | 270 | } |
| @@ -156,4 +156,21 @@ class CustomTemplateController extends BaseController | @@ -156,4 +156,21 @@ class CustomTemplateController extends BaseController | ||
| 156 | $logic->saveRollbackVersion(); | 156 | $logic->saveRollbackVersion(); |
| 157 | $this->response('success'); | 157 | $this->response('success'); |
| 158 | } | 158 | } |
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * @remark :复制单页 | ||
| 162 | + * @name :copyCustomTemplate | ||
| 163 | + * @author :lyh | ||
| 164 | + * @method :post | ||
| 165 | + * @time :2024/4/28 16:13 | ||
| 166 | + */ | ||
| 167 | + public function copyCustomTemplate(CustomTemplateLogic $logic){ | ||
| 168 | + $this->request->validate([ | ||
| 169 | + 'id'=>['required'], | ||
| 170 | + ],[ | ||
| 171 | + 'id.required' => 'ID不能为空', | ||
| 172 | + ]); | ||
| 173 | + $logic->copyCustomTemplateInfo(); | ||
| 174 | + $this->response('success'); | ||
| 175 | + } | ||
| 159 | } | 176 | } |
| @@ -395,7 +395,44 @@ class CustomTemplateLogic extends BaseLogic | @@ -395,7 +395,44 @@ class CustomTemplateLogic extends BaseLogic | ||
| 395 | }else{ | 395 | }else{ |
| 396 | $this->model->edit(['html'=>$logInfo['text']],['id'=>$logInfo['source_id']]); | 396 | $this->model->edit(['html'=>$logInfo['text']],['id'=>$logInfo['source_id']]); |
| 397 | } | 397 | } |
| 398 | - | ||
| 399 | return $this->success(); | 398 | return $this->success(); |
| 400 | } | 399 | } |
| 400 | + | ||
| 401 | + /** | ||
| 402 | + * @remark :复制单页面 | ||
| 403 | + * @name :copyCustomTemplateInfo | ||
| 404 | + * @author :lyh | ||
| 405 | + * @method :post | ||
| 406 | + * @time :2024/4/28 16:16 | ||
| 407 | + */ | ||
| 408 | + public function copyCustomTemplateInfo(){ | ||
| 409 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 410 | + $param = $this->setCustomTemplateParams($info); | ||
| 411 | + $save_id = $this->model->insertGetId($param); | ||
| 412 | + $route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']); | ||
| 413 | + $this->model->edit(['route'=>$route],['id'=>$save_id]); | ||
| 414 | + return $this->success(['id'=>$save_id]); | ||
| 415 | + } | ||
| 416 | + | ||
| 417 | + /** | ||
| 418 | + * @remark :组装数据 | ||
| 419 | + * @name :setCustomTemplateParams | ||
| 420 | + * @author :lyh | ||
| 421 | + * @method :post | ||
| 422 | + * @time :2024/4/28 16:18 | ||
| 423 | + */ | ||
| 424 | + public function setCustomTemplateParams($info){ | ||
| 425 | + return [ | ||
| 426 | + 'name'=>$info['name'].'-copy', | ||
| 427 | + 'status'=>$info['status'], | ||
| 428 | + 'url'=>$info['url'], | ||
| 429 | + 'html'=>$info['html'], | ||
| 430 | + 'html_style'=>$info['html_style'], | ||
| 431 | + 'project_id'=>$info['project_id'], | ||
| 432 | + 'section_list_id'=>$info['section_list_id'], | ||
| 433 | + 'is_visualization'=>$info['is_visualization'], | ||
| 434 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 435 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 436 | + ]; | ||
| 437 | + } | ||
| 401 | } | 438 | } |
| @@ -16,6 +16,7 @@ use App\Models\CustomModule\CustomModuleContent; | @@ -16,6 +16,7 @@ use App\Models\CustomModule\CustomModuleContent; | ||
| 16 | use App\Models\CustomModule\CustomModuleExtend; | 16 | use App\Models\CustomModule\CustomModuleExtend; |
| 17 | use App\Models\CustomModule\CustomModuleExtentContent; | 17 | use App\Models\CustomModule\CustomModuleExtentContent; |
| 18 | use App\Models\RouteMap\RouteMap; | 18 | use App\Models\RouteMap\RouteMap; |
| 19 | +use App\Models\Template\BTemplate; | ||
| 19 | use Illuminate\Support\Facades\DB; | 20 | use Illuminate\Support\Facades\DB; |
| 20 | use mysql_xdevapi\Exception; | 21 | use mysql_xdevapi\Exception; |
| 21 | 22 | ||
| @@ -391,4 +392,92 @@ class CustomModuleContentLogic extends BaseLogic | @@ -391,4 +392,92 @@ class CustomModuleContentLogic extends BaseLogic | ||
| 391 | } | 392 | } |
| 392 | return $this->success(); | 393 | return $this->success(); |
| 393 | } | 394 | } |
| 395 | + | ||
| 396 | + /** | ||
| 397 | + * @remark :复制扩展模块内容页 | ||
| 398 | + * @name :copyModuleContentInfo | ||
| 399 | + * @author :lyh | ||
| 400 | + * @method :post | ||
| 401 | + * @time :2024/4/28 16:32 | ||
| 402 | + */ | ||
| 403 | + public function copyModuleContentInfo(){ | ||
| 404 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 405 | + $param = $this->setContentParams($info); | ||
| 406 | + $save_id = $this->model->insertGetId($param); | ||
| 407 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id,$info['module_id']); | ||
| 408 | + $this->response('success'); | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + /** | ||
| 412 | + * @remark :字段处理 | ||
| 413 | + * @name :setContentParams | ||
| 414 | + * @author :lyh | ||
| 415 | + * @method :post | ||
| 416 | + * @time :2024/4/28 16:33 | ||
| 417 | + */ | ||
| 418 | + public function setContentParams($info){ | ||
| 419 | + return [ | ||
| 420 | + 'name'=>$info['name'].'-copy', | ||
| 421 | + 'status'=>$info['status'], | ||
| 422 | + 'sort'=>$info['sort'], | ||
| 423 | + 'content'=>$info['content'], | ||
| 424 | + 'remark'=>$info['remark'], | ||
| 425 | + 'route'=>$info['route'], | ||
| 426 | + 'image'=>$info['image'], | ||
| 427 | + 'project_id'=>$info['project_id'], | ||
| 428 | + 'operator_id'=>$this->user['id'], | ||
| 429 | + 'module_id'=>$info['module_id'], | ||
| 430 | + 'category_id'=>!empty($info['category_id']) ? ','.Arr::arrToSet($info['category_id']).',' : '', | ||
| 431 | + 'video'=>Arr::a2s($info['video']), | ||
| 432 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 433 | + 'updated_at'=>date('Y-m-d H:i:s') | ||
| 434 | + ]; | ||
| 435 | + } | ||
| 436 | + | ||
| 437 | + /** | ||
| 438 | + * @remark :同步模版数据 | ||
| 439 | + * @name :copyTemplate | ||
| 440 | + * @author :lyh | ||
| 441 | + * @method :post | ||
| 442 | + * @time :2023/7/29 15:53 | ||
| 443 | + */ | ||
| 444 | + public function copyTemplate($id,$project_id,$save_id,$module_id){ | ||
| 445 | + $BTemplateModel = new BTemplate(); | ||
| 446 | + $list = $BTemplateModel->list(['source'=>$module_id,'source_id'=>$id,'is_custom'=>BTemplate::IS_CUSTOM,'project_id'=>$project_id]); | ||
| 447 | + if(!empty($list)){ | ||
| 448 | + $data = []; | ||
| 449 | + foreach ($list as $v){ | ||
| 450 | + $data[] = $this->setTemplateParams($v,$project_id,$save_id); | ||
| 451 | + } | ||
| 452 | + $rs = $BTemplateModel->insert($data); | ||
| 453 | + if($rs === false){ | ||
| 454 | + $this->fail('error'); | ||
| 455 | + } | ||
| 456 | + } | ||
| 457 | + return $this->success(); | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + /** | ||
| 461 | + * @remark :组装模版数据 | ||
| 462 | + * @name :setTemplateParams | ||
| 463 | + * @author :lyh | ||
| 464 | + * @method :post | ||
| 465 | + * @time :2023/7/29 15:54 | ||
| 466 | + */ | ||
| 467 | + public function setTemplateParams($v,$project_id,$save_id){ | ||
| 468 | + $param = [ | ||
| 469 | + 'html'=>$v['html'], | ||
| 470 | + 'project_id'=>$project_id, | ||
| 471 | + 'source'=>$v['source'], | ||
| 472 | + 'source_id'=>$save_id, | ||
| 473 | + 'template_id'=>$v['template_id'], | ||
| 474 | + 'section_list_id'=>$v['section_list_id'], | ||
| 475 | + 'main_html'=>$v['main_html'], | ||
| 476 | + 'main_css'=>$v['main_css'], | ||
| 477 | + 'is_custom'=>$v['is_custom'], | ||
| 478 | + 'created_at'=>$v['created_at'], | ||
| 479 | + 'updated_at'=>$v['updated_at'] | ||
| 480 | + ]; | ||
| 481 | + return $this->success($param); | ||
| 482 | + } | ||
| 394 | } | 483 | } |
| @@ -402,6 +402,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -402,6 +402,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 402 | Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del'); | 402 | Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del'); |
| 403 | Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'rollbackVersion'])->name('custom_rollbackVersion'); | 403 | Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'rollbackVersion'])->name('custom_rollbackVersion'); |
| 404 | Route::any('/getCustomTemplateLog', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'getCustomTemplateLog'])->name('custom_getCustomTemplateLog'); | 404 | Route::any('/getCustomTemplateLog', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'getCustomTemplateLog'])->name('custom_getCustomTemplateLog'); |
| 405 | + Route::any('/copyCustomTemplate', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'copyCustomTemplate'])->name('custom_copyCustomTemplate'); | ||
| 405 | }); | 406 | }); |
| 406 | // 菜单组 | 407 | // 菜单组 |
| 407 | Route::prefix('nav_group')->group(function () { | 408 | Route::prefix('nav_group')->group(function () { |
-
请 注册 或 登录 后发表评论