作者 lyh

gx

正在显示 40 个修改的文件 包含 1376 行增加570 行删除
@@ -64,12 +64,14 @@ class Demo extends Command @@ -64,12 +64,14 @@ class Demo extends Command
64 public function handle() 64 public function handle()
65 { 65 {
66 $projectModel = new Project(); 66 $projectModel = new Project();
67 - $list = $projectModel->list(['delete_status'=>0]); 67 + $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]);
68 $data = []; 68 $data = [];
69 foreach ($list as $v){ 69 foreach ($list as $v){
70 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 70 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
71 ProjectServer::useProject($v['id']); 71 ProjectServer::useProject($v['id']);
72 DB::table('gl_web_template_com')->truncate(); 72 DB::table('gl_web_template_com')->truncate();
  73 + $templateComModel = new BTemplateCom();
  74 + $templateComModel->truncate();
73 $this->saveTemplateCom($v['id']); 75 $this->saveTemplateCom($v['id']);
74 DB::disconnect('custom_mysql'); 76 DB::disconnect('custom_mysql');
75 } 77 }
@@ -43,6 +43,7 @@ class KeywordVideoController extends BaseController @@ -43,6 +43,7 @@ class KeywordVideoController extends BaseController
43 'gl_keyword_video_task.project_id AS project_id', 43 'gl_keyword_video_task.project_id AS project_id',
44 'gl_keyword_video_task.number AS number', 44 'gl_keyword_video_task.number AS number',
45 'gl_keyword_video_task.status AS status', 45 'gl_keyword_video_task.status AS status',
  46 + 'gl_keyword_video_task.keywords AS keywords',
46 'gl_keyword_video_task.sort AS sort', 47 'gl_keyword_video_task.sort AS sort',
47 'gl_keyword_video_task.created_at AS created_at', 48 'gl_keyword_video_task.created_at AS created_at',
48 'gl_keyword_video_task.updated_at AS updated_at', 49 'gl_keyword_video_task.updated_at AS updated_at',
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ReplaceHtmlController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/8 10:02
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Template;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Http\Logic\Aside\Template\ReplaceHtmlLogic;
  15 +use App\Models\Template\TemplateReplaceHtml;
  16 +use App\Models\Template\TemplateReplaceHtmlLog;
  17 +use App\Services\ProjectServer;
  18 +use Illuminate\Support\Facades\DB;
  19 +
  20 +class ReplaceHtmlController extends BaseController
  21 +{
  22 + /**
  23 + * @remark :替换同一种类型的html代码
  24 + * @name :replaceTemplateMainHtml
  25 + * @author :lyh
  26 + * @method :post
  27 + * @time :2024/5/7 14:39
  28 + */
  29 + public function replaceTemplateMainHtml(ReplaceHtmlLogic $logic){
  30 + $this->request->validate([
  31 + 'old_html'=>'required',
  32 + 'html'=>'required',
  33 + 'type'=>'required',
  34 + 'is_list'=>'required',
  35 + 'is_custom'=>'required',
  36 + 'project_id'=>'required',
  37 + ],[
  38 + 'old_html.required' => '需替换的html不能为空',
  39 + 'html.required' => 'html不能为空',
  40 + 'type.required' => '类型type不能为空',
  41 + 'is_custom.required' => '类型is_custom不能为空',
  42 + 'is_list.required' => '类型is_list不能为空',
  43 + 'project_id.required' => 'project_id不能为空',
  44 + ]);
  45 + $logic->replaceHtml();
  46 + $this->response('success');
  47 + }
  48 +
  49 + /**
  50 + * @remark :替换的记录
  51 + * @name :replaceTemplateLog
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2024/5/8 10:28
  55 + */
  56 + public function replaceTemplateLog(TemplateReplaceHtml $replaceModel){
  57 + $this->request->validate([
  58 + 'project_id'=>'required',
  59 + ],[
  60 + 'project_id.required' => 'project_id不能为空',
  61 + ]);
  62 + ProjectServer::useProject($this->param['project_id']);
  63 + $lists = $replaceModel->lists($this->map,$this->page,$this->row,$this->order);
  64 + if(!empty($lists) && !empty($lists['list'])){
  65 + $templateLogModel = new TemplateReplaceHtmlLog();
  66 + foreach ($lists['list'] as $k => $v){
  67 + $v['sub'] = $templateLogModel->list(['replace_id'=>$v['id']]);
  68 + $lists['list'][$k] = $v;
  69 + }
  70 + }
  71 + DB::disconnect('custom_mysql');
  72 + $this->response('success',Code::SUCCESS,$lists);
  73 + }
  74 +
  75 + /**
  76 + * @remark :还原
  77 + * @name :reductionHtml
  78 + * @author :lyh
  79 + * @method :post
  80 + * @time :2024/5/8 10:27
  81 + */
  82 + public function reductionHtml(ReplaceHtmlLogic $logic){
  83 + $this->request->validate([
  84 + 'id'=>'required',
  85 + ],[
  86 + 'id.required' => 'id不能为空',
  87 + ]);
  88 + $logic->reductionHtml();
  89 + $this->response('success');
  90 + }
  91 +}
@@ -24,7 +24,7 @@ class PageSettingController extends BaseController @@ -24,7 +24,7 @@ class PageSettingController extends BaseController
24 */ 24 */
25 public function info(){ 25 public function info(){
26 $pageSettingModel = new PageSetting(); 26 $pageSettingModel = new PageSetting();
27 - $info = $pageSettingModel->read(['project_id'=>$this->user['project_id']]); 27 + $info = $pageSettingModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'] ?? 1]);
28 if($info === false){ 28 if($info === false){
29 $info = [ 29 $info = [
30 'project_id'=>$this->user['project_id'], 30 'project_id'=>$this->user['project_id'],
@@ -36,6 +36,8 @@ class PageSettingController extends BaseController @@ -36,6 +36,8 @@ class PageSettingController extends BaseController
36 'news_list'=>0, 36 'news_list'=>0,
37 'news_details'=>0, 37 'news_details'=>0,
38 'polymerization'=>0, 38 'polymerization'=>0,
  39 + 'home'=>0,
  40 + 'type'=>$this->param['type'] ?? 1,
39 ]; 41 ];
40 $pageSettingModel->add($info); 42 $pageSettingModel->add($info);
41 } 43 }
@@ -51,7 +53,7 @@ class PageSettingController extends BaseController @@ -51,7 +53,7 @@ class PageSettingController extends BaseController
51 */ 53 */
52 public function edit(){ 54 public function edit(){
53 $pageSettingModel = new PageSetting(); 55 $pageSettingModel = new PageSetting();
54 - $rs = $pageSettingModel->edit($this->param,['project_id'=>$this->user['project_id']]); 56 + $rs = $pageSettingModel->edit($this->param,['project_id'=>$this->user['project_id'],'type'=>$this->param['type'] ?? 1]);
55 if($rs === false){ 57 if($rs === false){
56 $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR); 58 $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR);
57 } 59 }
@@ -151,4 +151,17 @@ class BlogCategoryController extends BaseController @@ -151,4 +151,17 @@ class BlogCategoryController extends BaseController
151 //TODO::写入操作日志 151 //TODO::写入操作日志
152 $this->response('success'); 152 $this->response('success');
153 } 153 }
  154 +
  155 +
  156 + /**
  157 + * @remark :批量排序
  158 + * @name :allSort
  159 + * @author :lyh
  160 + * @method :post
  161 + * @time :2024/1/11 9:46
  162 + */
  163 + public function allSort(BlogCategoryLogic $blogCategoryLogic){
  164 + $blogCategoryLogic->setAllSort();
  165 + $this->response('success');
  166 + }
154 } 167 }
@@ -298,13 +298,28 @@ class BlogController extends BaseController @@ -298,13 +298,28 @@ class BlogController extends BaseController
298 $this->request->validate([ 298 $this->request->validate([
299 'id'=>'required', 299 'id'=>'required',
300 'category_id'=>'required', 300 'category_id'=>'required',
301 - 'status'=>'required'  
302 ],[ 301 ],[
303 'id.required' => '产品ID不能为空', 302 'id.required' => '产品ID不能为空',
304 'category_id.required' => '分类ID不能为空', 303 'category_id.required' => '分类ID不能为空',
305 - 'status.required'=>'状态不能为空'  
306 ]); 304 ]);
307 $logic->batchSetCategory(); 305 $logic->batchSetCategory();
308 $this->response('success'); 306 $this->response('success');
309 } 307 }
  308 +
  309 + /**
  310 + * @remark :复制新闻
  311 + * @name :copyNews
  312 + * @author :lyh
  313 + * @method :post
  314 + * @time :2024/4/28 11:53
  315 + */
  316 + public function copyBlog(BlogLogic $blog){
  317 + $this->request->validate([
  318 + 'id'=>'required',
  319 + ],[
  320 + 'id.required' => 'id不能为空',
  321 + ]);
  322 + $data = $blog->copyBlogInfo();
  323 + $this->response('success',Code::SUCCESS,$data);
  324 + }
310 } 325 }
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\CustomModule; @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\CustomModule;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
14 use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic; 14 use App\Http\Logic\Bside\CustomModule\CustomModuleCategoryLogic;
  15 +use App\Http\Logic\Bside\CustomModule\CustomModuleContentLogic;
15 use App\Models\CustomModule\CustomModule; 16 use App\Models\CustomModule\CustomModule;
16 use App\Models\CustomModule\CustomModuleCategory; 17 use App\Models\CustomModule\CustomModuleCategory;
17 use App\Models\Template\BTemplate; 18 use App\Models\Template\BTemplate;
@@ -173,4 +174,18 @@ class CustomModuleCategoryController extends BaseController @@ -173,4 +174,18 @@ class CustomModuleCategoryController extends BaseController
173 $logic->categorySort(); 174 $logic->categorySort();
174 $this->response('success'); 175 $this->response('success');
175 } 176 }
  177 +
  178 + /**
  179 + * @remark :批量排序
  180 + * @name :allSort
  181 + * @author :lyh
  182 + * @method :post
  183 + * @time :2024/1/11 9:46
  184 + */
  185 + public function allSort(CustomModuleCategoryLogic $logic){
  186 + $logic->setAllSort();
  187 + $this->response('success');
  188 + }
  189 +
  190 +
176 } 191 }
@@ -243,4 +243,28 @@ class CustomModuleContentController extends BaseController @@ -243,4 +243,28 @@ class CustomModuleContentController extends BaseController
243 $logic->contentSort(); 243 $logic->contentSort();
244 $this->response('success'); 244 $this->response('success');
245 } 245 }
  246 +
  247 + /**
  248 + * @remark :批量排序
  249 + * @name :allSort
  250 + * @author :lyh
  251 + * @method :post
  252 + * @time :2024/1/11 9:46
  253 + */
  254 + public function allSort(CustomModuleContentLogic $logic){
  255 + $logic->setAllSort();
  256 + $this->response('success');
  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 + }
246 } 270 }
@@ -148,4 +148,17 @@ class NewsCategoryController extends BaseController @@ -148,4 +148,17 @@ class NewsCategoryController extends BaseController
148 $this->response('success'); 148 $this->response('success');
149 } 149 }
150 150
  151 +
  152 + /**
  153 + * @remark :批量排序
  154 + * @name :allSort
  155 + * @author :lyh
  156 + * @method :post
  157 + * @time :2024/1/11 9:46
  158 + */
  159 + public function allSort(NewsCategoryLogic $newsCategoryLogic){
  160 + $newsCategoryLogic->setAllSort();
  161 + $this->response('success');
  162 + }
  163 +
151 } 164 }
@@ -281,7 +281,7 @@ class NewsController extends BaseController @@ -281,7 +281,7 @@ class NewsController extends BaseController
281 281
282 282
283 /** 283 /**
284 - * @remark :批量设置产品分类及状态 284 + * @remark :批量设置分类及状态
285 * @name :batchSetCategory 285 * @name :batchSetCategory
286 * @author :lyh 286 * @author :lyh
287 * @method :post 287 * @method :post
@@ -291,11 +291,9 @@ class NewsController extends BaseController @@ -291,11 +291,9 @@ class NewsController extends BaseController
291 $this->request->validate([ 291 $this->request->validate([
292 'id'=>'required', 292 'id'=>'required',
293 'category_id'=>'required', 293 'category_id'=>'required',
294 - 'status'=>'required'  
295 ],[ 294 ],[
296 'id.required' => '产品ID不能为空', 295 'id.required' => '产品ID不能为空',
297 'category_id.required' => '分类ID不能为空', 296 'category_id.required' => '分类ID不能为空',
298 - 'status.required'=>'状态不能为空'  
299 ]); 297 ]);
300 $logic->batchSetCategory(); 298 $logic->batchSetCategory();
301 $this->response('success'); 299 $this->response('success');
@@ -338,7 +336,13 @@ class NewsController extends BaseController @@ -338,7 +336,13 @@ class NewsController extends BaseController
338 * @method :post 336 * @method :post
339 * @time :2024/4/28 11:53 337 * @time :2024/4/28 11:53
340 */ 338 */
341 - public function copyNews(NewsModel $news){  
342 - 339 + public function copyNews(NewsLogic $news){
  340 + $this->request->validate([
  341 + 'id'=>'required',
  342 + ],[
  343 + 'id.required' => 'id不能为空',
  344 + ]);
  345 + $data = $news->copyNewsInfo();
  346 + $this->response('success',Code::SUCCESS,$data);
343 } 347 }
344 } 348 }
@@ -164,4 +164,17 @@ class CategoryController extends BaseController @@ -164,4 +164,17 @@ class CategoryController extends BaseController
164 $data = $logic->categoryDelete(); 164 $data = $logic->categoryDelete();
165 $this->response('success',Code::SUCCESS,$data); 165 $this->response('success',Code::SUCCESS,$data);
166 } 166 }
  167 +
  168 +
  169 + /**
  170 + * @remark :批量更新排序
  171 + * @name :allSort
  172 + * @author :lyh
  173 + * @method :post
  174 + * @time :2024/1/10 15:34
  175 + */
  176 + public function allSort(CategoryLogic $logic){
  177 + $logic->setAllSort();
  178 + $this->response('success');
  179 + }
