作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

@@ -246,6 +246,7 @@ class OptimizeController extends BaseController @@ -246,6 +246,7 @@ class OptimizeController extends BaseController
246 if($rs === false){ 246 if($rs === false){
247 $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR); 247 $this->response('系统错误,请联系管理员',Code::SYSTEM_ERROR);
248 } 248 }
  249 + //TODO::通知C端
249 $this->response('success'); 250 $this->response('success');
250 } 251 }
251 } 252 }
@@ -24,7 +24,7 @@ class BTemplateModuleController extends BaseController @@ -24,7 +24,7 @@ class BTemplateModuleController extends BaseController
24 */ 24 */
25 public function lists(BTemplateModuleLogic $BTemplateModuleLogic){ 25 public function lists(BTemplateModuleLogic $BTemplateModuleLogic){
26 if(!isset($this->map['test_model'])){ 26 if(!isset($this->map['test_model'])){
27 - $this->map['test_model'] = 0; 27 + $this->map['test_model'] = ['in',[0,1]];
28 } 28 }
29 $data = []; 29 $data = [];
30 $list = $BTemplateModuleLogic->ModuleList($this->map,$this->order); 30 $list = $BTemplateModuleLogic->ModuleList($this->map,$this->order);
@@ -60,6 +60,10 @@ class BTemplateLogLogic extends BaseLogic @@ -60,6 +60,10 @@ class BTemplateLogLogic extends BaseLogic
60 $commonData = $this->setCommonParam($info); 60 $commonData = $this->setCommonParam($info);
61 $commonTemplateModel = new BTemplateCommon(); 61 $commonTemplateModel = new BTemplateCommon();
62 $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]); 62 $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
  63 + //更新所有界面的other
  64 + if(!empty($info['other'])){
  65 + $commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
  66 + }
63 }catch (\Exception $e){ 67 }catch (\Exception $e){
64 $this->fail('系统错误,请联系管理员'); 68 $this->fail('系统错误,请联系管理员');
65 } 69 }
@@ -93,7 +97,7 @@ class BTemplateLogLogic extends BaseLogic @@ -93,7 +97,7 @@ class BTemplateLogLogic extends BaseLogic
93 'head_html'=>$info['head_html'], 97 'head_html'=>$info['head_html'],
94 'head_css'=>$info['head_css'], 98 'head_css'=>$info['head_css'],
95 'footer_html'=>$info['footer_html'], 99 'footer_html'=>$info['footer_html'],
96 - 'footer_css'=>$info['footer_css'], 100 + 'footer_css'=>$info['footer_css']
97 ]; 101 ];
98 return $this->success($data); 102 return $this->success($data);
99 } 103 }
@@ -110,12 +114,22 @@ class BTemplateLogLogic extends BaseLogic @@ -110,12 +114,22 @@ class BTemplateLogLogic extends BaseLogic
110 if($info === false){ 114 if($info === false){
111 $this->fail('当前数据不存在,或已被删除'); 115 $this->fail('当前数据不存在,或已被删除');
112 } 116 }
  117 + if(empty($info['other'])){
  118 + $info['other'] = str_replace('<header','',characterTruncation($info['text'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));;
  119 + }
  120 + $html = $info['head_css'].$info['main_css'].$info['footer_css'].$info['other'].
  121 + $info['head_html'].$info['main_html'].$info['footer_html'];
113 $serviceSettingModel = new ServiceSettingModel(); 122 $serviceSettingModel = new ServiceSettingModel();
114 $list = $serviceSettingModel->list(['type'=>2],'created_at'); 123 $list = $serviceSettingModel->list(['type'=>2],'created_at');
115 - $data = [  
116 - 'info' => $info,  
117 - 'header_footer'=>$list,  
118 - ];  
119 - return $this->success($data); 124 + //拼接html
  125 + foreach ($list as $v){
  126 + if($v['key'] == 'head'){
  127 + $html = $v['values'].$html;
  128 + }
  129 + if($v['key'] == 'footer'){
  130 + $html = $html.$v['values'];
  131 + }
  132 + }
  133 + return $this->success(['html'=>$html]);
120 } 134 }
121 } 135 }
@@ -335,6 +335,7 @@ class BTemplateLogic extends BaseLogic @@ -335,6 +335,7 @@ class BTemplateLogic extends BaseLogic
335 'main_css'=>$param['main_css'], 335 'main_css'=>$param['main_css'],
336 'footer_html'=>$param['footer_html'], 336 'footer_html'=>$param['footer_html'],
337 'footer_css'=>$param['footer_css'], 337 'footer_css'=>$param['footer_css'],
  338 + 'other'=> str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"))
