作者 lyh

gx

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Template; @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bside\Template;
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic; 7 use App\Http\Logic\Bside\BTemplate\BTemplateModuleLogic;
  8 +use App\Http\Logic\Bside\BTemplate\BTemplateModuleProjectLogic;
8 use App\Models\Template\BModuleProject; 9 use App\Models\Template\BModuleProject;
9 10
10 /** 11 /**
@@ -22,15 +23,14 @@ class BTemplateModuleController extends BaseController @@ -22,15 +23,14 @@ class BTemplateModuleController extends BaseController
22 * @method :post 23 * @method :post
23 * @time :2023/6/29 11:33 24 * @time :2023/6/29 11:33
24 */ 25 */
25 - public function lists(BTemplateModuleLogic $BTemplateModuleLogic){ 26 + public function lists(BTemplateModuleLogic $bTemplateModuleLogic,BTemplateModuleProjectLogic $bTemplateModuleProjectLogic){
26 if(!isset($this->map['test_model'])){ 27 if(!isset($this->map['test_model'])){
27 $this->map['test_model'] = ['in',[0,1]]; 28 $this->map['test_model'] = ['in',[0,1]];
28 } 29 }
29 $data = []; 30 $data = [];
30 - $list = $BTemplateModuleLogic->ModuleList($this->map,$this->order); 31 + $list = $bTemplateModuleLogic->ModuleList($this->map,$this->order);
31 $data['list'] = $list; 32 $data['list'] = $list;
32 - $moduleProjectModel = new BModuleProject();  
33 - $module_list = $moduleProjectModel->list(['project_id'=>$this->user['project_id']]); 33 + $module_list = $bTemplateModuleProjectLogic->ModuleList(['project_id'=>$this->user['project_id']]);
34 $data['module_list'] = $module_list; 34 $data['module_list'] = $module_list;
35 $this->response('success',Code::SUCCESS,$data); 35 $this->response('success',Code::SUCCESS,$data);
36 } 36 }
@@ -22,6 +22,19 @@ class BTemplateModuleProjectLogic extends BaseLogic @@ -22,6 +22,19 @@ class BTemplateModuleProjectLogic extends BaseLogic
22 } 22 }
23 23
24 /** 24 /**
  25 + * @remark :获取左侧模块列表
  26 + * @name :ModuleList
  27 + * @author :lyh
  28 + * @method :post
  29 + * @time :2023/6/29 13:35
  30 + */
  31 + public function ModuleList($map,$order = 'created_at',$filed = ['id','name','sort','status','image','html']){
  32 + $map['status'] = 0;
  33 + $lists = $this->model->list($map,$order,$filed);
  34 + return $this->success($lists);
  35 + }
  36 +
  37 + /**
25 * @remark :保存私有化左侧模块 38 * @remark :保存私有化左侧模块
26 * @name :moduleProjectSave 39 * @name :moduleProjectSave
27 * @author :lyh 40 * @author :lyh
@@ -284,46 +284,71 @@ class VisualizationLogic extends BaseLogic @@ -284,46 +284,71 @@ class VisualizationLogic extends BaseLogic
284 $type = $this->getType($this->param['source'],$this->param['source_id']); 284 $type = $this->getType($this->param['source'],$this->param['source_id']);
285 try { 285 try {
286 if(in_array($type,$page_array)){//定制页面 286 if(in_array($type,$page_array)){//定制页面
287 - $bTemplateModel = new BTemplate();  
288 - $templateInfo = $bTemplateModel->read([  
289 - 'source'=>$this->param['source'],  
290 - 'project_id'=>$this->user['project_id'],  
291 - 'source_id'=>$this->param['source_id'],  
292 - 'template_id'=>0  
293 - ]);  
294 - if($templateInfo === false){  
295 - $this->param['project_id'] = $this->user['project_id'];  
296 - $this->param['template_id'] = 0;  
297 - $bTemplateModel->add($this->param);  
298 - }else{  
299 - $bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);  
300 - } 287 + $this->saveVisualizationHtml();
301 }else{ 288 }else{
302 - $bTemplateModel = new BTemplate();  
303 - $templateInfo = $bTemplateModel->read([  
304 - 'source'=>$this->param['source'],  
305 - 'project_id'=>$this->user['project_id'],  
306 - 'source_id'=>$this->param['source_id'],  
307 - 'template_id'=>$this->param['template_id'],  
308 - ]);  
309 - $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');  
310 - $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');  
311 - //保存头部  
312 - $this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);  
313 - if($templateInfo === false){  
314 - $this->param['project_id'] = $this->user['project_id'];  
315 - $bTemplateModel->add($this->param);  
316 - }else{  
317 - $bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);  
318 - }  
319 - $this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);  
320 - $this->homeOrProduct($this->param['source'],$this->param['source_id']); 289 + $this->saveTemplateHtml();
321 } 290 }
322 }catch (\Exception $e){ 291 }catch (\Exception $e){
323 $this->fail('系统错误,请联系管理员'); 292 $this->fail('系统错误,请联系管理员');
324 } 293 }
325 return $this->success(); 294 return $this->success();
  295 + }
326 296
  297 + /**
  298 + * @remark :保存定制界面
  299 + * @name :saveVisualizationHtml
  300 + * @author :lyh
  301 + * @method :post
  302 + * @time :2023/12/5 15:42
  303 + */
  304 + public function saveVisualizationHtml(){
  305 + $bTemplateModel = new BTemplate();
  306 + $templateInfo = $bTemplateModel->read([
  307 + 'source'=>$this->param['source'], 'project_id'=>$this->user['project_id'],
  308 + 'source_id'=>$this->param['source_id'], 'template_id'=>0
  309 + ]);
  310 + if($templateInfo === false){
  311 + $this->param['project_id'] = $this->user['project_id'];
  312 + $this->param['template_id'] = 0;
  313 +// $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
  314 +// $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  315 + $bTemplateModel->add($this->param);
  316 + }else{
  317 +// $param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
  318 +// $param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  319 + $param['html'] = $this->param['html'];
  320 + $bTemplateModel->edit($param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);
  321 + }
  322 + return $this->success();
  323 + }
  324 +
  325 + /**
  326 + * @remark :非定制界面保存数据
  327 + * @name :saveTemplateHtml
  328 + * @author :lyh
  329 + * @method :post
  330 + * @time :2023/12/5 15:44
  331 + */
  332 + public function saveTemplateHtml(){
  333 + $bTemplateModel = new BTemplate();
  334 + $templateInfo = $bTemplateModel->read([
  335 + 'source'=>$this->param['source'],
  336 + 'project_id'=>$this->user['project_id'],
  337 + 'source_id'=>$this->param['source_id'],
  338 + 'template_id'=>$this->param['template_id'],
  339 + ]);
  340 + $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
  341 + $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  342 + //保存头部
  343 + $this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
  344 + if($templateInfo === false){
  345 + $this->param['project_id'] = $this->user['project_id'];
  346 + $bTemplateModel->add($this->param);
  347 + }else{
  348 + $bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
  349 + }
  350 + $this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);
  351 + $this->homeOrProduct($this->param['source'],$this->param['source_id']);