167 } 180 }
@@ -297,7 +297,7 @@ class ProductController extends BaseController @@ -297,7 +297,7 @@ class ProductController extends BaseController
297 $v = $this->getHandleFileImage($v); 297 $v = $this->getHandleFileImage($v);
298 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL); 298 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
299 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0); 299 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0);
300 - $v['url'] = $this->user['domain'].$v['route'] ?? ''; 300 + $v['url'] = $this->user['domain'].($v['route'] ?? '');
301 //获取当前数据扩展字段及值 301 //获取当前数据扩展字段及值
302 $v['extend'] = $this->getExtendInfo($v['id']); 302 $v['extend'] = $this->getExtendInfo($v['id']);
303 return $v; 303 return $v;
@@ -433,12 +433,17 @@ class ProductController extends BaseController @@ -433,12 +433,17 @@ 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 }
439 444
440 /** 445 /**
441 - * @remark :批量设置产品分类及状态 446 + * @remark :批量设置产品分类
442 * @name :batchSetCategory 447 * @name :batchSetCategory
443 * @author :lyh 448 * @author :lyh
444 * @method :post 449 * @method :post
@@ -448,11 +453,9 @@ class ProductController extends BaseController @@ -448,11 +453,9 @@ class ProductController extends BaseController
448 $this->request->validate([ 453 $this->request->validate([
449 'id'=>'required', 454 'id'=>'required',
450 'category_id'=>'required', 455 'category_id'=>'required',
451 - 'status'=>'required'  
452 ],[ 456 ],[
453 'id.required' => '产品ID不能为空', 457 'id.required' => '产品ID不能为空',
454 'category_id.required' => '分类ID不能为空', 458 'category_id.required' => '分类ID不能为空',
455 - 'status.required'=>'状态不能为空'  
456 ]); 459 ]);
457 $logic->batchSetCategory(); 460 $logic->batchSetCategory();
458 $this->response('success'); 461 $this->response('success');
@@ -51,7 +51,7 @@ class BTemplateController extends BaseController @@ -51,7 +51,7 @@ class BTemplateController extends BaseController
51 } 51 }
52 52
53 /** 53 /**
54 - * @remark :获取当前已选择的模板 54 + * @remark :获取可视化数据
55 * @name :getModuleTemplate 55 * @name :getModuleTemplate
56 * @author :lyh 56 * @author :lyh
57 * @method :post 57 * @method :post
@@ -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 }
@@ -165,14 +165,16 @@ class FileController @@ -165,14 +165,16 @@ class FileController
165 */ 165 */
166 public function getOnlyFilename($name,$project_id = 0){ 166 public function getOnlyFilename($name,$project_id = 0){
167 $nameArr = explode('.',$name); 167 $nameArr = explode('.',$name);
168 - $enName = generateRoute(Translate::tran($nameArr[0], 'en')); 168 + $suffix = array_pop($nameArr) ?? 'jpg';
  169 + $nameStr = implode('-', $nameArr);
  170 + $enName = generateRoute(Translate::tran($nameStr, 'en'));
169 $fileName = $enName; 171 $fileName = $enName;
170 $i=1; 172 $i=1;
171 - while($this->onlyName($enName.'.'.$nameArr[1],$project_id)){ 173 + while($this->onlyName($enName.'.'.$suffix,$project_id)){
172 $enName = $fileName .'-'.$i; 174 $enName = $fileName .'-'.$i;
173 $i++; 175 $i++;
174 } 176 }
175 - return $enName.'.'.$nameArr[1]; 177 + return $enName.'.'.$suffix;
176 } 178 }
177 179
178 /** 180 /**
@@ -224,15 +224,18 @@ class ImageController extends Controller @@ -224,15 +224,18 @@ class ImageController extends Controller
224 * @time :2024/4/26 16:10 224 * @time :2024/4/26 16:10
225 */ 225 */
226 public function getOnlyFilename($name,$project_id = 0){ 226 public function getOnlyFilename($name,$project_id = 0){
  227 +
227 $nameArr = explode('.',$name); 228 $nameArr = explode('.',$name);
228 - $enName = generateRoute(Translate::tran($nameArr[0], 'en')); 229 + $suffix = array_pop($nameArr) ?? 'jpg';
  230 + $nameStr = implode('-', $nameArr);
  231 + $enName = generateRoute(Translate::tran($nameStr, 'en'));
229 $fileName = $enName; 232 $fileName = $enName;
230 $i=1; 233 $i=1;
231 - while($this->onlyName($enName.'.'.$nameArr[1],$project_id)){ 234 + while($this->onlyName($enName.'.'.$suffix,$project_id)){
232 $enName = $fileName .'-'.$i; 235 $enName = $fileName .'-'.$i;
233 $i++; 236 $i++;
234 } 237 }
235 - return $enName.'.'.$nameArr[1]; 238 + return $enName.'.'.$suffix;
236 } 239 }
237 240
238 /** 241 /**
@@ -6,6 +6,7 @@ use App\Http\Logic\Aside\BaseLogic; @@ -6,6 +6,7 @@ use App\Http\Logic\Aside\BaseLogic;
6 use App\Models\RouteMap\RouteMap; 6 use App\Models\RouteMap\RouteMap;
7 use App\Models\Service\Service as ServiceSettingModel; 7 use App\Models\Service\Service as ServiceSettingModel;
8 use App\Models\Template\BTemplate; 8 use App\Models\Template\BTemplate;
  9 +use App\Models\Template\BTemplateCom;
9 use App\Models\Template\BTemplateCommon; 10 use App\Models\Template\BTemplateCommon;
10 use App\Models\Template\Template; 11 use App\Models\Template\Template;
11 use App\Models\Template\Setting; 12 use App\Models\Template\Setting;
@@ -203,25 +204,34 @@ class ATemplateLogic extends BaseLogic @@ -203,25 +204,34 @@ class ATemplateLogic extends BaseLogic
203 $templateInfo = $this->model->read(['id'=>$template_id]); 204 $templateInfo = $this->model->read(['id'=>$template_id]);
204 ProjectServer::useProject($project_id); 205 ProjectServer::useProject($project_id);
205 $bTemplateModel = new BTemplate(); 206 $bTemplateModel = new BTemplate();
206 - $info = $bTemplateModel->read(['source'=>1,'template_id'=>$template_id]); 207 + $info = $bTemplateModel->read(['source'=>BTemplate::SOURCE_HOME,'template_id'=>$template_id]);
207 if($info === false){ 208 if($info === false){
208 $data = [ 209 $data = [
209 - 'source'=>1, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],  
210 - 'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id, 210 + 'source'=>BTemplate::SOURCE_HOME, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],
  211 + 'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id
211 ]; 212 ];
212 $bTemplateModel->add($data); 213 $bTemplateModel->add($data);
213 } 214 }
214 - //保存一次公共头部信息  
215 - $bCommonTemplateModel = new BTemplateCommon();  
216 - $commonInfo = $bCommonTemplateModel->read(['template_id'=>$template_id,'type'=>1]);  
217 - if($commonInfo === false){  
218 - $commonData = [  
219 - 'type'=>1, 'template_id'=>$template_id, 'head_html'=>$templateInfo['head_html'],  
220 - 'head_css'=>$templateInfo['head_css'], 'footer_html'=>$templateInfo['footer_html'],  
221 - 'footer_css'=>$templateInfo['footer_css'],'project_id'=>$project_id,  
222 - 'other'=>str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"))  
223 - ];  
224 - $bCommonTemplateModel->add($commonData); 215 + //保存一次公共头部+底部+other信息
  216 + $bComTemplateModel = new BTemplateCom();
  217 + $condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_HEAD,'source'=>BTemplate::SOURCE_COM];
  218 + $headInfo = $bComTemplateModel->read($condition);
  219 + if($headInfo === false){
  220 + $headData = ['html'=>$templateInfo['head_html'], 'html_style'=>$templateInfo['head_css'], 'project_id'=>$project_id];
  221 + $bComTemplateModel->add(array_merge($condition,$headData));
  222 + }
  223 + $condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_FOOTER,'source'=>BTemplate::SOURCE_COM];
  224 + $footerInfo = $bComTemplateModel->read($condition);
  225 + if($footerInfo === false){
  226 + $footerData = ['html'=>$templateInfo['footer_html'], 'html_style'=>$templateInfo['footer_css'], 'project_id'=>$project_id];
  227 + $bComTemplateModel->add(array_merge($condition,$footerData));
  228 + }
  229 + $condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_OTHER,'source'=>BTemplate::SOURCE_COM];
  230 + $footerInfo = $bComTemplateModel->read($condition);
  231 + if($footerInfo === false){
  232 + $other = str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
  233 + $otherData = ['html'=>$other, 'html_style'=>'', 'project_id'=>$project_id];
  234 + $bComTemplateModel->add(array_merge($condition,$otherData));
225 } 235 }
226 RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $project_id); 236 RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $project_id);
227 DB::disconnect('custom_mysql'); 237 DB::disconnect('custom_mysql');
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ReplaceHtmlLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/8 10:03
  8 + */
  9 +
  10 +namespace App\Http\Logic\Aside\Template;
  11 +
  12 +use App\Http\Logic\aside\BaseLogic;
  13 +use App\Models\Template\BTemplate;
  14 +use App\Models\Template\TemplateReplaceHtml;
  15 +use App\Models\Template\TemplateReplaceHtmlLog;
  16 +use App\Services\ProjectServer;
  17 +use Illuminate\Support\Facades\DB;
  18 +
  19 +class ReplaceHtmlLogic extends BaseLogic
  20 +{
  21 + public function __construct()
  22 + {
  23 + parent::__construct();
  24 + $this->model = new TemplateReplaceHtml();
  25 + $this->param = $this->requestAll;
  26 + }
  27 +
  28 + /**
  29 + * @remark :替换可视化的html代码(按类型)
  30 + * @name :replaceHtml
  31 + * @author :lyh
  32 + * @method :post
  33 + * @time :2024/5/7 15:52
  34 + */
  35 + public function replaceHtml(){
  36 + ProjectServer::useProject($this->param['project_id']);
  37 + //TODO::生成一条任务记录
  38 + $replaceId = $this->saveReplaceHtml($this->param);
  39 + //查询当前类型所有装修的记录
  40 + $condition = ['source'=>$this->param['type'],'is_custom'=>$this->param['is_custom'],'is_list'=>$this->param['is_list'],
  41 + 'template_id'=>$this->param['template_id']];
  42 + $list = $this->model->list($condition);
  43 + foreach ($list as $v){
  44 + if($v['type'] == 0){
  45 + $main_html = str_replace($this->param['old_html'],$this->param['html'],$v['main_html']);
  46 + $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
  47 + }else{
  48 + $html = str_replace($this->param['old_html'],$this->param['html'],$v['html']);
  49 + $this->model->edit(['html'=>$html],['id'=>$v['id']]);
  50 + }
  51 + $this->saveReplaceHtmlLog($replaceId,$v['id']);
  52 + }
  53 + DB::disconnect('custom_mysql');
  54 + return $this->success();
  55 + }
  56 +
  57 + /**
  58 + * @remark :生成一条记录
  59 + * @name :saveTemplateLog
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2024/5/8 9:23
  63 + */
  64 + public function saveReplaceHtml($data,$template_id){
  65 + $logData = [
  66 + 'type'=>$data['type'],
  67 + 'is_custom'=>$data['is_custom'],
  68 + 'is_list'=>$data['is_list'],
  69 + 'template_id'=>$template_id,
  70 + 'old_html'=>$data['old_html'],
  71 + 'html'=>$data['html'],
  72 + ];
  73 + return $this->model->addReturnId($logData);
  74 + }
  75 +
  76 + /**
  77 + * @remark :保存每条替换记录
  78 + * @name :saveReplaceHtmlLog
  79 + * @author :lyh
  80 + * @method :post
  81 + * @time :2024/5/8 9:37
  82 + */
  83 + public function saveReplaceHtmlLog($replace_id,$replace_template_id){
  84 + $logData = [
  85 + 'replace_id'=>$replace_id,
  86 + 'replace_template_id'=>$replace_template_id,
  87 + 'uid'=>$this->user['manager_id'],
  88 + ];
  89 + $replaceHtmlModel = new TemplateReplaceHtmlLog();
  90 + return $replaceHtmlModel->add($logData);
  91 + }
  92 +
  93 + /**
  94 + * @remark :还原所有记录
  95 + * @name :reductionHtml
  96 + * @author :lyh
  97 + * @method :post
  98 + * @time :2024/5/8 10:35
  99 + */
  100 + public function reductionHtml(){
  101 + ProjectServer::useProject($this->param['project_id']);
  102 + //获取当前数据详情
  103 + $info = $this->model->read(['id'=>$this->param['id']]);
  104 + if($info === false){
  105 + $this->fail('当前数据不存在');
  106 + }
  107 + $replaceLogModel = new TemplateReplaceHtmlLog();
  108 + $logList = $replaceLogModel->list(['replace_id'=>$this->param['id']]);
  109 + $replaceArr = [];
  110 + foreach ($logList as $v){
  111 + $replaceArr[] = $v['replace_template_id'];
  112 + }
  113 + if(!empty($replaceArr)){
  114 + //查询可视化数据
  115 + $bTemplateModel = new BTemplate();
  116 + $templateList = $bTemplateModel->list(['id'=>['in',$replaceArr]]);
  117 + foreach ($templateList as $value){
  118 + if($v['type'] == 0){
  119 + $main_html = str_replace($info['html'],$info['old_html'],$value['main_html']);
  120 + $this->model->edit(['main_html'=>$main_html],['id'=>$v['id']]);
  121 + }else{
  122 + $html = str_replace($info['html'],$info['old_html'],$value['html']);
  123 + $this->model->edit(['html'=>$html],['id'=>$v['id']]);
  124 + }
  125 + }
  126 + }
  127 + DB::disconnect('custom_mysql');
  128 + return $this->success();
  129 + }
  130 +}
@@ -13,6 +13,7 @@ use App\Http\Logic\Bside\BaseLogic; @@ -13,6 +13,7 @@ use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\Project\PageSetting; 13 use App\Models\Project\PageSetting;
14 use App\Models\Service\Service as ServiceSettingModel; 14 use App\Models\Service\Service as ServiceSettingModel;
15 use App\Models\Template\BTemplate; 15 use App\Models\Template\BTemplate;
  16 +use App\Models\Template\BTemplateCom;
16 use App\Models\Template\BTemplateCommon; 17 use App\Models\Template\BTemplateCommon;
17 use App\Models\Template\BTemplateLog; 18 use App\Models\Template\BTemplateLog;
18 use App\Models\Template\Setting; 19 use App\Models\Template\Setting;
@@ -64,13 +65,14 @@ class BTemplateLogLogic extends BaseLogic @@ -64,13 +65,14 @@ class BTemplateLogLogic extends BaseLogic
64 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']]; 65 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
65 //TODO::还原头部+底部 66 //TODO::还原头部+底部
66 $bTemplateModel->edit(['html'=>$info['text']],$condition); 67 $bTemplateModel->edit(['html'=>$info['text']],$condition);
67 - $commonData = [  
68 - 'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'],  
69 - 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']  
70 - ];  
71 - $type = $this->getCustomizedType($info['source'],$info['is_list']);  
72 $commonTemplateModel = new BTemplateCommon(); 68 $commonTemplateModel = new BTemplateCommon();
73 - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]); 69 + //还原头部
  70 + $condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],
  71 + 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom'],'project_id'=>$this->user['project_id']];
  72 + $condition['common_type'] = BTemplate::COMMON_HEAD;
  73 + $commonTemplateModel->edit(['head'=>$info['head_html'], 'head_style'=>$info['head_css']],$condition);
  74 + $condition['common_type'] = BTemplate::COMMON_FOOTER;
  75 + $commonTemplateModel->edit(['footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']],$condition);