338 ]; 339 ];
339 $bTemplateLogModel = new BTemplateLog(); 340 $bTemplateLogModel = new BTemplateLog();
340 return $bTemplateLogModel->add($data); 341 return $bTemplateLogModel->add($data);
@@ -8,6 +8,7 @@ use App\Models\RouteMap\RouteMap; @@ -8,6 +8,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\BTemplateCommon; 10 use App\Models\Template\BTemplateCommon;
  11 +use App\Models\Template\BTemplateLog;
11 use App\Models\Template\Setting; 12 use App\Models\Template\Setting;
12 use App\Models\Template\BTemplate; 13 use App\Models\Template\BTemplate;
13 14
@@ -94,9 +95,16 @@ class CustomTemplateLogic extends BaseLogic @@ -94,9 +95,16 @@ class CustomTemplateLogic extends BaseLogic
94 $html = $this->param['html']; 95 $html = $this->param['html'];
95 $info = $this->model->read(['id'=>$this->param['id']],['id','is_visualization','url']); 96 $info = $this->model->read(['id'=>$this->param['id']],['id','is_visualization','url']);
96 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){//非定制项目+可视化页面 97 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){//非定制项目+可视化页面
97 - $this->saveCommonTemplate($html); 98 + //获取设置的默认模版
  99 + $bSettingModel = new Setting();
  100 + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
  101 + if($bSettingInfo === false){
  102 + $this->fail('请先选择模版');
  103 + }
  104 + $this->saveCommonTemplate($html,$bSettingInfo['template_id']);
98 $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); 105 $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
99 $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); 106 $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
  107 + $this->setTemplateLog($bSettingInfo['template_id'],$html,$this->param['id']);
100 } 108 }
101 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 109 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
102 if($rs === false){ 110 if($rs === false){
@@ -108,19 +116,44 @@ class CustomTemplateLogic extends BaseLogic @@ -108,19 +116,44 @@ class CustomTemplateLogic extends BaseLogic
108 } 116 }
109 117
110 /** 118 /**
  119 + * @remark :生成记录
  120 + * @name :setTemplateLog
  121 + * @author :lyh
  122 + * @method :post
  123 + * @time :2023/8/23 11:16
  124 + */
  125 + public function setTemplateLog($template_id,$html,$source_id){
  126 + $data = [
  127 + 'template_id'=>$template_id,
  128 + 'project_id'=>$this->user['project_id'],
  129 + 'operator_id'=>$this->user['id'],
  130 + 'text'=>$html,
  131 + 'source'=>9,
  132 + 'source_id'=>$source_id,
  133 + 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
  134 + 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
  135 + 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
  136 + 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
  137 + 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
  138 + 'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
  139 + 'other'=> str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"))
  140 + ];
  141 + $bTemplateLogModel = new BTemplateLog();
  142 + return $bTemplateLogModel->add($data);
  143 + }
  144 +
  145 + /**
111 * @remark :保存头部公共数据 146 * @remark :保存头部公共数据
112 * @name :saveCommonTemplate 147 * @name :saveCommonTemplate
113 * @author :lyh 148 * @author :lyh
114 * @method :post 149 * @method :post
115 * @time :2023/10/13 14:27 150 * @time :2023/10/13 14:27
116 */ 151 */
117 - public function saveCommonTemplate($html){ 152 + public function saveCommonTemplate($html,$template_id){
118 $type = $this->getType(); 153 $type = $this->getType();
119 - //获取设置的默认模版  
120 - $bSettingModel = new Setting();  
121 - $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 154 +
122 $templateCommonModel = new BTemplateCommon(); 155 $templateCommonModel = new BTemplateCommon();
123 - $info = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]); 156 + $info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
124 $data = [ 157 $data = [
125 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), 158 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
126 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), 159 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
@@ -129,7 +162,7 @@ class CustomTemplateLogic extends BaseLogic @@ -129,7 +162,7 @@ class CustomTemplateLogic extends BaseLogic
129 ]; 162 ];
130 $other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")); 163 $other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
131 if($info === false){ 164 if($info === false){
132 - $data['template_id'] = $bSettingInfo['template_id']; 165 + $data['template_id'] = $template_id;
133 $data['project_id'] = $this->user['project_id']; 166 $data['project_id'] = $this->user['project_id'];
134 $data['type'] = $type; 167 $data['type'] = $type;
135 $templateCommonModel->add($data); 168 $templateCommonModel->add($data);