正在显示
1 个修改的文件
包含
448 行增加
和
0 行删除
app/Services/GeneratePageService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GeneratePageService.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/2/19 15:54 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services; | ||
| 11 | + | ||
| 12 | +use App\Models\CustomModule\CustomModule; | ||
| 13 | +use App\Models\CustomModule\CustomModuleCategory; | ||
| 14 | +use App\Models\CustomModule\CustomModuleContent; | ||
| 15 | +use App\Models\Project\Project; | ||
| 16 | +use App\Models\RouteMap\RouteMap; | ||
| 17 | +use App\Models\Template\BTemplate; | ||
| 18 | +use App\Models\Template\BTemplateCommon; | ||
| 19 | +use App\Models\Template\BTemplateMain; | ||
| 20 | +use App\Models\Template\Setting; | ||
| 21 | +use App\Models\Template\Template; | ||
| 22 | +use App\Models\Template\TemplateTypeMain; | ||
| 23 | +use Illuminate\Support\Facades\DB; | ||
| 24 | + | ||
| 25 | +class GeneratePageService | ||
| 26 | +{ | ||
| 27 | + protected $route; | ||
| 28 | + | ||
| 29 | + protected $param; | ||
| 30 | + | ||
| 31 | + protected $project_id = 0; | ||
| 32 | + public function __construct(){ | ||
| 33 | + $this->param = request()->all(); | ||
| 34 | + $this->route = $this->param['route']; | ||
| 35 | + $this->project_id = $this->param['project_id']; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @remark :生成单页数据 | ||
| 40 | + * @name :generateHtml | ||
| 41 | + * @author :lyh | ||
| 42 | + * @method :post | ||
| 43 | + * @time :2024/2/19 16:57 | ||
| 44 | + */ | ||
| 45 | + public function generateHtml(){ | ||
| 46 | + ProjectServer::useProject($this->project_id); | ||
| 47 | + //生成单页数据 | ||
| 48 | + $this->handleParam($this->param['route']); | ||
| 49 | + return $this->getTemplateHtml(); | ||
| 50 | + DB::disconnect('custom_mysql'); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * @remark :生成页面参数处理 | ||
| 55 | + * @name :generateHtml | ||
| 56 | + * @author :lyh | ||
| 57 | + * @method :post | ||
| 58 | + * @time :2024/2/19 16:36 | ||
| 59 | + */ | ||
| 60 | + public function handleParam($route){ | ||
| 61 | + $routeMapModel = new RouteMap(); | ||
| 62 | + $routeInfo = $routeMapModel->read(['route'=>$route]); | ||
| 63 | + switch ($routeInfo['source']){ | ||
| 64 | + case $routeMapModel::SOURCE_PRODUCT: | ||
| 65 | + $this->param['source'] = BTemplate::SOURCE_PRODUCT; | ||
| 66 | + $this->param['is_list'] = BTemplate::IS_DETAIL; | ||
| 67 | + break; | ||
| 68 | + case $routeMapModel::SOURCE_PRODUCT_CATE: | ||
| 69 | + $this->param['source'] = BTemplate::SOURCE_PRODUCT; | ||
| 70 | + $this->param['is_list'] = BTemplate::IS_LIST; | ||
| 71 | + break; | ||
| 72 | + case $routeMapModel::SOURCE_BLOG: | ||
| 73 | + $this->param['source'] = BTemplate::SOURCE_BLOG; | ||
| 74 | + $this->param['is_list'] = BTemplate::IS_DETAIL; | ||
| 75 | + break; | ||
| 76 | + case $routeMapModel::SOURCE_BLOG_CATE: | ||
| 77 | + $this->param['source'] = BTemplate::SOURCE_BLOG; | ||
| 78 | + $this->param['is_list'] = BTemplate::IS_LIST; | ||
| 79 | + break; | ||
| 80 | + case $routeMapModel::SOURCE_NEWS: | ||
| 81 | + $this->param['source'] = BTemplate::SOURCE_NEWS; | ||
| 82 | + $this->param['is_list'] = BTemplate::IS_DETAIL; | ||
| 83 | + break; | ||
| 84 | + case $routeMapModel::SOURCE_NEWS_CATE: | ||
| 85 | + $this->param['source'] = BTemplate::SOURCE_NEWS; | ||
| 86 | + $this->param['is_list'] = BTemplate::IS_LIST; | ||
| 87 | + break; | ||
| 88 | + case $routeMapModel::SOURCE_MODULE: | ||
| 89 | + $this->param['is_custom'] = BTemplate::IS_CUSTOM; | ||
| 90 | + //TODO::获取对应模块数据 | ||
| 91 | + $moduleModel = new CustomModuleContent(); | ||
| 92 | + $moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']); | ||
| 93 | + $this->param['source'] = $moduleInfo['id'] ?? 0; | ||
| 94 | + $this->param['is_list'] = BTemplate::IS_DETAIL; | ||
| 95 | + break; | ||
| 96 | + case $routeMapModel::SOURCE_MODULE_CATE: | ||
| 97 | + $this->param['is_custom'] = BTemplate::IS_CUSTOM; | ||
| 98 | + //TODO::获取对应模块数据 | ||
| 99 | + $moduleModel = new CustomModuleCategory(); | ||
| 100 | + $moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']); | ||
| 101 | + $this->param['source'] = $moduleInfo['id'] ?? 0; | ||
| 102 | + $this->param['is_list'] = BTemplate::IS_LIST; | ||
| 103 | + break; | ||
| 104 | + case $routeMapModel::SOURCE_PAGE: | ||
| 105 | + //TODO::单独处理 | ||
| 106 | + if($routeInfo['source_id'] == 0){ | ||
| 107 | + $this->param['source'] = BTemplate::SOURCE_HOME; | ||
| 108 | + $this->param['is_list'] = BTemplate::IS_DETAIL; | ||
| 109 | + } | ||
| 110 | + break; | ||
| 111 | + default: | ||
| 112 | + break; | ||
| 113 | + return true; | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * @notes: 请简要描述方法功能 | ||
| 119 | + * @param array $data | ||
| 120 | + * @return array | ||
| 121 | + */ | ||
| 122 | + public function success($data = []) | ||
| 123 | + { | ||
| 124 | + return $data; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * @remark :获取html | ||
| 129 | + * @name :getTemplateHtml | ||
| 130 | + * @author :lyh | ||
| 131 | + * @method :post | ||
| 132 | + */ | ||
| 133 | + public function getTemplateHtml(){ | ||
| 134 | + $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块 | ||
| 135 | + $is_list = $this->param['is_list'] ?? 0;//是否为列表页 | ||
| 136 | + $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id | ||
| 137 | + $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list); | ||
| 138 | + if($templateInfo === false){ | ||
| 139 | + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据 | ||
| 140 | + $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list); | ||
| 141 | + if($html !== false){ | ||
| 142 | + return $this->success($html); | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + //非定制初始中间部分 | ||
| 146 | + $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码 | ||
| 147 | + }else{ | ||
| 148 | + if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码 | ||
| 149 | + return $this->getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list); | ||
| 150 | + } | ||
| 151 | + $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; | ||
| 152 | + } | ||
| 153 | + $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部 | ||
| 154 | + $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; | ||
| 155 | + $html = $this->getHeadFooter($html); | ||
| 156 | + $result = ['html'=>$html,'template_id'=>$template_id]; | ||
| 157 | + return $this->success($result); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + /** | ||
| 161 | + * @remark :获取整个html代码 | ||
| 162 | + * @name :getCustomizeAllHtml | ||
| 163 | + * @author :lyh | ||
| 164 | + * @method :post | ||
| 165 | + * @time :2024/1/10 14:15 | ||
| 166 | + */ | ||
| 167 | + public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){ | ||
| 168 | + if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 169 | + $commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部 | ||
| 170 | + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); | ||
| 171 | + }else{ | ||
| 172 | + $type = $this->getCustomizedType($this->param['source'],$is_list); | ||
| 173 | + $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 | ||
| 174 | + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); | ||
| 175 | + } | ||
| 176 | + return $this->success(['html'=>$html,'template_id'=>$template_id]); | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + /** | ||
| 180 | + * @remark :获取装修详情 | ||
| 181 | + * @name :webTemplateInfo | ||
| 182 | + * @author :lyh | ||
| 183 | + * @method :post | ||
| 184 | + * @time :2024/1/10 13:43 | ||
| 185 | + */ | ||
| 186 | + public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){ | ||
| 187 | + $templateInfo = $this->model->read([ | ||
| 188 | + 'template_id'=>$template_id, 'source'=>$source, | ||
| 189 | + 'project_id'=>$this->user['project_id'], 'source_id'=>$source_id, | ||
| 190 | + 'is_custom'=>$is_custom, 'is_list'=>$is_list | ||
| 191 | + ]); | ||
| 192 | + return $this->success($templateInfo); | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * @remark :定制页面获取html | ||
| 197 | + * @name :customizedReturnHtml | ||
| 198 | + * @author :lyh | ||
| 199 | + * @method :post | ||
| 200 | + * @time :2024/1/10 13:46 | ||
| 201 | + */ | ||
| 202 | + public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){ | ||
| 203 | + //TODO::扩展模块定制单独处理 | ||
| 204 | + if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 205 | + $customModuleModel = new CustomModule(); | ||
| 206 | + $info = $customModuleModel->read(['id'=>$source]); | ||
| 207 | + if($info === false){ | ||
| 208 | + $this->fail('当前扩展模块不存在或已被删除'); | ||
| 209 | + } | ||
| 210 | + //扩展模块定制 | ||
| 211 | + if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){ | ||
| 212 | + $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); | ||
| 213 | + return $this->success(['html'=>$html,'template_id'=>$template_id]); | ||
| 214 | + } | ||
| 215 | + if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ | ||
| 216 | + $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); | ||
| 217 | + return $this->success(['html'=>$html,'template_id'=>$template_id]); | ||
| 218 | + } | ||
| 219 | + return false; | ||
| 220 | + } | ||
| 221 | + //TODO::默认模块定制 | ||
| 222 | + $html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html | ||
| 223 | + if(!empty($html)){ | ||
| 224 | + return $this->success(['html'=>$html,'template_id'=>$template_id]); | ||
| 225 | + } | ||
| 226 | + return false; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /** | ||
| 230 | + * @remark :扩展模块定制html | ||
| 231 | + * @name :customModuleInfo | ||
| 232 | + * @author :lyh | ||
| 233 | + * @method :post | ||
| 234 | + * @time :2024/1/10 9:20 | ||
| 235 | + */ | ||
| 236 | + public function customModuleCustomizeHtml($source,$is_list,$is_custom){ | ||
| 237 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 238 | + //TODO::获取初始代码 | ||
| 239 | + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]); | ||
| 240 | + if($customHtmlInfo === false){ | ||
| 241 | + $this->fail('定制页面,请先上传代码块'); | ||
| 242 | + } | ||
| 243 | + $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部 | ||
| 244 | + if($commonInfo !== false){ | ||
| 245 | + $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); | ||
| 246 | + } | ||
| 247 | + return $customHtmlInfo['main_html']; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + /** | ||
| 251 | + * @remark :获取中间部分的html | ||
| 252 | + * @name :getMAinHtml | ||
| 253 | + * @author :lyh | ||
| 254 | + * @method :post | ||
| 255 | + * @time :2023/12/27 15:00 | ||
| 256 | + */ | ||
| 257 | + public function getMAinHtml($type,$is_custom,$is_list){ | ||
| 258 | + //获取设置的默认中间部分 | ||
| 259 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 260 | + $mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]); | ||
| 261 | + if($mainInfo === false){ | ||
| 262 | + $main_html = $this->getInitModule($type,$is_custom,$is_list); | ||
| 263 | + $main_css = "<style id='globalsojs-styles'></style>"; | ||
| 264 | + }else{ | ||
| 265 | + $main_html = $mainInfo['main_html']; | ||
| 266 | + $main_css = $mainInfo['main_css']; | ||
| 267 | + } | ||
| 268 | + return ['main_html'=>$main_html,'main_css'=>$main_css]; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + /** | ||
| 272 | + * @remark :默认复合页数据 | ||
| 273 | + * @name :getProductModule | ||
| 274 | + * @author :lyh | ||
| 275 | + * @method :post | ||
| 276 | + * @time :2023/7/27 15:08 | ||
| 277 | + */ | ||
| 278 | + public function getInitModule($type,$is_custom,$is_list){ | ||
| 279 | + if($is_custom == BTemplate::IS_CUSTOM) { | ||
| 280 | + $type = BTemplate::SOURCE_CUSTOM; | ||
| 281 | + } | ||
| 282 | + $mainModel = new TemplateTypeMain(); | ||
| 283 | + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]); | ||
| 284 | + return $info['main_html']; | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + /** | ||
| 288 | + * @remark :返回整个html截取代码 | ||
| 289 | + * @name :handleAllHtml | ||
| 290 | + * @author :lyh | ||
| 291 | + * @method :post | ||
| 292 | + * @time :2023/12/13 15:39 | ||
| 293 | + */ | ||
| 294 | + public function handleAllHtml($commonInfo,$html){ | ||
| 295 | + if(!empty($commonInfo)){ | ||
| 296 | + $html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html); | ||
| 297 | + $html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html); | ||
| 298 | + $html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html); | ||
| 299 | + $html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html); | ||
| 300 | + } | ||
| 301 | + return $html; | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + /** | ||
| 305 | + * @remark :页面是否为定制页面获取初始代码 | ||
| 306 | + * @name :watchProjectIsCustomized | ||
| 307 | + * @author :lyh | ||
| 308 | + * @method :post | ||
| 309 | + * @time :2023/12/13 10:55 | ||
| 310 | + */ | ||
| 311 | + public function isCustomizedPage($source,$is_list,$is_custom) | ||
| 312 | + { | ||
| 313 | + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 | ||
| 314 | + //查看当前页面是否定制,是否开启可视化 | ||
| 315 | + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 | ||
| 316 | + if (in_array($type, $page_array)) {//是定制界面 | ||
| 317 | + //TODO::获取初始代码 | ||
| 318 | + $bTemplateMainModel = new BTemplateMain(); | ||
| 319 | + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]); | ||
| 320 | + if($customHtmlInfo === false){ | ||
| 321 | + $this->fail('定制页面,请先上传代码块'); | ||
| 322 | + } | ||
| 323 | + $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 | ||
| 324 | + if($commonInfo !== false){ | ||
| 325 | + $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); | ||
| 326 | + } | ||
| 327 | + return $customHtmlInfo['main_html']; | ||
| 328 | + } | ||
| 329 | + return false; | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + /** | ||
| 333 | + * @remark :定制项目获取头部底部 | ||
| 334 | + * @name :getCustomizedCommonHtml | ||
| 335 | + * @author :lyh | ||
| 336 | + * @method :post | ||
| 337 | + * @time :2023/12/29 13:13 | ||
| 338 | + */ | ||
| 339 | + public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){ | ||
| 340 | + $data = [ | ||
| 341 | + 'template_id' => 0, | ||
| 342 | + 'project_id' => $this->user['project_id'], | ||
| 343 | + 'type'=>$type, | ||
| 344 | + 'is_custom'=>$is_custom, | ||
| 345 | + 'is_list'=>$is_list | ||
| 346 | + ]; | ||
| 347 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 348 | + return $commonTemplateModel->read($data); | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + /** | ||
| 352 | + * @remark :定制页面头部类型---根据source获取type类型 | ||
| 353 | + * @name :getType | ||
| 354 | + * @author :lyh | ||
| 355 | + * @method :post | ||
| 356 | + * @time :2023/11/16 11:20 | ||
| 357 | + */ | ||
| 358 | + public function getCustomizedType($source,$is_list){ | ||
| 359 | + $type = BTemplate::TYPE_HOME; | ||
| 360 | + if($source == BTemplate::SOURCE_PRODUCT){ | ||
| 361 | + if($is_list == BTemplate::IS_LIST){ | ||
| 362 | + $type = BTemplate::TYPE_PRODUCT_LIST; | ||
| 363 | + }else{ | ||
| 364 | + $type = BTemplate::TYPE_PRODUCT_DETAIL; | ||
| 365 | + } | ||
| 366 | + } | ||
| 367 | + if($source == BTemplate::SOURCE_BLOG){ | ||
| 368 | + if($is_list == BTemplate::IS_LIST){ | ||
| 369 | + $type = BTemplate::TYPE_BLOG_LIST; | ||
| 370 | + }else{ | ||
| 371 | + $type = BTemplate::TYPE_BLOG_DETAIL; | ||
| 372 | + } | ||
| 373 | + } | ||
| 374 | + if($source == BTemplate::SOURCE_NEWS){ | ||
| 375 | + if($is_list == BTemplate::IS_LIST){ | ||
| 376 | + $type = BTemplate::TYPE_NEWS_LIST; | ||
| 377 | + }else{ | ||
| 378 | + $type = BTemplate::TYPE_NEWS_DETAIL; | ||
| 379 | + } | ||
| 380 | + } | ||
| 381 | + return $type; | ||
| 382 | + } | ||
| 383 | + | ||
| 384 | + /** | ||
| 385 | + * @remark :获取当前项目设置的模版 | ||
| 386 | + * @name :getSettingTemplate | ||
| 387 | + * @author :lyh | ||
| 388 | + * @method :post | ||
| 389 | + * @time :2023/12/13 10:48 | ||
| 390 | + */ | ||
| 391 | + public function getSettingTemplate($source,$is_list,$is_custom){ | ||
| 392 | + $template_id = 0; | ||
| 393 | + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目 | ||
| 394 | + if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 395 | + $customModuleModel = new CustomModule(); | ||
| 396 | + $info = $customModuleModel->read(['id'=>$source]); | ||
| 397 | + if($info === false){ | ||
| 398 | + return false; | ||
| 399 | + } | ||
| 400 | + if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){ | ||
| 401 | + return $this->success($template_id); | ||
| 402 | + } | ||
| 403 | + if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){ | ||
| 404 | + return $this->success($template_id); | ||
| 405 | + } | ||
| 406 | + }else{ | ||
| 407 | + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 | ||
| 408 | + //查看当前页面是否定制,是否开启可视化 | ||
| 409 | + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 | ||
| 410 | + if (in_array($type, $page_array)) {//是定制界面 | ||
| 411 | + return $this->success($template_id); | ||
| 412 | + } | ||
| 413 | + } | ||
| 414 | + } | ||
| 415 | + $bSettingModel = new Setting(); | ||
| 416 | + $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 417 | + if($info === false){ | ||
| 418 | + $this->fail('请先选择模版'); | ||
| 419 | + } | ||
| 420 | + $template_id = $info['template_id']; | ||
| 421 | + return $this->success($template_id); | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + /** | ||
| 425 | + * @remark :根据类型获取公共头和底 | ||
| 426 | + * @name :getCommonPage | ||
| 427 | + * @author :lyh | ||
| 428 | + * @method :post | ||
| 429 | + * @time :2023/10/21 16:55 | ||
| 430 | + */ | ||
| 431 | + public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){ | ||
| 432 | + $type = $this->getType($source,$is_list,$is_custom); | ||
| 433 | + $data = [ | ||
| 434 | + 'template_id' => $template_id, | ||
| 435 | + 'project_id' => $this->user['project_id'], | ||
| 436 | + 'type'=>$type, | ||
| 437 | + 'is_custom'=>0, | ||
| 438 | + ]; | ||
| 439 | + $commonTemplateModel = new BTemplateCommon(); | ||
| 440 | + $commonInfo = $commonTemplateModel->read($data); | ||
| 441 | + if($commonInfo === false){ | ||
| 442 | + $data['type'] = BTemplate::SOURCE_HOME; | ||
| 443 | + $commonInfo = $commonTemplateModel->read($data); | ||
| 444 | + } | ||
| 445 | + return $this->success($commonInfo); | ||
| 446 | + } | ||
| 447 | + | ||
| 448 | +} |
-
请 注册 或 登录 后发表评论