74 return $this->success(); 76 return $this->success();
75 } 77 }
76 78
@@ -99,18 +101,9 @@ class BTemplateLogLogic extends BaseLogic @@ -99,18 +101,9 @@ class BTemplateLogLogic extends BaseLogic
99 $bTemplateModel->edit($data,$condition); 101 $bTemplateModel->edit($data,$condition);
100 //还原头部+底部 102 //还原头部+底部
101 $commonData = [ 103 $commonData = [
102 - 'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css'] 104 + 'head_html'=>$info['head_html'], 'head_style'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_style'=>$info['footer_css'],'other'=>$info['other']
103 ]; 105 ];
104 - $commonTemplateModel = new BTemplateCommon();  
105 - $type = $this->getType($info['source'],$info['is_list'],$info['is_custom']);  
106 - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);  
107 - if(!empty($info['other'])){  
108 - $commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);  
109 - }else{  
110 - $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));  
111 - $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);  
112 - $commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$type]);  
113 - } 106 + $this->saveTemplateCom($commonData,$info['template_id'],$info['source'],$info['is_list'],$info['is_custom']);
114 }catch (\Exception $e){ 107 }catch (\Exception $e){
115 $this->fail('系统错误,请联系管理员'); 108 $this->fail('系统错误,请联系管理员');
116 } 109 }
@@ -118,36 +111,40 @@ class BTemplateLogLogic extends BaseLogic @@ -118,36 +111,40 @@ class BTemplateLogLogic extends BaseLogic
118 } 111 }
119 112
120 /** 113 /**
121 - * @remark :定制页面头部类型---根据source获取type类型  
122 - * @name :getType 114 + * @remark :保存公共部分(头部。底部。连接部分)
  115 + * @name :saveTemplateCom
123 * @author :lyh 116 * @author :lyh
124 * @method :post 117 * @method :post
125 - * @time :2023/11/16 11:20 118 + * @time :2024/4/29 10:32
126 */ 119 */
127 - public function getCustomizedType($source,$is_list){  
128 - $type = BTemplate::TYPE_HOME;  
129 - if($source == BTemplate::SOURCE_PRODUCT){  
130 - if($is_list == BTemplate::IS_LIST){  
131 - $type = BTemplate::TYPE_PRODUCT_LIST;  
132 - }else{  
133 - $type = BTemplate::TYPE_PRODUCT_DETAIL;  
134 - }  
135 - }  
136 - if($source == BTemplate::SOURCE_BLOG){  
137 - if($is_list == BTemplate::IS_LIST){  
138 - $type = BTemplate::TYPE_BLOG_LIST; 120 + public function saveTemplateCom($handleInfo,$template_id,$source,$is_list,$is_custom){
  121 + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
  122 + $templateComModel = new BTemplateCom();
  123 + foreach ($typeArr as $type){
  124 + if($type == BTemplate::COMMON_HEAD){
  125 + $param['html'] = $handleInfo['head_html'];
  126 + $param['html_style'] = $handleInfo['head_style'];
  127 + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
  128 + }elseif ($type == BTemplate::COMMON_FOOTER){
  129 + $param['html'] = $handleInfo['footer_html'];
  130 + $param['html_style'] = $handleInfo['footer_style'];
  131 + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
139 }else{ 132 }else{
140 - $type = BTemplate::TYPE_BLOG_DETAIL; 133 + $param['html'] = $handleInfo['other'];
  134 + $param['html_style'] = null;
  135 + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
141 } 136 }
142 - }  
143 - if($source == BTemplate::SOURCE_NEWS){  
144 - if($is_list == BTemplate::IS_LIST){  
145 - $type = BTemplate::TYPE_NEWS_LIST; 137 + //查看当前数据是否还存在
  138 + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
  139 + $info = $templateComModel->read($condition);
  140 + if($info === false){
  141 + $data = array_merge($param,$condition);
  142 + $templateComModel->add($data);
146 }else{ 143 }else{
147 - $type = BTemplate::TYPE_NEWS_DETAIL; 144 + $templateComModel->edit($param,$condition);
148 } 145 }
149 } 146 }
150 - return $type; 147 + return $this->success();
151 } 148 }
152 149
153 /** 150 /**
@@ -157,27 +154,30 @@ class BTemplateLogLogic extends BaseLogic @@ -157,27 +154,30 @@ class BTemplateLogLogic extends BaseLogic
157 * @method :post 154 * @method :post
158 * @time :2023/10/21 17:29 155 * @time :2023/10/21 17:29
159 */ 156 */
160 - public function getType($source,$is_list,$is_custom = 0){  
161 - $type = BTemplate::SOURCE_HOME;//首页公共头部底部 157 + public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$CommonType = BTemplate::COMMON_HEAD,$template_id = 0){
  158 + if($template_id == 0){//定制全为独立头部和底部
  159 + $type = $source;
  160 + return $this->success($type);
  161 + }
  162 + $type = BTemplate::SOURCE_COM;//公共头部底部
162 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; 163 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
163 - if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部 164 + if($is_custom == BTemplate::IS_CUSTOM || $is_head == BTemplate::IS_NO_HEADER){//拓展模块为首页头部
164 return $this->success($type); 165 return $this->success($type);
165 } 166 }
166 //查看页面是否设置自定义头部底部 167 //查看页面是否设置自定义头部底部
167 - if($is_head != BTemplate::IS_NO_HEADER) {  
168 $pageSettingModel = new PageSetting(); 168 $pageSettingModel = new PageSetting();
169 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); 169 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
170 if ($pageInfo === false) { 170 if ($pageInfo === false) {
171 return $this->success($type); 171 return $this->success($type);
172 } 172 }
173 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}  
174 - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}  
175 - if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}  
176 - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}  
177 - if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}  
178 - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}} 173 + if($source == BTemplate::SOURCE_HOME){if ($pageInfo['home'] != 0){$type = BTemplate::SOURCE_HOME;}}
  174 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}
  175 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}}
  176 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::SOURCE_BLOG;}}
  177 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::SOURCE_BLOG;}}}
  178 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::SOURCE_NEWS;}}
  179 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::SOURCE_NEWS;}}}
179 if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}} 180 if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
180 - }  
181 return $this->success($type); 181 return $this->success($type);
182 } 182 }
183 183
@@ -15,12 +15,15 @@ use App\Models\Project\PageSetting; @@ -15,12 +15,15 @@ use App\Models\Project\PageSetting;
15 use App\Models\Project\Project; 15 use App\Models\Project\Project;
16 use App\Models\RouteMap\RouteMap; 16 use App\Models\RouteMap\RouteMap;
17 use App\Models\Service\Service as ServiceSettingModel; 17 use App\Models\Service\Service as ServiceSettingModel;
  18 +use App\Models\Template\BTemplateCom;
18 use App\Models\Template\BTemplateCommon; 19 use App\Models\Template\BTemplateCommon;
19 use App\Models\Template\BTemplateMain; 20 use App\Models\Template\BTemplateMain;
20 use App\Models\Template\Setting; 21 use App\Models\Template\Setting;
21 use App\Models\Template\BTemplate; 22 use App\Models\Template\BTemplate;
22 use App\Models\Template\BTemplateLog; 23 use App\Models\Template\BTemplateLog;
23 use App\Models\Template\Template; 24 use App\Models\Template\Template;
  25 +use App\Models\Template\TemplateReplaceHtml;
  26 +use App\Models\Template\TemplateReplaceHtmlLog;
24 use App\Models\Template\TemplateTypeMain; 27 use App\Models\Template\TemplateTypeMain;
25 use Illuminate\Support\Facades\Cache; 28 use Illuminate\Support\Facades\Cache;
26 use Illuminate\Support\Facades\DB; 29 use Illuminate\Support\Facades\DB;
@@ -68,11 +71,11 @@ class BTemplateLogic extends BaseLogic @@ -68,11 +71,11 @@ class BTemplateLogic extends BaseLogic
68 $is_list = $this->param['is_list'] ?? 0;//是否为列表页 71 $is_list = $this->param['is_list'] ?? 0;//是否为列表页
69 $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id 72 $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
70 $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list); 73 $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
71 - if($templateInfo === false){ 74 + if($templateInfo === false){//todo::无装修数据处理
72 if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据 75 if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
73 - $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);  
74 - if($html !== false){  
75 - return $this->success($html); 76 + $data = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
  77 + if($data !== false){
  78 + return $this->success($data);
76 } 79 }
77 } 80 }
78 //非定制初始中间部分 81 //非定制初始中间部分
@@ -83,15 +86,87 @@ class BTemplateLogic extends BaseLogic @@ -83,15 +86,87 @@ class BTemplateLogic extends BaseLogic
83 } 86 }
84 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; 87 $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
85 } 88 }
86 - $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部  
87 - $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; 89 + $commonInfo = $this->getTemplateComHtml($this->param['source'],$is_list,$is_custom,$template_id);//获取非定制头部
  90 + $html = $commonInfo['head_style'].$mainInfo['main_css'].$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
88 $html = $this->getHeadFooter($html); 91 $html = $this->getHeadFooter($html);
89 $result = ['html'=>$html,'template_id'=>$template_id]; 92 $result = ['html'=>$html,'template_id'=>$template_id];
90 - if($templateInfo !== false) {$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];} 93 + if($templateInfo !== false) {
  94 + $result['id'] = $templateInfo['id'];
  95 + $result['updated_at'] = $templateInfo['updated_at'];
  96 + }
91 return $this->success($result); 97 return $this->success($result);
92 } 98 }
93 99
94 /** 100 /**
  101 + * @remark :非定制获取头部+底部
  102 + * @name :getTemplateComHtml
  103 + * @author :lyh
  104 + * @method :post
  105 + * @time :2024/4/29 16:53
  106 + */
  107 + public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
  108 + $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
  109 + $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
  110 + $bTemplateComModel = new BTemplateCom();
  111 + $condition['common_type'] = BTemplate::COMMON_OTHER;
  112 + $condition['source'] = $headComInfo['source'];
  113 + $otherInfo = $bTemplateComModel->read($condition);
  114 + if($otherInfo === false){
  115 + $this->fail('获取失败,请联系管理员');
  116 + }
  117 + $footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
  118 + $data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
  119 + 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
  120 + return $this->success($data);
  121 + }
  122 +
  123 + /**
  124 + * @remark :公共头部
  125 + * @name :HeadComHtml
  126 + * @author :lyh
  127 + * @method :post
  128 + * @time :2024/4/29 17:20
  129 + */
  130 + public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
  131 + $commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
  132 + $bTemplateComModel = new BTemplateCom();
  133 + $condition['source'] = $commonHead;
  134 + $condition['common_type'] = BTemplate::COMMON_HEAD;
  135 + $headComInfo = $bTemplateComModel->read($condition);
  136 + if($headComInfo === false){
  137 + //取默认公共的
  138 + $condition['source'] = BTemplate::SOURCE_COM;
  139 + $headComInfo = $bTemplateComModel->read($condition);
  140 + if($headComInfo === false){
  141 + $this->fail('获取失败,请联系管理员');
  142 + }
  143 + }
  144 + return $this->success($headComInfo);
  145 + }
  146 + /**
  147 + * @remark :公共底部
  148 + * @name :footerComHtml
  149 + * @author :lyh
  150 + * @method :post
  151 + * @time :2024/4/29 17:18
  152 + */
  153 + public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
  154 + $bTemplateComModel = new BTemplateCom();
  155 + $condition['common_type'] = BTemplate::COMMON_FOOTER;
  156 + $condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
  157 + $footerComInfo = $bTemplateComModel->read($condition);
  158 + if($footerComInfo === false){
  159 + //取默认首页的
  160 + $condition['source'] = BTemplate::SOURCE_COM;
  161 + $footerComInfo = $bTemplateComModel->read($condition);
  162 + if($footerComInfo === false){
  163 + $this->fail('获取失败,请联系管理员');
  164 + }
  165 + }
  166 + return $this->success($footerComInfo);
  167 + }
  168 +
  169 + /**
95 * @remark :获取整个html代码 170 * @remark :获取整个html代码
96 * @name :getCustomizeAllHtml 171 * @name :getCustomizeAllHtml
97 * @author :lyh 172 * @author :lyh
@@ -100,11 +175,11 @@ class BTemplateLogic extends BaseLogic @@ -100,11 +175,11 @@ class BTemplateLogic extends BaseLogic
100 */ 175 */
101 public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){ 176 public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
102 if($is_custom == BTemplate::IS_CUSTOM){ 177 if($is_custom == BTemplate::IS_CUSTOM){
103 - $commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部 178 + $commonInfo = $this->getCustomizeTemplateComHtml($templateInfo['source'],$is_custom,$is_list);//获取定制头部
104 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); 179 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
105 }else{ 180 }else{
106 - $type = $this->getCustomizedType($this->param['source'],$is_list);  
107 - $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 181 + $type = $this->getCustomizedType($templateInfo['source'],$is_list);
  182 + $commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
108 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); 183 $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
109 } 184 }
110 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]); 185 return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
@@ -174,7 +249,7 @@ class BTemplateLogic extends BaseLogic @@ -174,7 +249,7 @@ class BTemplateLogic extends BaseLogic
174 if($customHtmlInfo === false){ 249 if($customHtmlInfo === false){
175 $this->fail('定制页面,请先上传代码块'); 250 $this->fail('定制页面,请先上传代码块');
176 } 251 }
177 - $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部 252 + $commonInfo = $this->getCustomizeTemplateComHtml($source,$is_custom,$is_list);//获取定制头部
178 if($commonInfo !== false){ 253 if($commonInfo !== false){
179 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); 254 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
180 } 255 }
@@ -254,7 +329,7 @@ class BTemplateLogic extends BaseLogic @@ -254,7 +329,7 @@ class BTemplateLogic extends BaseLogic
254 if($customHtmlInfo === false){ 329 if($customHtmlInfo === false){
255 $this->fail('定制页面,请先上传代码块'); 330 $this->fail('定制页面,请先上传代码块');
256 } 331 }
257 - $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 332 + $commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
258 if($commonInfo !== false){ 333 if($commonInfo !== false){
259 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); 334 $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
260 } 335 }
@@ -263,6 +338,7 @@ class BTemplateLogic extends BaseLogic @@ -263,6 +338,7 @@ class BTemplateLogic extends BaseLogic
263 return false; 338 return false;
264 } 339 }
265 340
  341 +