327 } 352 }
328 353
329 /** 354 /**
@@ -63,13 +63,12 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -63,13 +63,12 @@ class CustomModuleCategoryLogic extends BaseLogic
63 public function categoryAdd(){ 63 public function categoryAdd(){
64 try { 64 try {
65 $id = $this->model->addReturnId($this->param); 65 $id = $this->model->addReturnId($this->param);
66 - $route = RouteMap::setRoute($this->param['route'], 'module-'.$this->param['module_id'], $id, $this->user['project_id']);  
67 - $this->addUpdateNotify(RouteMap::SOURCE_NEWS,$route); 66 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']);
  67 + $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
68 $this->edit(['url' => $route], ['id' => $id]); 68 $this->edit(['url' => $route], ['id' => $id]);
69 }catch (\Exception $e){ 69 }catch (\Exception $e){
70 $this->fail('系统错误,请联系管理员'); 70 $this->fail('系统错误,请联系管理员');
71 } 71 }
72 -  
73 return $this->success(); 72 return $this->success();
74 } 73 }
75 74
@@ -81,6 +80,8 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -81,6 +80,8 @@ class CustomModuleCategoryLogic extends BaseLogic
81 * @time :2023/12/5 10:55 80 * @time :2023/12/5 10:55
82 */ 81 */
83 public function categoryEdit(){ 82 public function categoryEdit(){
  83 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $this->param['id'], $this->user['project_id']);
  84 + $this->editNewsRoute($this->param['id'],$route);
84 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 85 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
85 if($rs === false){ 86 if($rs === false){
86 $this->fail('系统错误,请连续管理员'); 87 $this->fail('系统错误,请连续管理员');
@@ -89,6 +90,24 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -89,6 +90,24 @@ class CustomModuleCategoryLogic extends BaseLogic
89 } 90 }
90 91
91 /** 92 /**
  93 + * @remark :查看是否编辑路由
  94 + * @name :editCategoryRoute
  95 + * @author :lyh
  96 + * @method :post
  97 + * @time :2023/9/7 11:05
  98 + */
  99 + public function editNewsRoute($id, $route)
  100 + {
  101 + //生成一条删除路由记录
  102 + $info = $this->model->read(['id' => $id], ['id', 'route']);
  103 + if ($info['route'] != $route) {
  104 + $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
  105 + $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
  106 + }
  107 + return true;
  108 + }
  109 +
  110 + /**
92 * @remark :删除数据 111 * @remark :删除数据
93 * @name :ModuleDel 112 * @name :ModuleDel
94 * @author :lyh 113 * @author :lyh
@@ -96,6 +115,10 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -96,6 +115,10 @@ class CustomModuleCategoryLogic extends BaseLogic
96 * @time :2023/12/4 15:47 115 * @time :2023/12/4 15:47
97 */ 116 */
98 public function customModuleCategoryDel(){ 117 public function customModuleCategoryDel(){
  118 + $info = $this->model->read(['pid' => $this->param['id']], ['id', 'route']);
  119 + if($info === false){
  120 + $this->fail('当前分类拥有下级');
  121 + }
99 $rs = $this->model->del($this->param); 122 $rs = $this->model->del($this->param);
100 if($rs === false){ 123 if($rs === false){
101 $this->fail('系统错误,请连续管理员'); 124 $this->fail('系统错误,请连续管理员');