266 /** 342 /**
267 * @remark :定制项目获取头部底部 343 * @remark :定制项目获取头部底部
268 * @name :getCustomizedCommonHtml 344 * @name :getCustomizedCommonHtml
@@ -270,49 +346,25 @@ class BTemplateLogic extends BaseLogic @@ -270,49 +346,25 @@ class BTemplateLogic extends BaseLogic
270 * @method :post 346 * @method :post
271 * @time :2023/12/29 13:13 347 * @time :2023/12/29 13:13
272 */ 348 */
273 - public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){  
274 - $data = [  
275 - 'template_id' => 0,  
276 - 'project_id' => $this->user['project_id'],  
277 - 'type'=>$type,  
278 - 'is_custom'=>$is_custom,  
279 - 'is_list'=>$is_list  
280 - ];  
281 - $commonTemplateModel = new BTemplateCommon();  
282 - return $commonTemplateModel->read($data);  
283 - }  
284 -  
285 - /**  
286 - * @remark :定制页面头部类型---根据source获取type类型  
287 - * @name :getType  
288 - * @author :lyh  
289 - * @method :post  
290 - * @time :2023/11/16 11:20  
291 - */  
292 - public function getCustomizedType($source,$is_list){  
293 - $type = BTemplate::TYPE_HOME;  
294 - if($source == BTemplate::SOURCE_PRODUCT){  
295 - if($is_list == BTemplate::IS_LIST){  
296 - $type = BTemplate::TYPE_PRODUCT_LIST; 349 + public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
  350 + $data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
  351 + $param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
  352 + $commonTemplateModel = new BTemplateCom();
  353 + $commonList = $commonTemplateModel->list($param);
  354 + if(!empty($commonList)){
  355 + foreach ($commonList as $v){
  356 + if($v['common_type'] == BTemplate::COMMON_HEAD){
  357 + $data['head_html'] = $v['html'];
  358 + $data['head_style'] = $v['html_style'];
  359 + }elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
  360 + $data['footer_html'] = $v['html'];
  361 + $data['footer_style'] = $v['html_style'];
297 }else{ 362 }else{
298 - $type = BTemplate::TYPE_PRODUCT_DETAIL; 363 + $data['other'] = $v['html'];
299 } 364 }
300 } 365 }
301 - if($source == BTemplate::SOURCE_BLOG){  
302 - if($is_list == BTemplate::IS_LIST){  
303 - $type = BTemplate::TYPE_BLOG_LIST;  
304 - }else{  
305 - $type = BTemplate::TYPE_BLOG_DETAIL;  
306 - }  
307 - }  
308 - if($source == BTemplate::SOURCE_NEWS){  
309 - if($is_list == BTemplate::IS_LIST){  
310 - $type = BTemplate::TYPE_NEWS_LIST;  
311 - }else{  
312 - $type = BTemplate::TYPE_NEWS_DETAIL;  
313 - }  
314 } 366 }
315 - return $type; 367 + return $this->success($data);
316 } 368 }
317 369
318 /** 370 /**
@@ -351,38 +403,10 @@ class BTemplateLogic extends BaseLogic @@ -351,38 +403,10 @@ class BTemplateLogic extends BaseLogic
351 if($info === false){ 403 if($info === false){
352 $this->fail('请先选择模版'); 404 $this->fail('请先选择模版');
353 } 405 }
354 - $template_id = $info['template_id'];  
355 - return $this->success($template_id); 406 + return $this->success($info['template_id']);
356 } 407 }
357 408
358 /** 409 /**
359 - * @remark :根据类型获取公共头和底  
360 - * @name :getCommonPage  
361 - * @author :lyh  
362 - * @method :post  
363 - * @time :2023/10/21 16:55  
364 - */  
365 - public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){  
366 - $type = $this->getType($source,$is_list,$is_custom);  
367 - $data = [  
368 - 'template_id' => $template_id,  
369 - 'project_id' => $this->user['project_id'],  
370 - 'type'=>$type,  
371 - 'is_custom'=>0,  
372 - ];  
373 - $commonTemplateModel = new BTemplateCommon();  
374 - $commonInfo = $commonTemplateModel->read($data);  
375 - if($commonInfo === false){  
376 - $data['type'] = BTemplate::SOURCE_HOME;  
377 - $commonInfo = $commonTemplateModel->read($data);  
378 - }  
379 - return $this->success($commonInfo);  
380 - }  
381 -  
382 -  
383 -  
384 -  
385 - /**  
386 * @remark :保存修改后的模版 410 * @remark :保存修改后的模版
387 * @name :templateSave 411 * @name :templateSave
388 * @author :lyh 412 * @author :lyh
@@ -409,14 +433,12 @@ class BTemplateLogic extends BaseLogic @@ -409,14 +433,12 @@ class BTemplateLogic extends BaseLogic
409 'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'], 433 'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
410 'is_list'=>$this->param['is_list'] 434 'is_list'=>$this->param['is_list']
411 ]; 435 ];
412 - $data = [  
413 - 'section_list_id'=>$this->param['section_list_id']  
414 - ]; 436 + $data = ['section_list_id'=>$this->param['section_list_id']];
415 $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data); 437 $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
416 $this->model->edit($data,$condition); 438 $this->model->edit($data,$condition);
417 } 439 }
418 //更新头部信息 440 //更新头部信息
419 - $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']); 441 + $this->saveTemplateCom($this->param['html'],$this->param['template_id'],$this->param['source'],$this->param['is_list'],$this->param['is_custom']);
420 $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']); 442 $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
421 //通知更新 443 //通知更新
422 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']); 444 $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
@@ -446,14 +468,6 @@ class BTemplateLogic extends BaseLogic @@ -446,14 +468,6 @@ class BTemplateLogic extends BaseLogic
446 * @time :2023/12/15 10:59 468 * @time :2023/12/15 10:59
447 */ 469 */
448 public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){ 470 public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){
449 - if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目  
450 - $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型  
451 - //查看当前页面是否定制,是否开启可视化  
452 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面  
453 - if (in_array($type, $page_array)) {//当前页面是定制界面  
454 - $data['html'] = $html;  
455 - $data['type'] = BTemplate::ALL_HTML;  
456 - }else{  
457 //TODO::扩展模块定制单独处理 471 //TODO::扩展模块定制单独处理
458 if($is_custom == BTemplate::IS_CUSTOM){ 472 if($is_custom == BTemplate::IS_CUSTOM){
459 $customModuleModel = new CustomModule(); 473 $customModuleModel = new CustomModule();
@@ -465,100 +479,59 @@ class BTemplateLogic extends BaseLogic @@ -465,100 +479,59 @@ class BTemplateLogic extends BaseLogic
465 if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) { 479 if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
466 $data['html'] = $html; 480 $data['html'] = $html;
467 $data['type'] = BTemplate::ALL_HTML; 481 $data['type'] = BTemplate::ALL_HTML;
  482 + return $this->success($data);
468 } 483 }
469 } 484 }
470 - $mainInfo = $this->handleTemplateHtml($html);  
471 - $data['main_html'] = $mainInfo['main_html'];  
472 - $data['main_css'] = $mainInfo['main_css']; 485 + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){
  486 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
  487 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  488 + if(in_array($type, $page_array)){
  489 + $data['html'] = $html;
  490 + $data['type'] = BTemplate::ALL_HTML;
  491 + return $this->success($data);
473 } 492 }
474 - }else{  
475 - $mainInfo = $this->handleTemplateHtml($html);  
476 - $data['main_html'] = $mainInfo['main_html'];  
477 - $data['main_css'] = $mainInfo['main_css'];  
478 } 493 }
479 - return $data; 494 + $data['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
  495 + $data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  496 + return $this->success($data);
480 } 497 }
481 498
482 /** 499 /**
483 - * @remark :保存公共头部底部  
484 - * @name :saveCommonHtml 500 + * @remark :保存公共部分(头部。底部。连接部分)
  501 + * @name :saveTemplateCom
485 * @author :lyh 502 * @author :lyh
486 * @method :post 503 * @method :post
487 - * @time :2023/12/13 17:05 504 + * @time :2024/4/29 10:32
488 */ 505 */
489 - public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){  
490 - //TODO::定制扩展模块单独处理  
491 - if($is_custom == BTemplate::IS_CUSTOM){  
492 - $code = $this->saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id);  
493 - if($code === false){  
494 - return $this->success();  
495 - }  
496 - }  
497 - //其他情况  
498 - $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)  
499 - if($template_id == 0){//定制页面默认为独立头部  
500 - $type = $this->getCustomizedType($source,$is_list);//定制默认独立头部  
501 - }  
502 - $templateCommonModel = new BTemplateCommon();  
503 - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>0]);//查看当前头部是否存在 506 + public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
  507 + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
504 $handleInfo = $this->handleCommonParam($html); 508 $handleInfo = $this->handleCommonParam($html);
505 - if($commonInfo === false){  
506 - $data = [  
507 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],  
508 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
509 - 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],  
510 - ];  
511 - $templateCommonModel->add($data); 509 + $templateComModel = new BTemplateCom();
  510 + foreach ($typeArr as $type){
  511 + if($type == BTemplate::COMMON_HEAD){
  512 + $param['html'] = $handleInfo['head_html'];
  513 + $param['html_style'] = $handleInfo['head_style'];
  514 + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
  515 + }elseif ($type == BTemplate::COMMON_FOOTER){
  516 + $param['html'] = $handleInfo['footer_html'];
  517 + $param['html_style'] = $handleInfo['footer_style'];
  518 + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
512 }else{ 519 }else{
513 - $data = [  
514 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],  
515 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
516 - ];  
517 - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);  
518 - }  
519 - //更新所有界面的other  
520 - if($template_id != 0){  
521 - return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);  
522 - } 520 + $param['html'] = $handleInfo['other'];
  521 + $param['html_style'] = null;
  522 + $typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
523 } 523 }
524 -  
525 - /**  
526 - * @remark :扩展模块定制保存头部处理  
527 - * @name :saveCustomModuleCommonHtml  
528 - * @author :lyh  
529 - * @method :post  
530 - * @time :2024/1/10 11:33  
531 - */  
532 - public function saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id){  
533 - $customModuleModel = new CustomModule();  
534 - $info = $customModuleModel->read(['id'=>$source]); 524 + //查看当前数据是否还存在
  525 + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
  526 + $info = $templateComModel->read($condition);
535 if($info === false){ 527 if($info === false){
536 - $this->fail('当前扩展模块不存在或已被删除');  
537 - }  
538 - //todo::扩展模块(列表页/详情页)定制  
539 - if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {  
540 - $data = ['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list,'template_id'=>$template_id];  
541 - $templateCommonModel = new BTemplateCommon();  
542 - $commonInfo = $templateCommonModel->read($data);//查看当前头部是否存在  
543 - $handleInfo = $this->handleCommonParam($html);  
544 - if($commonInfo === false){  
545 - $data = [  
546 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],  
547 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
548 - 'type'=>$source,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],  
549 - 'is_custom'=>$is_custom,'is_list'=>$is_list,  
550 - ];  
551 - $templateCommonModel->add($data); 528 + $data = array_merge($param,$condition);
  529 + $templateComModel->add($data);
552 }else{ 530 }else{
553 - $data = [  
554 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],  
555 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
556 - ];  
557 - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); 531 + $templateComModel->edit($param,$condition);
558 } 532 }
559 - return false;  
560 } 533 }
561 - return true; 534 + return $this->success();
562 } 535 }
563 536
564 /** 537 /**
@@ -587,55 +560,43 @@ class BTemplateLogic extends BaseLogic @@ -587,55 +560,43 @@ class BTemplateLogic extends BaseLogic
587 //字符串截取 560 //字符串截取
588 $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); 561 $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
589 $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); 562 $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
590 - $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');  
591 - $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); 563 + $param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
  564 + $param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
592 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); 565 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
593 $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); 566 $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
594 return $this->success($param); 567 return $this->success($param);
595 } 568 }
596 569
597 /** 570 /**
598 - * @remark :保存时字符串处理  
599 - * @name :handleSaveParam  
600 - * @author :lyh  
601 - * @method :post  
602 - * @time :2023/6/29 15:35  
603 - */  
604 - public function handleTemplateHtml($html){  
605 - //字符串截取  
606 - $param['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');  
607 - $param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');  
608 - return $this->success($param);  
609 - }  
610 -  
611 - /**  
612 * @remark :(非定制)保存时获取获取设置的类型 571 * @remark :(非定制)保存时获取获取设置的类型
613 * @name :getType 572 * @name :getType
614 * @author :lyh 573 * @author :lyh
615 * @method :post 574 * @method :post
616 * @time :2023/10/21 17:29 575 * @time :2023/10/21 17:29
617 */ 576 */
618 - public function getType($source,$is_list,$is_custom = 0){  
619 - $type = BTemplate::SOURCE_HOME;//首页公共头部底部 577 + public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$CommonType = BTemplate::COMMON_HEAD,$template_id = 0){
  578 + if($template_id == 0){
  579 + return $this->success($source);
  580 + }
  581 + $type = BTemplate::SOURCE_COM;//公共头部底部
620 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; 582 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
621 - if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部 583 + if($is_custom == BTemplate::IS_CUSTOM || $is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底
622 return $this->success($type); 584 return $this->success($type);
623 } 585 }
624 //查看页面是否设置自定义头部底部 586 //查看页面是否设置自定义头部底部
625 - if($is_head != BTemplate::IS_NO_HEADER) {  
626 $pageSettingModel = new PageSetting(); 587 $pageSettingModel = new PageSetting();
627 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); 588 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
628 if ($pageInfo === false) { 589 if ($pageInfo === false) {
629 return $this->success($type); 590 return $this->success($type);
630 } 591 }
631 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}  
632 - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}  
633 - if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}  
634 - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}  
635 - if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}  
636 - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}  
637 - if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}  
638 - } 592 + if($source == BTemplate::SOURCE_HOME){if ($pageInfo['home'] != 0){$type = BTemplate::SOURCE_HOME;}}
  593 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}
  594 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}}
  595 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::SOURCE_BLOG;}}
  596 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::SOURCE_BLOG;}}}
  597 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::SOURCE_NEWS;}}
  598 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::SOURCE_NEWS;}}}
  599 + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::SOURCE_KEYWORD;}}
639 return $this->success($type); 600 return $this->success($type);
640 } 601 }
641 602
@@ -7,6 +7,7 @@ use App\Models\Project\PageSetting; @@ -7,6 +7,7 @@ use App\Models\Project\PageSetting;
7 use App\Models\RouteMap\RouteMap; 7 use App\Models\RouteMap\RouteMap;
8 use App\Models\Service\Service as ServiceSettingModel; 8 use App\Models\Service\Service as ServiceSettingModel;
9 use App\Models\Template\BCustomTemplate; 9 use App\Models\Template\BCustomTemplate;
  10 +use App\Models\Template\BTemplateCom;
10 use App\Models\Template\BTemplateCommon; 11 use App\Models\Template\BTemplateCommon;
11 use App\Models\Template\BTemplateLog; 12 use App\Models\Template\BTemplateLog;
12 use App\Models\Template\Setting; 13 use App\Models\Template\Setting;
@@ -49,13 +50,81 @@ class CustomTemplateLogic extends BaseLogic @@ -49,13 +50,81 @@ class CustomTemplateLogic extends BaseLogic
49 $this->fail('当前数据不存在'); 50 $this->fail('当前数据不存在');
50 } 51 }
51 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ 52 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
52 - $html = $this->getBodyHeaderFooter($info['html'],$info['html_style']); 53 + $html = $this->getTemplateComHtml($info['html'],$info['html_style']);
53 $info['html'] = $this->getHeadFooter($html); 54 $info['html'] = $this->getHeadFooter($html);
54 } 55 }
55 return $this->success($info); 56 return $this->success($info);
56 } 57 }
57 58
58 /** 59 /**
  60 + * @remark :非定制获取头部+底部
  61 + * @name :getTemplateComHtml
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2024/4/29 16:53
  65 + */
  66 + public function getTemplateComHtml($html,$html_style){
  67 + $headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD]);
  68 + $bTemplateComModel = new BTemplateCom();
  69 + $condition['common_type'] = BTemplate::COMMON_OTHER;
  70 + $condition['source'] = $headComInfo['source'];
  71 + $otherInfo = $bTemplateComModel->read($condition);
  72 + if($otherInfo === false){
  73 + $this->fail('获取失败,请联系管理员');
  74 + }
  75 + $footerComInfo = $this->getFooterComHtml();
  76 + $commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
  77 + 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
  78 + $html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html'];
  79 + return $this->success($html);
  80 + }
  81 +
  82 + /**
  83 + * @remark :公共头部
  84 + * @name :HeadComHtml
  85 + * @author :lyh
  86 + * @method :post
  87 + * @time :2024/4/29 17:20
  88 + */
  89 + public function getHeadComHtml($condition){
  90 + $bTemplateComModel = new BTemplateCom();
  91 + $condition['source'] = $this->getType();
  92 + $condition['common_type'] = BTemplate::COMMON_HEAD;
  93 + $headComInfo = $bTemplateComModel->read($condition);
  94 + if($headComInfo === false){
  95 + //取默认公共的
  96 + $condition['source'] = BTemplate::SOURCE_COM;
  97 + $headComInfo = $bTemplateComModel->read($condition);
  98 + if($headComInfo === false){
  99 + $this->fail('获取失败,请联系管理员');
  100 + }
  101 + }
  102 + return $this->success($headComInfo);
  103 + }
  104 + /**
  105 + * @remark :公共底部
  106 + * @name :footerComHtml
  107 + * @author :lyh
  108 + * @method :post
  109 + * @time :2024/4/29 17:18
  110 + */
  111 + public function getFooterComHtml(){
  112 + $bTemplateComModel = new BTemplateCom();
  113 + $condition['common_type'] = BTemplate::COMMON_FOOTER;
  114 + $condition['source'] = $this->getType(BTemplate::COMMON_FOOTER);
  115 + $footerComInfo = $bTemplateComModel->read($condition);
  116 + if($footerComInfo === false){
  117 + //取默认首页的
  118 + $condition['source'] = BTemplate::SOURCE_COM;
  119 + $footerComInfo = $bTemplateComModel->read($condition);
  120 + if($footerComInfo === false){
  121 + $this->fail('获取失败,请联系管理员');
  122 + }
  123 + }
  124 + return $this->success($footerComInfo);
  125 + }
  126 +
  127 + /**
59 * @remark :保存自定义界面 128 * @remark :保存自定义界面
60 * @name :customTemplateSave 129 * @name :customTemplateSave
61 * @author :lyh 130 * @author :lyh
@@ -108,15 +177,16 @@ class CustomTemplateLogic extends BaseLogic @@ -108,15 +177,16 @@ class CustomTemplateLogic extends BaseLogic
108 if($bSettingInfo === false){ 177 if($bSettingInfo === false){
109 $this->fail('请先选择模版'); 178 $this->fail('请先选择模版');
110 } 179 }
111 - $this->saveCommonTemplate($html,$bSettingInfo['template_id']);  
112 - $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');  
113 - $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); 180 + $handleInfo = $this->handleResultParam($html);
  181 + $this->saveTemplateCom($handleInfo,$bSettingInfo['template_id']);
  182 + $this->param['html'] = $handleInfo['main_html'];
  183 + $this->param['html_style'] = $handleInfo['main_style'];
114 } 184 }
115 $rs = $this->model->edit($this->param,['id'=>$this->param['id'],'project_id'=>$this->user['project_id']]); 185 $rs = $this->model->edit($this->param,['id'=>$this->param['id'],'project_id'=>$this->user['project_id']]);
116 if($rs === false){ 186 if($rs === false){
117 $this->fail('系统错误,请联系管理'); 187 $this->fail('系统错误,请联系管理');
118 } 188 }
119 - $this->setTemplateLog($bSettingInfo['template_id'],$html,$this->param['id']); 189 + $this->setTemplateLog($bSettingInfo['template_id'],$handleInfo,$this->param['id']);
120 //通知 190 //通知
121 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']); 191 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']);
122 $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$info['url']]); 192 $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$info['url']]);
@@ -131,6 +201,7 @@ class CustomTemplateLogic extends BaseLogic @@ -131,6 +201,7 @@ class CustomTemplateLogic extends BaseLogic
131 * @time :2023/8/23 11:16 201 * @time :2023/8/23 11:16
132 */ 202 */
133 public function setTemplateLog($template_id,$html,$source_id){ 203 public function setTemplateLog($template_id,$html,$source_id){
  204 + $handleInfo = $this->handleResultParam($html);
134 $data = [ 205 $data = [
135 'template_id'=>$template_id, 206 'template_id'=>$template_id,
136 'project_id'=>$this->user['project_id'], 207 'project_id'=>$this->user['project_id'],
@@ -138,71 +209,99 @@ class CustomTemplateLogic extends BaseLogic @@ -138,71 +209,99 @@ class CustomTemplateLogic extends BaseLogic
138 'text'=>$html, 209 'text'=>$html,
139 'source'=>9, 210 'source'=>9,
140 'source_id'=>$source_id, 211 'source_id'=>$source_id,
141 - 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),  
142 - 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),  
143 - 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),  
144 - 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),  
145 - 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),  
146 - 'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'), 212 + 'head_html'=>$handleInfo['head_html'],
  213 + 'head_css'=>$handleInfo['head_style'],
  214 + 'footer_html'=>$handleInfo['footer_html'],
  215 + 'footer_css'=>$handleInfo['footer_style'],
  216 + 'main_html' => $handleInfo['main_html'],
  217 + 'main_css' => $handleInfo['main_style'],
  218 + 'other'=>$handleInfo['other']
147 ]; 219 ];
148 - $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));  
149 - $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);  
150 $bTemplateLogModel = new BTemplateLog(); 220 $bTemplateLogModel = new BTemplateLog();
151 return $bTemplateLogModel->add($data); 221 return $bTemplateLogModel->add($data);
152 } 222 }
153 223
154 /** 224 /**
155 - * @remark :保存头部公共数据  
156 - * @name :saveCommonTemplate 225 + * @remark :截取数据返回
  226 + * @name :handleResultParam
157 * @author :lyh 227 * @author :lyh
158 * @method :post 228 * @method :post
159 - * @time :2023/10/13 14:27 229 + * @time :2024/5/6 14:14
160 */ 230 */
161 - public function saveCommonTemplate($html,$template_id){  
162 - $type = $this->getType();  
163 - $templateCommonModel = new BTemplateCommon();  
164 - $info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);  
165 - $data = [ 231 + public function handleResultParam($html){
  232 + $handleInfo = [
166 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), 233 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
167 - 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), 234 + 'head_style'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
168 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), 235 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
169 - 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), 236 + 'footer_style'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
  237 + 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
  238 + 'main_style' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
170 ]; 239 ];
171 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); 240 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
172 $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); 241 $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
  242 + $handleInfo['other'] = $other;
  243 + return $this->success($handleInfo);
  244 + }
  245 +
  246 + /**
  247 + * @remark :保存公共部分(头部。底部。连接部分)
  248 + * @name :saveTemplateCom
  249 + * @author :lyh
  250 + * @method :post
  251 + * @time :2024/4/29 10:32
  252 + */
  253 + public function saveTemplateCom($handleInfo,$template_id){
  254 + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
  255 + $templateComModel = new BTemplateCom();
  256 + foreach ($typeArr as $type){
  257 + if($type == BTemplate::COMMON_HEAD){
  258 + $param['html'] = $handleInfo['head_html'];
  259 + $param['html_style'] = $handleInfo['head_style'];
  260 + $typeSource = $this->getType($type);//头部是否为独立头部
  261 + }elseif ($type == BTemplate::COMMON_FOOTER){
  262 + $param['html'] = $handleInfo['footer_html'];
  263 + $param['html_style'] = $handleInfo['footer_style'];
  264 + $typeSource = $this->getType($type);
  265 + }else{
  266 + $param['html'] = $handleInfo['other'];
  267 + $param['html_style'] = null;
  268 + $type == BTemplate::COMMON_HEAD;
  269 + $typeSource = $this->getType($type);
  270 + }
  271 + //查看当前数据是否还存在
  272 + $condition = ['template_id'=>$template_id,'source'=>$typeSource,'common_type'=>$type];
  273 + $info = $templateComModel->read($condition);
173 if($info === false){ 274 if($info === false){
174 - $data['template_id'] = $template_id;  
175 - $data['project_id'] = $this->user['project_id'];  
176 - $data['type'] = $type;  
177 - $templateCommonModel->add($data); 275 + $data = array_merge($param,$condition);
  276 + $rs = $templateComModel->add($data);
178 }else{ 277 }else{
179 - $templateCommonModel->edit($data,['id'=>$info['id']]); 278 + $rs = $templateComModel->edit($param,$condition);
  279 + }
  280 + if($rs === false){
  281 + $this->fail('保存错误,请联系管理员');
  282 + }
180 } 283 }
181 - //更新所有界面的other  
182 - $templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]);  
183 return $this->success(); 284 return $this->success();
184 } 285 }
185 286
186 /** 287 /**
187 - * @remark :获取设置的类型 288 + * @remark :(非定制)保存时获取获取设置的类型
188 * @name :getType 289 * @name :getType
189 * @author :lyh 290 * @author :lyh
190 * @method :post 291 * @method :post
191 * @time :2023/10/21 17:29 292 * @time :2023/10/21 17:29
192 */ 293 */
193 - public function getType(){  
194 - $type = 1;//首页公共头部底部 294 + public function getType($CommonType = BTemplate::COMMON_HEAD){
  295 + $type = BTemplate::SOURCE_COM;//公共头部底部
  296 + $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
  297 + if($is_head == BTemplate::IS_NO_HEADER){
  298 + return $this->success($type);
  299 + }
195 //查看页面是否设置自定义头部底部 300 //查看页面是否设置自定义头部底部
196 - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {  
197 $pageSettingModel = new PageSetting(); 301 $pageSettingModel = new PageSetting();
198 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);  
199 - if ($pageInfo !== false) {  
200 - if ($pageInfo['page_list'] != 0) {  
201 - $type = 9;  
202 - }  
203 - }  
204 - }  
205 - return $type; 302 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
  303 + if ($pageInfo !== false) {if ($pageInfo['page_list'] != 0) {$type = 9;}}
  304 + return $this->success($type);
206 } 305 }
207 306
208 /** 307 /**
@@ -288,7 +387,7 @@ class CustomTemplateLogic extends BaseLogic @@ -288,7 +387,7 @@ class CustomTemplateLogic extends BaseLogic
288 $this->fail('请先设置模版'); 387 $this->fail('请先设置模版');
289 } 388 }
290 //获取type类型 389 //获取type类型
291 - $commonInfo = $this->getCommonPage($info['template_id']); 390 + $commonInfo = $this->getType();
292 $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other']. 391 $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
293 $commonInfo['head_html'].$preg_html.$commonInfo['footer_html']; 392 $commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
294 return $this->success($html); 393 return $this->success($html);
@@ -395,7 +494,44 @@ class CustomTemplateLogic extends BaseLogic @@ -395,7 +494,44 @@ class CustomTemplateLogic extends BaseLogic
395 }else{ 494 }else{
396 $this->model->edit(['html'=>$logInfo['text']],['id'=>$logInfo['source_id']]); 495 $this->model->edit(['html'=>$logInfo['text']],['id'=>$logInfo['source_id']]);
397 } 496 }
398 -  
399 return $this->success(); 497 return $this->success();
400 } 498 }
  499 +
  500 + /**
  501 + * @remark :复制单页面
  502 + * @name :copyCustomTemplateInfo
  503 + * @author :lyh
  504 + * @method :post
  505 + * @time :2024/4/28 16:16
  506 + */
  507 + public function copyCustomTemplateInfo(){
  508 + $info = $this->model->read(['id'=>$this->param['id']]);
  509 + $param = $this->setCustomTemplateParams($info);
  510 + $save_id = $this->model->insertGetId($param);
  511 + $route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);
  512 + $this->model->edit(['route'=>$route],['id'=>$save_id]);
  513 + return $this->success(['id'=>$save_id]);
  514 + }
  515 +
  516 + /**
  517 + * @remark :组装数据
  518 + * @name :setCustomTemplateParams
  519 + * @author :lyh
  520 + * @method :post
  521 + * @time :2024/4/28 16:18
  522 + */
  523 + public function setCustomTemplateParams($info){
  524 + return [
  525 + 'name'=>$info['name'].'-copy',
  526 + 'status'=>$info['status'],
  527 + 'url'=>$info['url'],
  528 + 'html'=>$info['html'],
  529 + 'html_style'=>$info['html_style'],
  530 + 'project_id'=>$info['project_id'],
  531 + 'section_list_id'=>$info['section_list_id'],
  532 + 'is_visualization'=>$info['is_visualization'],
  533 + 'created_at'=>date('Y-m-d H:i:s'),
  534 + 'updated_at'=>date('Y-m-d H:i:s'),
  535 + ];
  536 + }
401 } 537 }
@@ -14,6 +14,7 @@ use App\Models\Project\PageSetting; @@ -14,6 +14,7 @@ use App\Models\Project\PageSetting;
14 use App\Models\RouteMap\RouteMap; 14 use App\Models\RouteMap\RouteMap;
15 use App\Models\Service\Service as ServiceSettingModel; 15 use App\Models\Service\Service as ServiceSettingModel;
16 use App\Models\Template\BTemplate; 16 use App\Models\Template\BTemplate;
  17 +use App\Models\Template\BTemplateCom;
17 use App\Models\Template\BTemplateCommon; 18 use App\Models\Template\BTemplateCommon;
18 use App\Models\Template\BTemplateMain; 19 use App\Models\Template\BTemplateMain;
19 use App\Models\Template\Setting; 20 use App\Models\Template\Setting;
@@ -51,14 +52,83 @@ class InitHtmlLogic extends BaseLogic @@ -51,14 +52,83 @@ class InitHtmlLogic extends BaseLogic
51 $data['id'] = $mainInfo['id']; 52 $data['id'] = $mainInfo['id'];
52 $data['updated_at'] = $mainInfo['updated_at']; 53 $data['updated_at'] = $mainInfo['updated_at'];
53 } 54 }
54 - $commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部  
55 - $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; 55 + $commonInfo = $this->getTemplateComHtml($this->param['type'],$is_list,$is_custom,$template_id); //获取头部
  56 + $html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
56 $html = $this->getHeadFooter($html);//组装数据 57 $html = $this->getHeadFooter($html);//组装数据
57 $data['html'] = $html; 58 $data['html'] = $html;
58 return $this->success($data); 59 return $this->success($data);
59 } 60 }
60 61
61 /** 62 /**
  63 + * @remark :非定制获取头部+底部
  64 + * @name :getTemplateComHtml
  65 + * @author :lyh
  66 + * @method :post
  67 + * @time :2024/4/29 16:53
  68 + */
  69 + public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
  70 + $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
  71 + $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
  72 + $bTemplateComModel = new BTemplateCom();
  73 + $condition['common_type'] = BTemplate::COMMON_OTHER;
  74 + $condition['source'] = $headComInfo['source'];
  75 + $otherInfo = $bTemplateComModel->read($condition);
  76 + if($otherInfo === false){
  77 + $this->fail('获取失败,请联系管理员');
  78 + }
  79 + $footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
  80 + $data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
  81 + 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
  82 + return $this->success($data);
  83 + }
  84 +
  85 + /**
  86 + * @remark :公共头部
  87 + * @name :HeadComHtml
  88 + * @author :lyh
  89 + * @method :post
  90 + * @time :2024/4/29 17:20
  91 + */
  92 + public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
  93 + $commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
  94 + $bTemplateComModel = new BTemplateCom();
  95 + $condition['source'] = $commonHead;
  96 + $condition['common_type'] = BTemplate::COMMON_HEAD;
  97 + $headComInfo = $bTemplateComModel->read($condition);
  98 + if($headComInfo === false){
  99 + //取默认公共的
  100 + $condition['source'] = BTemplate::SOURCE_COM;
  101 + $headComInfo = $bTemplateComModel->read($condition);
  102 + if($headComInfo === false){
  103 + $this->fail('获取失败,请联系管理员');
  104 + }
  105 + }
  106 + return $this->success($headComInfo);
  107 + }
  108 + /**
  109 + * @remark :公共底部
  110 + * @name :footerComHtml
  111 + * @author :lyh
  112 + * @method :post
  113 + * @time :2024/4/29 17:18
  114 + */
  115 + public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
  116 + $bTemplateComModel = new BTemplateCom();
  117 + $condition['common_type'] = BTemplate::COMMON_FOOTER;
  118 + $condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
  119 + $footerComInfo = $bTemplateComModel->read($condition);
  120 + if($footerComInfo === false){
  121 + //取默认首页的
  122 + $condition['source'] = BTemplate::SOURCE_COM;
  123 + $footerComInfo = $bTemplateComModel->read($condition);
  124 + if($footerComInfo === false){
  125 + $this->fail('获取失败,请联系管理员');
  126 + }
  127 + }
  128 + return $this->success($footerComInfo);
  129 + }
  130 +
  131 + /**
62 * @remark :拼接获取公共头部底部 132 * @remark :拼接获取公共头部底部
63 * @name :getHeadFooter 133 * @name :getHeadFooter
64 * @author :lyh 134 * @author :lyh
@@ -114,93 +184,80 @@ class InitHtmlLogic extends BaseLogic @@ -114,93 +184,80 @@ class InitHtmlLogic extends BaseLogic
114 ]; 184 ];
115 $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); 185 $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
116 } 186 }
117 - $this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom); 187 + $this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom);
118 $route = RouteMap::getRoute('all',0,$this->user['project_id']); 188 $route = RouteMap::getRoute('all',0,$this->user['project_id']);
119 $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); 189 $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
120 return $this->success(); 190 return $this->success();
121 } 191 }
122 192
123 /** 193 /**
124 - * @remark :保存公共头部底部  
125 - * @name :saveCommonHtml 194 + * @remark :保存公共部分(头部。底部。连接部分)
  195 + * @name :saveTemplateCom
126 * @author :lyh 196 * @author :lyh
127 * @method :post 197 * @method :post
128 - * @time :2023/12/13 17:05 198 + * @time :2024/4/29 10:32
129 */ 199 */
130 - public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){  
131 - $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)  
132 - $templateCommonModel = new BTemplateCommon();  
133 - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在 200 + public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
  201 + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
134 $handleInfo = $this->handleCommonParam($html); 202 $handleInfo = $this->handleCommonParam($html);
135 - if($commonInfo === false){  
136 - $data = [  
137 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],  
138 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
139 - 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],  
140 - ];  
141 - $templateCommonModel->add($data); 203 + $templateComModel = new BTemplateCom();
  204 + foreach ($typeArr as $type){
  205 + if($type == BTemplate::COMMON_HEAD){
  206 + $param['html'] = $handleInfo['head_html'];
  207 + $param['html_style'] = $handleInfo['head_style'];
  208 + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
  209 + }elseif ($type == BTemplate::COMMON_FOOTER){
  210 + $param['html'] = $handleInfo['footer_html'];
  211 + $param['html_style'] = $handleInfo['footer_style'];
  212 + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
142 }else{ 213 }else{
143 - $data = [  
144 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],  
145 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
146 - ];  
147 - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); 214 + $param['html'] = $handleInfo['other'];
  215 + $param['html_style'] = null;
  216 + $typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
148 } 217 }
149 - //更新所有界面的other  
150 - return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]); 218 + //查看当前数据是否还存在
  219 + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
  220 + $info = $templateComModel->read($condition);
  221 + if($info === false){
  222 + $data = array_merge($param,$condition);
  223 + $templateComModel->add($data);
  224 + }else{
  225 + $templateComModel->edit($param,$condition);
151 } 226 }
152 -  
153 - /**  
154 - * @remark :根据类型获取公共头和底  
155 - * @name :getCommonPage  
156 - * @author :lyh  
157 - * @method :post  
158 - * @time :2023/10/21 16:55  
159 - */  
160 - public function getCommonHtml($source,$is_list,$template_id,$is_custom){  
161 - $type = $this->getType($source,$is_list,$is_custom);  
162 - $data = [  
163 - 'template_id' => $template_id,  
164 - 'project_id' => $this->user['project_id'],  
165 - 'type'=>$type  
166 - ];  
167 - $commonTemplateModel = new BTemplateCommon();  
168 - $commonInfo = $commonTemplateModel->read($data);  
169 - if($commonInfo === false){  
170 - $data['type'] = BTemplate::SOURCE_HOME;  
171 - $commonInfo = $commonTemplateModel->read($data);  
172 } 227 }
173 - return $this->success($commonInfo); 228 + return $this->success();
174 } 229 }
175 230
176 /** 231 /**
177 - * @remark :保存时获取获取设置的类型 232 + * @remark :(非定制)保存时获取获取设置的类型
178 * @name :getType 233 * @name :getType
179 * @author :lyh 234 * @author :lyh
180 * @method :post 235 * @method :post
181 * @time :2023/10/21 17:29 236 * @time :2023/10/21 17:29
182 */ 237 */
183 - public function getType($source,$is_list,$is_custom = 0){  
184 - $type = BTemplate::SOURCE_HOME;//首页公共头部底部 238 + public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$CommonType = BTemplate::COMMON_HEAD,$template_id = 0){
  239 + if($template_id == 0){
  240 + return $this->success($source);
  241 + }
  242 + $type = BTemplate::SOURCE_COM;//公共头部底部
185 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; 243 $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
186 - if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部 244 + if($is_custom == BTemplate::IS_CUSTOM || $is_head == BTemplate::IS_NO_HEADER){//拓展模块为首页头部
187 return $this->success($type); 245 return $this->success($type);
188 } 246 }
189 //查看页面是否设置自定义头部底部 247 //查看页面是否设置自定义头部底部
190 - if($is_head != BTemplate::IS_NO_HEADER) {  
191 $pageSettingModel = new PageSetting(); 248 $pageSettingModel = new PageSetting();
192 - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); 249 + $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
193 if ($pageInfo === false) { 250 if ($pageInfo === false) {
194 return $this->success($type); 251 return $this->success($type);
195 } 252 }
196 - if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}  
197 - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}  
198 - if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}  
199 - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}  
200 - if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}  
201 - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}  
202 - if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}  
203 - } 253 + if($source == BTemplate::SOURCE_HOME){if ($pageInfo['home'] != 0){$type = BTemplate::SOURCE_HOME;}}
  254 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}
  255 + else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}}
  256 + if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::SOURCE_BLOG;}}
  257 + else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::SOURCE_BLOG;}}}
  258 + if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::SOURCE_NEWS;}}
  259 + else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::SOURCE_NEWS;}}}
  260 + if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::SOURCE_KEYWORD;}}
204 return $this->success($type); 261 return $this->success($type);
205 } 262 }
206 263
@@ -215,8 +272,8 @@ class InitHtmlLogic extends BaseLogic @@ -215,8 +272,8 @@ class InitHtmlLogic extends BaseLogic
215 //字符串截取 272 //字符串截取
216 $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); 273 $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
217 $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); 274 $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
218 - $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');  
219 - $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); 275 + $param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
  276 + $param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
220 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); 277 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
221 $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); 278 $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
222 return $this->success($param); 279 return $this->success($param);
@@ -269,21 +326,39 @@ class InitHtmlLogic extends BaseLogic @@ -269,21 +326,39 @@ class InitHtmlLogic extends BaseLogic
269 if($info === false){ 326 if($info === false){
270 $html = ''; 327 $html = '';
271 }else{ 328 }else{
272 - //扩展模块获取头部  
273 - if($is_custom == BTemplate::IS_CUSTOM){  
274 - $type = $this->param['type']; 329 + $commonInfo = $this->getCustomizeTemplateComHtml($this->param['type'],$is_custom,$is_list);
  330 + $html = $this->handleAllHtml($commonInfo,$info['main_html']);
  331 + }
  332 + //更新头部底部
  333 + return $this->success(['html'=>$html]);
  334 + }
  335 +
  336 + /**
  337 + * @remark :定制获取头部底部
  338 + * @name :getCustomizedCommonHtml
  339 + * @author :lyh
  340 + * @method :post
  341 + * @time :2023/12/29 13:13
  342 + */
  343 + public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
  344 + $data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
  345 + $param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
  346 + $commonTemplateModel = new BTemplateCom();
  347 + $commonList = $commonTemplateModel->list($param);
  348 + if(!empty($commonList)){
  349 + foreach ($commonList as $v){
  350 + if($v['common_type'] == BTemplate::COMMON_HEAD){
  351 + $data['head_html'] = $v['html'];
  352 + $data['head_style'] = $v['html_style'];
  353 + }elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
  354 + $data['footer_html'] = $v['html'];
  355 + $data['footer_style'] = $v['html_style'];
275 }else{ 356 }else{
276 - $type = $this->getCustomizedType($this->param['type'],$is_list); 357 + $data['other'] = $v['html'];
277 } 358 }
278 - $commonTemplateModel = new BTemplateCommon();  
279 - $commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);  
280 - if($commonInfo !== false){  
281 - $info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);  
282 } 359 }
283 - $html = $info['main_html'];  
284 } 360 }
285 - //更新头部底部  
286 - return $this->success(['html'=>$html]); 361 + return $this->success($data);
287 } 362 }
288 363
289 /** 364 /**
@@ -329,7 +404,7 @@ class InitHtmlLogic extends BaseLogic @@ -329,7 +404,7 @@ class InitHtmlLogic extends BaseLogic
329 $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); 404 $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
330 } 405 }
331 //更新头部底部 406 //更新头部底部
332 - $this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list,$is_custom); 407 + $this->saveTemplateCom($this->param['html'],0,$this->param['type'],$is_list,$is_custom);
333 }catch (\Exception $exception){ 408 }catch (\Exception $exception){
334 $this->fail('保存失败,请联系开发人员'); 409 $this->fail('保存失败,请联系开发人员');
335 } 410 }
@@ -337,73 +412,6 @@ class InitHtmlLogic extends BaseLogic @@ -337,73 +412,6 @@ class InitHtmlLogic extends BaseLogic
337 } 412 }
338 413
339 /** 414 /**
340 - * @remark :定制代码更新头部信息  
341 - * @name :saveCustomizeCommon  
342 - * @author :lyh  
343 - * @method :post  
344 - * @time :2024/1/6 10:29  
345 - */  
346 - public function saveCustomizeCommon($html,$source,$is_list,$is_custom){  
347 - if($is_custom == BTemplate::IS_CUSTOM){  
348 - $type = $source;  
349 - }else{  
350 - $type = $this->getCustomizedType($source,$is_list);  
351 - }  
352 - $templateCommonModel = new BTemplateCommon();  
353 - $commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);//查看当前头部是否存在  
354 - $handleInfo = $this->handleCommonParam($html);  
355 - if($commonInfo === false){  
356 - $data = [  
357 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],  
358 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
359 - 'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],  
360 - 'is_custom'=>$is_custom,'is_list'=>$is_list  
361 - ];  
362 - $templateCommonModel->add($data);  
363 - }else{  
364 - $data = [  
365 - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],  
366 - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],  
367 - ];  
368 - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);  
369 - }  
370 - return $this->success();  
371 - }  
372 -  
373 - /**  
374 - * @remark :定制页面头部类型---根据source获取type类型  
375 - * @name :getType  
376 - * @author :lyh  
377 - * @method :post  
378 - * @time :2023/11/16 11:20  
379 - */  
380 - public function getCustomizedType($source,$is_list){  
381 - $type = BTemplate::TYPE_HOME;  
382 - if($source == BTemplate::SOURCE_PRODUCT){  
383 - if($is_list == BTemplate::IS_LIST){  
384 - $type = BTemplate::TYPE_PRODUCT_LIST;  
385 - }else{  
386 - $type = BTemplate::TYPE_PRODUCT_DETAIL;  
387 - }  
388 - }  
389 - if($source == BTemplate::SOURCE_BLOG){  
390 - if($is_list == BTemplate::IS_LIST){  
391 - $type = BTemplate::TYPE_BLOG_LIST;  
392 - }else{  
393 - $type = BTemplate::TYPE_BLOG_DETAIL;  
394 - }  
395 - }  
396 - if($source == BTemplate::SOURCE_NEWS){  
397 - if($is_list == BTemplate::IS_LIST){  
398 - $type = BTemplate::TYPE_NEWS_LIST;  
399 - }else{  
400 - $type = BTemplate::TYPE_NEWS_DETAIL;  
401 - }  
402 - }  
403 - return $type;  
404 - }  
405 -  
406 - /**  
407 * @remark :前端获取设置模块(侧边栏) 415 * @remark :前端获取设置模块(侧边栏)
408 * @name :getInitModuleMain 416 * @name :getInitModuleMain
409 * @author :lyh 417 * @author :lyh
@@ -4,8 +4,11 @@ namespace App\Http\Logic\Bside\Blog; @@ -4,8 +4,11 @@ namespace App\Http\Logic\Bside\Blog;
4 4
5 use App\Helper\Translate; 5 use App\Helper\Translate;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
  7 +use App\Models\Blog\Blog;
7 use App\Models\Blog\Blog as BlogModel; 8 use App\Models\Blog\Blog as BlogModel;
  9 +use App\Models\Blog\BlogCategory;
8 use App\Models\Blog\BlogCategory as BlogCategoryModel; 10 use App\Models\Blog\BlogCategory as BlogCategoryModel;
  11 +use App\Models\News\NewsCategory as NewsCategoryModel;
9 use App\Models\RouteMap\RouteMap; 12 use App\Models\RouteMap\RouteMap;
10 use Illuminate\Support\Facades\DB; 13 use Illuminate\Support\Facades\DB;
11 14
@@ -90,32 +93,13 @@ class BlogCategoryLogic extends BaseLogic @@ -90,32 +93,13 @@ class BlogCategoryLogic extends BaseLogic
90 */ 93 */
91 public function delBlogCategory(){ 94 public function delBlogCategory(){
92 foreach ($this->param['id'] as $id){ 95 foreach ($this->param['id'] as $id){
93 - $this->verifyIsDelete($id);  
94 //删除路由 96 //删除路由
95 $this->delRoute($id); 97 $this->delRoute($id);
96 $this->model->del(['id'=>$id]); 98 $this->model->del(['id'=>$id]);
97 - }  
98 - return $this->success();  
99 - }  
100 -  
101 - /**  
102 - * @remark :验证是否可删除  
103 - * @name :VerifyIsDelete  
104 - * @author :lyh  
105 - * @method :post  
106 - * @time :2023/9/7 14:40  
107 - */  
108 - public function verifyIsDelete($id){  
109 - //查询是否有子分类  
110 - $rs = $this->model->read(['pid'=>$id],['id']);  
111 - if($rs !== false){  
112 - $this->response('当前分类拥有子分类不允许删除');  
113 - }  
114 - //查看当前分内下是否有博客  
115 - $blogModel = new BlogModel();  
116 - $rs = $blogModel->read(['category_id'=>['like','%,'.$id.',%']],['id']);  
117 - if($rs !== false){  
118 - $this->response('当前分类拥有博客,不允许删除'); 99 + //同步删除产品字段category_id
  100 + $blogModel = new Blog();
  101 + $blogModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
  102 + $blogModel->edit(['category_id'=>null],['category_id'=>',']);
119 } 103 }
120 return $this->success(); 104 return $this->success();
121 } 105 }
@@ -278,4 +262,19 @@ class BlogCategoryLogic extends BaseLogic @@ -278,4 +262,19 @@ class BlogCategoryLogic extends BaseLogic
278 } 262 }
279 return $this->success(); 263 return $this->success();
280 } 264 }
  265 +
  266 +
  267 + /**
  268 + * @remark :设置批量排序
  269 + * @name :setAllSort
  270 + * @author :lyh
  271 + * @method :post
  272 + * @time :2024/1/10 15:40
  273 + */
  274 + public function setAllSort(){
  275 + foreach ($this->param['data'] as $k => $v){
  276 + $this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
  277 + }
  278 + return $this->success();
  279 + }
281 } 280 }
@@ -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
@@ -16,7 +17,6 @@ class BlogLogic extends BaseLogic @@ -16,7 +17,6 @@ class BlogLogic extends BaseLogic
16 public function __construct() 17 public function __construct()
17 { 18 {
18 parent::__construct(); 19 parent::__construct();
19 -  
20 $this->model = new Blog(); 20 $this->model = new Blog();
21 $this->param = $this->requestAll; 21 $this->param = $this->requestAll;
22 } 22 }
@@ -382,15 +382,26 @@ class BlogLogic extends BaseLogic @@ -382,15 +382,26 @@ class BlogLogic extends BaseLogic
382 public function batchSetCategory(){ 382 public function batchSetCategory(){
383 if(isset($this->param['category_id']) && !empty($this->param['category_id'])) { 383 if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
384 DB::connection('custom_mysql')->beginTransaction(); 384 DB::connection('custom_mysql')->beginTransaction();
385 - $this->param['category_id'] = ','.implode(',',$this->param['category_id']).','; 385 + $category_id_str = ','.implode(',',$this->param['category_id']).',';
386 try { 386 try {
387 - //批量 387 + if(!isset($this->param['is_cover']) || ($this->param['is_cover'] == 1)){
  388 + //批量覆盖
388 $param = [ 389 $param = [
389 - 'category_id'=>$this->param['category_id'], 390 + 'category_id'=>$category_id_str,
390 'status'=>$this->param['status'] 391 'status'=>$this->param['status']
391 ]; 392 ];
392 $this->model->edit($param,['id'=>['in',$this->param['id']]]); 393 $this->model->edit($param,['id'=>['in',$this->param['id']]]);
393 DB::connection('custom_mysql')->commit(); 394 DB::connection('custom_mysql')->commit();
  395 + }else{
  396 + foreach ($this->param['id'] as $id){
  397 + //获取当前产品的分类
  398 + $blogInfo = $this->model->read(['id'=>$id],['id','category_id']);
  399 + $category_ids = explode(',',trim($blogInfo['category_id'],','));
  400 + $category_ids_arr = array_values(array_unique(array_merge($category_ids,$this->param['category_id'])));
  401 + $category_ids = ','.implode(',',$category_ids_arr).',';
  402 + $this->model->edit(['category_id'=>$category_ids],['id'=>$id]);
  403 + }
  404 + }
394 //对应添加关联表 405 //对应添加关联表
395 }catch (\Exception $e){ 406 }catch (\Exception $e){
396 DB::connection('custom_mysql')->rollBack(); 407 DB::connection('custom_mysql')->rollBack();
@@ -399,4 +410,71 @@ class BlogLogic extends BaseLogic @@ -399,4 +410,71 @@ class BlogLogic extends BaseLogic
399 } 410 }
400 return $this->success(); 411 return $this->success();
401 } 412 }
  413 +
  414 + /**
  415 + * @remark :复制新闻
  416 + * @name :copyNewsInfo
  417 + * @author :lyh
  418 + * @method :post
  419 + * @time :2024/4/28 14:51
  420 + */
  421 + public function copyBlogInfo(){
  422 + $info = $this->model->read(['id'=>$this->param['id']]);
  423 + $param = [
  424 + 'name'=>$info['name']."-copy",
  425 + 'status'=>$info['status'],
  426 + 'sort'=>$info['sort'],
  427 + 'category_id'=>$info['category_id'],
  428 + 'text'=>$info['text'],
  429 + 'remark'=>$info['remark'],
  430 + 'url'=>$info['url'],
  431 + 'label_id'=>$info['label_id'],
  432 + 'image'=>$info['image'],
  433 + 'project_id'=>$info['project_id'],
  434 + 'operator_id'=>$this->user['id'],
  435 + 'create_id'=>$this->user['id'],
  436 + 'created_at'=>date('Y-m-d H:i:s'),
  437 + 'updated_at'=>date('Y-m-d H:i:s'),
  438 + ];
  439 + $save_id = $this->model->insertGetId($param);
  440 + $route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_BLOG, $save_id, $this->user['project_id']);
  441 + $this->model->edit(['url'=>$route],['id'=>$save_id]);
  442 + //同步可视化装修数据
  443 + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
  444 + return $this->success(['id'=>$save_id]);
  445 + }
  446 +
  447 + /**
  448 + * @remark :同步模版数据
  449 + * @name :copyTemplate
  450 + * @author :lyh
  451 + * @method :post
  452 + * @time :2023/7/29 15:53
  453 + */
  454 + public function copyTemplate($id,$project_id,$save_id){
  455 + $BTemplateModel = new BTemplate();
  456 + $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_BLOG,'source_id'=>$id,'project_id'=>$project_id]);
  457 + if(!empty($list)){
  458 + $data = [];
  459 + foreach ($list as $v){
  460 + $data[] = [
  461 + 'html'=>$v['html'],
  462 + 'project_id'=>$project_id,
  463 + 'source'=>$v['source'],
  464 + 'source_id'=>$save_id,
  465 + 'template_id'=>$v['template_id'],
  466 + 'section_list_id'=>$v['section_list_id'],
  467 + 'main_html'=>$v['main_html'],
  468 + 'main_css'=>$v['main_css'],
  469 + 'created_at'=>date('Y-m-d H:i:s'),
  470 + 'updated_at'=>date('Y-m-d H:i:s'),
  471 + ];
  472 + }
  473 + $rs = $BTemplateModel->insert($data);
  474 + if($rs === false){
  475 + $this->fail('error');
  476 + }
  477 + }
  478 + return $this->success();
  479 + }
402 } 480 }
@@ -189,18 +189,13 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -189,18 +189,13 @@ class CustomModuleCategoryLogic extends BaseLogic
189 public function categoryDel(){ 189 public function categoryDel(){
190 $ids = $this->param['id']; 190 $ids = $this->param['id'];
191 foreach ($ids as $id){ 191 foreach ($ids as $id){
192 - $info = $this->model->read(['pid'=>$id],['id']);  
193 - if($info !== false){  
194 - $this->fail('分类id:'.$id.'拥有子集不允许删除');  
195 - }  
196 - $contentModel = new CustomModuleContent();  
197 - $contentInfo = $contentModel->read(['category_id'=>['like','%,'.$id.',%']]);  
198 - if($contentInfo !== false){  
199 - $this->fail('当前分类拥有产品不允许删除');  
200 - }  
201 //删除路由 192 //删除路由
202 $this->delRoute($id); 193 $this->delRoute($id);
203 $this->model->del(['id'=>$id]); 194 $this->model->del(['id'=>$id]);
  195 + //同步删除产品字段category_id
  196 + $contentModel = new CustomModuleContent();
  197 + $contentModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
  198 + $contentModel->edit(['category_id'=>null],['category_id'=>',']);
204 } 199 }
205 return $this->success(); 200 return $this->success();
206 } 201 }
@@ -238,4 +233,18 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -238,4 +233,18 @@ class CustomModuleCategoryLogic extends BaseLogic
238 } 233 }
239 return $this->success(); 234 return $this->success();
240 } 235 }
  236 +
  237 + /**
  238 + * @remark :设置批量排序
  239 + * @name :setAllSort
  240 + * @author :lyh
  241 + * @method :post
  242 + * @time :2024/1/10 15:40
  243 + */
  244 + public function setAllSort(){
  245 + foreach ($this->param['data'] as $k => $v){
  246 + $this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
  247 + }
  248 + return $this->success();
  249 + }
241 } 250 }
@@ -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
@@ -377,4 +378,106 @@ class CustomModuleContentLogic extends BaseLogic @@ -377,4 +378,106 @@ class CustomModuleContentLogic extends BaseLogic
377 $contentExtendModel->del(['content_id'=>$id]); 378 $contentExtendModel->del(['content_id'=>$id]);
378 return $this->success(); 379 return $this->success();
379 } 380 }
  381 +
  382 + /**
  383 + * @remark :设置批量排序
  384 + * @name :setAllSort
  385 + * @author :lyh
  386 + * @method :post
  387 + * @time :2024/1/10 15:40
  388 + */
  389 + public function setAllSort(){
  390 + foreach ($this->param['data'] as $k => $v){
  391 + $this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
  392 + }
  393 + return $this->success();
  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 + }
380 } 483 }
@@ -46,7 +46,7 @@ class CountLogic extends BaseLogic @@ -46,7 +46,7 @@ class CountLogic extends BaseLogic
46 //获取项目的剩余时长 46 //获取项目的剩余时长
47 $projectModel = new Project(); 47 $projectModel = new Project();
48 $projectInfo = $projectModel->read(['id'=>$this->user['project_id']],['remain_day','finish_remain_day']); 48 $projectInfo = $projectModel->read(['id'=>$this->user['project_id']],['remain_day','finish_remain_day']);
49 - $info['service_day'] = $this->project['deploy_build']['service_duration'] - $projectInfo['finish_remain_day']; 49 + $info['service_day'] = ($this->project['deploy_build']['service_duration'] ?? 0 - $projectInfo['finish_remain_day'] ?? 0);
50 $info['compliance_day'] = $projectInfo['finish_remain_day']; 50 $info['compliance_day'] = $projectInfo['finish_remain_day'];
51 return $this->success($info); 51 return $this->success($info);
52 } 52 }
@@ -4,8 +4,10 @@ namespace App\Http\Logic\Bside\News; @@ -4,8 +4,10 @@ namespace App\Http\Logic\Bside\News;
4 4
5 use App\Helper\Translate; 5 use App\Helper\Translate;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
  7 +use App\Models\News\News;
7 use App\Models\News\News as NewsModel; 8 use App\Models\News\News as NewsModel;
8 use App\Models\News\NewsCategory as NewsCategoryModel; 9 use App\Models\News\NewsCategory as NewsCategoryModel;
  10 +use App\Models\Product\Product;
9 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
10 use Illuminate\Support\Facades\DB; 12 use Illuminate\Support\Facades\DB;
11 13
@@ -88,19 +90,12 @@ class NewsCategoryLogic extends BaseLogic @@ -88,19 +90,12 @@ class NewsCategoryLogic extends BaseLogic
88 */ 90 */
89 public function del_news_category(){ 91 public function del_news_category(){
90 foreach ($this->param['id'] as $id){ 92 foreach ($this->param['id'] as $id){
91 - //查询是否有子分类  
92 - $rs = $this->model->read(['pid'=>$id],['id']);  
93 - if($rs !== false){  
94 - $this->fail('当前分类拥有子分类不允许删除');  
95 - }  
96 - //查看当前分内下是否有商品  
97 - $newsModel = new NewsModel();  
98 - $rs = $newsModel->read(['category_id'=>$id],['id']);  
99 - if($rs !== false){  
100 - $this->fail('当前分类拥有商品,不允许删除');  
101 - }  
102 $this->delRoute($id); 93 $this->delRoute($id);
103 $this->model->del(['id'=>$id]); 94 $this->model->del(['id'=>$id]);
  95 + //同步删除产品字段category_id
  96 + $newsModel = new NewsModel();
  97 + $newsModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
  98 + $newsModel->edit(['category_id'=>null],['category_id'=>',']);
104 } 99 }
105 return $this->success(); 100 return $this->success();
106 } 101 }
@@ -259,4 +254,18 @@ class NewsCategoryLogic extends BaseLogic @@ -259,4 +254,18 @@ class NewsCategoryLogic extends BaseLogic
259 } 254 }
260 return $this->success(); 255 return $this->success();
261 } 256 }
  257 +
  258 + /**
  259 + * @remark :设置批量排序
  260 + * @name :setAllSort
  261 + * @author :lyh
  262 + * @method :post
  263 + * @time :2024/1/10 15:40
  264 + */
  265 + public function setAllSort(){
  266 + foreach ($this->param['data'] as $k => $v){
  267 + $this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
  268 + }
  269 + return $this->success();
  270 + }
262 } 271 }
@@ -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;
@@ -270,7 +271,7 @@ class NewsLogic extends BaseLogic @@ -270,7 +271,7 @@ class NewsLogic extends BaseLogic
270 } 271 }
271 272
272 /** 273 /**
273 - * @remark : 274 + * @remark :设置批量排序
274 * @name :setAllSort 275 * @name :setAllSort
275 * @author :lyh 276 * @author :lyh
276 * @method :post 277 * @method :post
@@ -427,16 +428,26 @@ class NewsLogic extends BaseLogic @@ -427,16 +428,26 @@ class NewsLogic extends BaseLogic
427 public function batchSetCategory(){ 428 public function batchSetCategory(){
428 if(isset($this->param['category_id']) && !empty($this->param['category_id'])) { 429 if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
429 DB::connection('custom_mysql')->beginTransaction(); 430 DB::connection('custom_mysql')->beginTransaction();
430 - $this->param['category_id'] = ','.implode(',',$this->param['category_id']).','; 431 + $category_id_str = ','.implode(',',$this->param['category_id']).',';
431 try { 432 try {
432 - //批量 433 + if(!isset($this->param['is_cover']) || ($this->param['is_cover'] == 1)){
  434 + //批量覆盖
433 $param = [ 435 $param = [
434 - 'category_id'=>$this->param['category_id'], 436 + 'category_id'=>$category_id_str,
435 'status'=>$this->param['status'] 437 'status'=>$this->param['status']
436 ]; 438 ];
437 $this->model->edit($param,['id'=>['in',$this->param['id']]]); 439 $this->model->edit($param,['id'=>['in',$this->param['id']]]);
438 DB::connection('custom_mysql')->commit(); 440 DB::connection('custom_mysql')->commit();
439 - //对应添加关联表 441 + }else{
  442 + foreach ($this->param['id'] as $id){
  443 + //获取当前产品的分类
  444 + $newsInfo = $this->model->read(['id'=>$id],['id','category_id']);
  445 + $category_ids = explode(',',trim($newsInfo['category_id'],','));
  446 + $category_ids_arr = array_values(array_unique(array_merge($category_ids,$this->param['category_id'])));
  447 + $category_ids = ','.implode(',',$category_ids_arr).',';
  448 + $this->model->edit(['category_id'=>$category_ids],['id'=>$id]);
  449 + }
  450 + }
440 }catch (\Exception $e){ 451 }catch (\Exception $e){
441 DB::connection('custom_mysql')->rollBack(); 452 DB::connection('custom_mysql')->rollBack();
442 $this->fail('系统错误,请联系管理员'); 453 $this->fail('系统错误,请联系管理员');
@@ -444,4 +455,70 @@ class NewsLogic extends BaseLogic @@ -444,4 +455,70 @@ class NewsLogic extends BaseLogic
444 } 455 }
445 return $this->success(); 456 return $this->success();
446 } 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 + }
447 } 524 }
@@ -168,18 +168,16 @@ class CategoryLogic extends BaseLogic @@ -168,18 +168,16 @@ class CategoryLogic extends BaseLogic
168 public function categoryDelete(){ 168 public function categoryDelete(){
169 $ids = $this->param['ids']; 169 $ids = $this->param['ids'];
170 foreach ($ids as $id){ 170 foreach ($ids as $id){
171 - $info = $this->model->read(['pid'=>$id],['id']);  
172 - if($info !== false){  
173 - $this->fail('分类id:'.$id.'拥有子集不允许删除');  
174 - }  
175 - $productModel = new Product();  
176 - $product_info = $productModel->read(['category_id'=>['like','%,'.$id.',%']]);  
177 - if($product_info !== false){  
178 - $this->fail('当前分类拥有产品不允许删除');  
179 - }  
180 //删除路由 171 //删除路由
181 $this->delRoute($id); 172 $this->delRoute($id);
182 $this->model->del(['id'=>$id]); 173 $this->model->del(['id'=>$id]);
  174 + //同步删除关联表
  175 + $categoryRelatedModel = new CategoryRelated();
  176 + $categoryRelatedModel->del(['cate_id'=>$id]);
  177 + //同步删除产品字段category_id
  178 + $productModel = new Product();
  179 + $productModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
  180 + $productModel->edit(['category_id'=>null],['category_id'=>',']);
183 } 181 }
184 //清除缓存 182 //清除缓存
185 Common::del_user_cache('product_category',$this->user['project_id']); 183 Common::del_user_cache('product_category',$this->user['project_id']);
@@ -273,4 +271,18 @@ class CategoryLogic extends BaseLogic @@ -273,4 +271,18 @@ class CategoryLogic extends BaseLogic
273 } 271 }
274 return $this->success(); 272 return $this->success();
275 } 273 }
  274 +
  275 + /**
  276 + * @remark :批量设置排序
  277 + * @name :setAllSort
  278 + * @author :lyh
  279 + * @method :post
  280 + * @time :2024/1/10 15:40
  281 + */
  282 + public function setAllSort(){
  283 + foreach ($this->param['data'] as $k => $v){
  284 + $this->model->edit(['sort'=>$v['sort']],['id'=>$v['id']]);
  285 + }
  286 + return $this->success();
  287 + }
276 } 288 }
@@ -335,22 +335,6 @@ class ProductLogic extends BaseLogic @@ -335,22 +335,6 @@ class ProductLogic extends BaseLogic
335 return !empty(trim($str,',')) ? ','.$str.',' : ''; 335 return !empty(trim($str,',')) ? ','.$str.',' : '';
336 } 336 }
337 337
338 - /**  
339 - * @remark :获取最后一级分类id(数组)  
340 - * @name :getLastCategory  
341 - * @author :lyh  
342 - * @method :post  
343 - * @time :2023/10/20 9:02  
344 - */  
345 - public function getLastCategoryArr($category){  
346 - $arr = [];  
347 - if(isset($category) && !empty($category)){  
348 - foreach ($category as $v){  
349 - $arr[] = $v;  
350 - }  
351 - }  
352 - return $arr;  
353 - }  
354 338
355 /** 339 /**
356 * @remark :编辑产品 340 * @remark :编辑产品
@@ -575,27 +559,29 @@ class ProductLogic extends BaseLogic @@ -575,27 +559,29 @@ class ProductLogic extends BaseLogic
575 * @time :2023/8/15 17:53 559 * @time :2023/8/15 17:53
576 */ 560 */
577 public function batchSetCategory(){ 561 public function batchSetCategory(){
578 - if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {  
579 - DB::connection('custom_mysql')->beginTransaction();  
580 - $category_ids = $this->getLastCategoryArr($this->param['category_id']);  
581 - $this->param['category_id'] = ','.implode(',',$category_ids).','; 562 + if(!isset($this->param['category_id']) || empty($this->param['category_id'])){
  563 + $this->fail('请选择分类');
  564 + }
582 try { 565 try {
583 - //批量  
584 - $param = [  
585 - 'category_id'=>$this->param['category_id'],  
586 - 'status'=>$this->param['status']  
587 - ];  
588 - $this->model->edit($param,['id'=>['in',$this->param['id']]]); 566 + if(!isset($this->param['is_cover']) || ($this->param['is_cover'] == 1)){
  567 + $category_ids = ','.implode(',',$this->param['category_id']).',';
  568 + $this->model->edit(['category_id'=>$category_ids],['id'=>['in',$this->param['id']]]);
589 //分类关联 569 //分类关联
590 foreach ($this->param['id'] as $id){ 570 foreach ($this->param['id'] as $id){
591 - CategoryRelated::saveRelated($id, $category_ids); 571 + CategoryRelated::saveRelated($id, $this->param['category_id']);
  572 + }
  573 + }else{
  574 + foreach ($this->param['id'] as $id){
  575 + //获取当前产品的分类
  576 + $productInfo = $this->model->read(['id'=>$id],['id','category_id']);
  577 + $category_ids_arr = array_values(array_unique(array_merge($productInfo['category_id'],$this->param['category_id'])));
  578 + $category_ids = ','.implode(',',$category_ids_arr).',';
  579 + $this->model->edit(['category_id'=>$category_ids],['id'=>$id]);
  580 + CategoryRelated::saveRelated($id, $category_ids_arr);
592 } 581 }
593 - DB::connection('custom_mysql')->commit();  
594 - //对应添加关联表  
595 - }catch (\Exception $e){  
596 - DB::connection('custom_mysql')->rollBack();  
597 - $this->fail('系统错误,请联系管理员');  
598 } 582 }
  583 + }catch (\Exception $e){
  584 + $this->fail('设置分类失败,请联系管理员');
599 } 585 }
600 return $this->success(); 586 return $this->success();
601 } 587 }
@@ -158,7 +158,9 @@ class UserLoginLogic @@ -158,7 +158,9 @@ class UserLoginLogic
158 $info['aicc'] = $project['aicc'] ?? ''; 158 $info['aicc'] = $project['aicc'] ?? '';
159 $info['hagro'] = $project['hagro'] ?? ''; 159 $info['hagro'] = $project['hagro'] ?? '';
160 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']]; 160 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
161 - $info['domain'] = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? '')); 161 + $info['test_domain'] = $project['deploy_build']['test_domain'] ?? '';
  162 + $info['domain'] = (!empty($project['deploy_optimize']['domain']) ?
  163 + ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
162 $info['is_customized'] = $project['is_customized']; 164 $info['is_customized'] = $project['is_customized'];
163 $info['is_upload_manage'] = $project['is_upload_manage']; 165 $info['is_upload_manage'] = $project['is_upload_manage'];
164 $info['is_upgrade'] = $project['is_upgrade']; 166 $info['is_upgrade'] = $project['is_upgrade'];
@@ -258,8 +260,9 @@ class UserLoginLogic @@ -258,8 +260,9 @@ class UserLoginLogic
258 $info['hagro'] = $project['hagro'] ?? ''; 260 $info['hagro'] = $project['hagro'] ?? '';
259 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']]; 261 $info['plan'] = Project::planMap()[$project['deploy_build']['plan']];
260 $info['is_domain'] = empty($project['deploy_optimize']['domain']) ? 0 : 1; 262 $info['is_domain'] = empty($project['deploy_optimize']['domain']) ? 0 : 1;
  263 + $info['test_domain'] = $project['deploy_build']['test_domain'] ?? '';
261 $info['domain'] = (!empty($project['deploy_optimize']['domain']) ? 264 $info['domain'] = (!empty($project['deploy_optimize']['domain']) ?
262 - ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ($project['deploy_build']['test_domain'] ?? '')); 265 + ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : '');
263 $info['is_customized'] = $project['is_customized']; 266 $info['is_customized'] = $project['is_customized'];
264 $info['is_upgrade'] = $project['is_upgrade']; 267 $info['is_upgrade'] = $project['is_upgrade'];
265 $info['is_upload_manage'] = $project['is_upload_manage']; 268 $info['is_upload_manage'] = $project['is_upload_manage'];
@@ -15,6 +15,7 @@ class BTemplate extends Base @@ -15,6 +15,7 @@ class BTemplate extends Base
15 /** 15 /**
16 * 模块类型 16 * 模块类型
17 */ 17 */
  18 + const SOURCE_COM = 99;//公共页面
18 const SOURCE_HOME = 1;//首页 19 const SOURCE_HOME = 1;//首页
19 const SOURCE_PRODUCT = 2;//产品 20 const SOURCE_PRODUCT = 2;//产品
20 21
@@ -29,7 +30,12 @@ class BTemplate extends Base @@ -29,7 +30,12 @@ class BTemplate extends Base
29 */ 30 */
30 const ALL_HTML = 1;//无需拼接数据,获取整个html 31 const ALL_HTML = 1;//无需拼接数据,获取整个html
31 const PAGE_HTML = 0;//默认保存方式为0, 32 const PAGE_HTML = 0;//默认保存方式为0,
32 - 33 + /**
  34 + * 公共头部底部连接部分
  35 + */
  36 + const COMMON_HEAD = 1;//公共头部
  37 + const COMMON_FOOTER = 2;//公共头部
  38 + const COMMON_OTHER = 3;//公共头部
33 /** 39 /**
34 * 独立头部类型 40 * 独立头部类型
35 */ 41 */
@@ -52,7 +58,7 @@ class BTemplate extends Base @@ -52,7 +58,7 @@ class BTemplate extends Base
52 const IS_NO_CUSTOM = 0;//为默认模块 58 const IS_NO_CUSTOM = 0;//为默认模块
53 const IS_VISUALIZATION = 1;//定制项目 59 const IS_VISUALIZATION = 1;//定制项目
54 60
55 - const IS_NO_VISUALIZATION = 1;//定制项目 61 + const IS_NO_VISUALIZATION = 0;//非定制项目
56 const STATUS = 0; 62 const STATUS = 0;
57 63
58 /** 64 /**
@@ -4,13 +4,24 @@ @@ -4,13 +4,24 @@
4 * @name :BTemplateCom.php 4 * @name :BTemplateCom.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
  7 +<<<<<<< HEAD
7 * @time :2024/5/7 10:13 8 * @time :2024/5/7 10:13
  9 +=======
  10 + * @time :2024/4/29 10:29
  11 +>>>>>>> 6ab07f6903cde5505cc85cd6989e6f0401614405
8 */ 12 */
9 13
10 namespace App\Models\Template; 14 namespace App\Models\Template;
11 15
12 use App\Models\Base; 16 use App\Models\Base;
13 17
  18 +/**
  19 + * @remark :可视化公共部分
  20 + * @name :BTemplateCom
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2024/4/29 10:29
  24 + */
14 class BTemplateCom extends Base 25 class BTemplateCom extends Base
15 { 26 {
16 protected $table = 'gl_web_template_com'; 27 protected $table = 'gl_web_template_com';
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TemplateReplaceHtml.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/8 9:05
  8 + */
  9 +
  10 +namespace App\Models\Template;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class TemplateReplaceHtml extends Base
  15 +{
  16 + protected $table = 'gl_replace_html';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TemplateReplaceHtmlLog.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/8 9:34
  8 + */
  9 +
  10 +namespace App\Models\Template;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class TemplateReplaceHtmlLog extends Base
  15 +{
  16 + protected $table = 'gl_replace_html_log';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
@@ -133,7 +133,7 @@ class ProjectServer @@ -133,7 +133,7 @@ class ProjectServer
133 //初始化模块数据 133 //初始化模块数据
134 self::initModule($project_id); 134 self::initModule($project_id);
135 //初始化search页面 135 //初始化search页面
136 - self::initSearchPage($project_id); 136 +// self::initSearchPage($project_id);
137 DB::disconnect('custom_mysql'); 137 DB::disconnect('custom_mysql');
138 return true; 138 return true;
139 } 139 }
@@ -376,7 +376,12 @@ Route::middleware(['aloginauth'])->group(function () { @@ -376,7 +376,12 @@ Route::middleware(['aloginauth'])->group(function () {
376 Route::any('/del', [Aside\Template\ATemplateTypeController::class, 'del'])->name('admin.ATemplateType_del'); 376 Route::any('/del', [Aside\Template\ATemplateTypeController::class, 'del'])->name('admin.ATemplateType_del');
377 }); 377 });
378 }); 378 });
379 - 379 + //可视化数据替换
  380 + Route::prefix('replace')->group(function () {
  381 + Route::any('/replaceTemplateMainHtml', [Aside\Template\ReplaceHtmlController::class, 'replaceTemplateMainHtml'])->name('admin.replace_replaceTemplateMainHtml');
  382 + Route::any('/replaceTemplateLog', [Aside\Template\ReplaceHtmlController::class, 'replaceTemplateLog'])->name('admin.replace_replaceTemplateLog');
  383 + Route::any('/reductionHtml', [Aside\Template\ReplaceHtmlController::class, 'reductionHtml'])->name('admin.replace_reductionHtml');
  384 + });
380 385
381 Route::any('/generate_aicc_token', [Aside\Com\IndexController::class, 'generateAiCCToken'])->name('admin.generate_aicc_token'); 386 Route::any('/generate_aicc_token', [Aside\Com\IndexController::class, 'generateAiCCToken'])->name('admin.generate_aicc_token');
382 Route::any('/getAutoToken', [Aside\Com\IndexController::class, 'getAutoToken'])->name('admin.getAutoToken'); 387 Route::any('/getAutoToken', [Aside\Com\IndexController::class, 'getAutoToken'])->name('admin.getAutoToken');
@@ -77,12 +77,14 @@ Route::middleware(['bloginauth'])->group(function () { @@ -77,12 +77,14 @@ Route::middleware(['bloginauth'])->group(function () {
77 Route::any('/category/info', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'info'])->name('news_category_info'); 77 Route::any('/category/info', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'info'])->name('news_category_info');
78 Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_edit'); 78 Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_edit');
79 Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); 79 Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del');
  80 + Route::any('/category/allSort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'allSort'])->name('news_category_allSort');
80 Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status'); 81 Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status');
81 Route::any('/category/sort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'sort'])->name('news_category_sort'); 82 Route::any('/category/sort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'sort'])->name('news_category_sort');
82 Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'categoryTopList'])->name('news_category_categoryTopList'); 83 Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'categoryTopList'])->name('news_category_categoryTopList');
83 //新闻 84 //新闻
84 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');
85 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');
86 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');
87 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');
88 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');
@@ -111,6 +113,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -111,6 +113,7 @@ Route::middleware(['bloginauth'])->group(function () {
111 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');
112 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');
113 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');
114 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');
115 //分类 118 //分类
116 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');
@@ -118,6 +121,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -118,6 +121,7 @@ Route::middleware(['bloginauth'])->group(function () {
118 Route::any('/category/info', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'info'])->name('blog_category_info'); 121 Route::any('/category/info', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'info'])->name('blog_category_info');
119 Route::any('/category/edit', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'save'])->name('blog_category_edit'); 122 Route::any('/category/edit', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'save'])->name('blog_category_edit');
120 Route::any('/category/del', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'del'])->name('blog_category_del'); 123 Route::any('/category/del', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'del'])->name('blog_category_del');
  124 + Route::any('/category/allSort', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'allSort'])->name('blog_category_allSort');
121 Route::any('/category/status', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'status'])->name('blog_category_status'); 125 Route::any('/category/status', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'status'])->name('blog_category_status');
122 Route::any('/category/sort', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'sort'])->name('blog_category_sort'); 126 Route::any('/category/sort', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'sort'])->name('blog_category_sort');
123 Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'categoryTopList'])->name('blog_category_categoryTopList'); 127 Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'categoryTopList'])->name('blog_category_categoryTopList');
@@ -250,7 +254,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -250,7 +254,7 @@ Route::middleware(['bloginauth'])->group(function () {
250 Route::post('category/save', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'save'])->name('product_category_save'); 254 Route::post('category/save', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'save'])->name('product_category_save');
251 Route::post('category/sort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'sort'])->name('product_category_sort'); 255 Route::post('category/sort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'sort'])->name('product_category_sort');
252 Route::any('category/delete', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'delete'])->name('product_category_delete'); 256 Route::any('category/delete', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'delete'])->name('product_category_delete');
253 - 257 + Route::any('category/allSort', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'allSort'])->name('product_category_allSort');
254 //产品关键词 258 //产品关键词
255 Route::get('keyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'index'])->name('product_keyword'); 259 Route::get('keyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'index'])->name('product_keyword');
256 Route::get('keyword/info', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'info'])->name('product_keyword_info'); 260 Route::get('keyword/info', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'info'])->name('product_keyword_info');
@@ -353,7 +357,6 @@ Route::middleware(['bloginauth'])->group(function () { @@ -353,7 +357,6 @@ Route::middleware(['bloginauth'])->group(function () {
353 Route::any('/savePublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'savePublicTemplate'])->name('template_savePublicTemplate'); 357 Route::any('/savePublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'savePublicTemplate'])->name('template_savePublicTemplate');
354 Route::any('/getDetailInfo', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getDetailInfo'])->name('template_getDetailInfo'); 358 Route::any('/getDetailInfo', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getDetailInfo'])->name('template_getDetailInfo');
355 Route::any('/saveDetail', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'saveDetail'])->name('template_saveDetail'); 359 Route::any('/saveDetail', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'saveDetail'])->name('template_saveDetail');
356 - Route::any('/getSource', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getSource'])->name('template_getSource');  
357 // 模板 360 // 模板
358 Route::prefix('module')->group(function () { 361 Route::prefix('module')->group(function () {
359 //获取所有左侧模版 362 //获取所有左侧模版
@@ -398,6 +401,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -398,6 +401,7 @@ Route::middleware(['bloginauth'])->group(function () {
398 Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del'); 401 Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del');
399 Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'rollbackVersion'])->name('custom_rollbackVersion'); 402 Route::any('/rollbackVersion', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'rollbackVersion'])->name('custom_rollbackVersion');
400 Route::any('/getCustomTemplateLog', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'getCustomTemplateLog'])->name('custom_getCustomTemplateLog'); 403 Route::any('/getCustomTemplateLog', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'getCustomTemplateLog'])->name('custom_getCustomTemplateLog');
  404 + Route::any('/copyCustomTemplate', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'copyCustomTemplate'])->name('custom_copyCustomTemplate');
401 }); 405 });
402 // 菜单组 406 // 菜单组
403 Route::prefix('nav_group')->group(function () { 407 Route::prefix('nav_group')->group(function () {
@@ -487,6 +491,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -487,6 +491,7 @@ Route::middleware(['bloginauth'])->group(function () {
487 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'save'])->name('custom_category_save'); 491 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'save'])->name('custom_category_save');
488 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'del'])->name('custom_category_del'); 492 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'del'])->name('custom_category_del');
489 Route::any('/sort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'sort'])->name('custom_category_sort'); 493 Route::any('/sort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'sort'])->name('custom_category_sort');
  494 + Route::any('/allSort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleCategoryController::class, 'allSort'])->name('custom_category_allSort');
490 }); 495 });
491 496
492 Route::prefix('content')->group(function () { 497 Route::prefix('content')->group(function () {
@@ -496,6 +501,8 @@ Route::middleware(['bloginauth'])->group(function () { @@ -496,6 +501,8 @@ Route::middleware(['bloginauth'])->group(function () {
496 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save'); 501 Route::any('/save', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'save'])->name('custom_content_save');
497 Route::any('/sort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'sort'])->name('custom_content_sort'); 502 Route::any('/sort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'sort'])->name('custom_content_sort');
498 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del'); 503 Route::any('/del', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'del'])->name('custom_content_del');
  504 + Route::any('/allSort', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'allSort'])->name('custom_content_allSort');
  505 + Route::any('/copyModuleContent', [\App\Http\Controllers\Bside\CustomModule\CustomModuleContentController::class, 'copyModuleContent'])->name('custom_content_copyModuleContent');
499 }); 506 });
500 507
501 Route::prefix('extend')->group(function () { 508 Route::prefix('extend')->group(function () {