Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop
正在显示
12 个修改的文件
包含
196 行增加
和
190 行删除
| @@ -435,14 +435,12 @@ function isEnglish($str) { | @@ -435,14 +435,12 @@ function isEnglish($str) { | ||
| 435 | * @method :post | 435 | * @method :post |
| 436 | * @time :2023/6/28 17:39 | 436 | * @time :2023/6/28 17:39 |
| 437 | */ | 437 | */ |
| 438 | -function characterTruncation($string,$startTag,$endTag){ | ||
| 439 | - $startPos = strpos($string, $startTag); | ||
| 440 | - $endPos = strpos($string, $endTag); | ||
| 441 | - if ($startPos !== false && $endPos !== false) { | ||
| 442 | - $startPos += strlen($startTag); | ||
| 443 | - $result = substr($string, $startPos, $endPos - $startPos); | 438 | +function characterTruncation($string,$pattern){ |
| 439 | + preg_match($pattern, $string, $matches); | ||
| 440 | + if (isset($matches[0])) { | ||
| 441 | + $result = $matches[0]; | ||
| 442 | + return $result; // 输出:这是footer标签的内容 | ||
| 444 | } else { | 443 | } else { |
| 445 | - echo "无法找到起始或结束标签"; | 444 | + return ''; |
| 446 | } | 445 | } |
| 447 | - return $result; | ||
| 448 | } | 446 | } |
| @@ -5,7 +5,7 @@ namespace App\Http\Controllers\Bside\Template; | @@ -5,7 +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\BTemplateLogic; | 7 | use App\Http\Logic\Bside\BTemplate\BTemplateLogic; |
| 8 | -use App\Http\Requests\Bside\TemplateRequest; | 8 | +use App\Http\Requests\Bside\Template\TemplateRequest; |
| 9 | 9 | ||
| 10 | class BTemplateController extends BaseController | 10 | class BTemplateController extends BaseController |
| 11 | { | 11 | { |
| @@ -58,13 +58,6 @@ class BTemplateController extends BaseController | @@ -58,13 +58,6 @@ class BTemplateController extends BaseController | ||
| 58 | * @time :2023/6/29 10:02 | 58 | * @time :2023/6/29 10:02 |
| 59 | */ | 59 | */ |
| 60 | public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){ | 60 | public function save(TemplateRequest $templateRequest,BTemplateLogic $BTemplateLogic){ |
| 61 | - if(isset($this->param['id'])){ | ||
| 62 | - $this->request->validate([ | ||
| 63 | - 'id'=>'required' | ||
| 64 | - ],[ | ||
| 65 | - 'id.required' => 'ID不能为空' | ||
| 66 | - ]); | ||
| 67 | - } | ||
| 68 | $templateRequest->validated(); | 61 | $templateRequest->validated(); |
| 69 | $BTemplateLogic->templateSave(); | 62 | $BTemplateLogic->templateSave(); |
| 70 | $this->response('success'); | 63 | $this->response('success'); |
| @@ -25,4 +25,16 @@ class BTemplateModuleController extends BaseController | @@ -25,4 +25,16 @@ class BTemplateModuleController extends BaseController | ||
| 25 | $list = $BTemplateModuleLogic->ModuleList($this->map,$this->page,$this->row,$this->order); | 25 | $list = $BTemplateModuleLogic->ModuleList($this->map,$this->page,$this->row,$this->order); |
| 26 | $this->response('success',Code::SUCCESS,$list); | 26 | $this->response('success',Code::SUCCESS,$list); |
| 27 | } | 27 | } |
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @remark :获取所有模块类型 | ||
| 31 | + * @name :getType | ||
| 32 | + * @author :lyh | ||
| 33 | + * @method :post | ||
| 34 | + * @time :2023/6/29 14:41 | ||
| 35 | + */ | ||
| 36 | + public function getType(BTemplateModuleLogic $BTemplateModuleLogic){ | ||
| 37 | + $list = $BTemplateModuleLogic->ModuleType($this->map); | ||
| 38 | + $this->response('success',Code::SUCCESS,$list); | ||
| 39 | + } | ||
| 28 | } | 40 | } |
| @@ -2,7 +2,9 @@ | @@ -2,7 +2,9 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Bside\Template; | 3 | namespace App\Http\Controllers\Bside\Template; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Code; | ||
| 5 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | +use App\Http\Logic\Bside\BTemplate\CustomTemplateLogic; | ||
| 6 | 8 | ||
| 7 | /** | 9 | /** |
| 8 | * @remark :自定义模块 | 10 | * @remark :自定义模块 |
| @@ -19,8 +21,26 @@ class CustomTemplateController extends BaseController | @@ -19,8 +21,26 @@ class CustomTemplateController extends BaseController | ||
| 19 | * @method :post | 21 | * @method :post |
| 20 | * @time :2023/6/29 9:29 | 22 | * @time :2023/6/29 9:29 |
| 21 | */ | 23 | */ |
| 22 | - public function lists(){ | 24 | + public function lists(CustomTemplateLogic $customTemplateLogic){ |
| 25 | + $lists = $customTemplateLogic->customTemplateLists($this->map,$this->page,$this->row,$this->order); | ||
| 26 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 27 | + } | ||
| 23 | 28 | ||
| 29 | + /** | ||
| 30 | + * @remark :获取当前自定义界面详情 | ||
| 31 | + * @name :read | ||
| 32 | + * @author :lyh | ||
| 33 | + * @method :post | ||
| 34 | + * @time :2023/6/29 16:23 | ||
| 35 | + */ | ||
| 36 | + public function read(CustomTemplateLogic $customTemplateLogic){ | ||
| 37 | + $this->request->validate([ | ||
| 38 | + 'id'=>['required'], | ||
| 39 | + ],[ | ||
| 40 | + 'id.required' => 'ID不能为空', | ||
| 41 | + ]); | ||
| 42 | + $customTemplateLogic->customTemplateInfo(); | ||
| 43 | + $this->response('success'); | ||
| 24 | } | 44 | } |
| 25 | 45 | ||
| 26 | /** | 46 | /** |
| @@ -30,8 +50,9 @@ class CustomTemplateController extends BaseController | @@ -30,8 +50,9 @@ class CustomTemplateController extends BaseController | ||
| 30 | * @method :post | 50 | * @method :post |
| 31 | * @time :2023/6/29 9:30 | 51 | * @time :2023/6/29 9:30 |
| 32 | */ | 52 | */ |
| 33 | - public function save(){ | ||
| 34 | - | 53 | + public function save(CustomTemplateLogic $customTemplateLogic){ |
| 54 | + $customTemplateLogic->customTemplateSave(); | ||
| 55 | + $this->response('success'); | ||
| 35 | } | 56 | } |
| 36 | 57 | ||
| 37 | /** | 58 | /** |
| @@ -41,7 +62,8 @@ class CustomTemplateController extends BaseController | @@ -41,7 +62,8 @@ class CustomTemplateController extends BaseController | ||
| 41 | * @method :post | 62 | * @method :post |
| 42 | * @time :2023/6/29 9:30 | 63 | * @time :2023/6/29 9:30 |
| 43 | */ | 64 | */ |
| 44 | - public function del(){ | ||
| 45 | - | 65 | + public function del(CustomTemplateLogic $customTemplateLogic){ |
| 66 | + $customTemplateLogic->customTemplateDel(); | ||
| 67 | + $this->response('success'); | ||
| 46 | } | 68 | } |
| 47 | } | 69 | } |
| @@ -36,12 +36,7 @@ class ATemplateLogic extends BaseLogic | @@ -36,12 +36,7 @@ class ATemplateLogic extends BaseLogic | ||
| 36 | */ | 36 | */ |
| 37 | public function aTemplateSave(){ | 37 | public function aTemplateSave(){ |
| 38 | //字符串截取 | 38 | //字符串截取 |
| 39 | - $this->param['head_html'] = characterTruncation($this->param['html'],'<header>','</header>'); | ||
| 40 | - $this->param['main_html'] = characterTruncation($this->param['html'],'<main>','</main>'); | ||
| 41 | - $this->param['footer_html'] = characterTruncation($this->param['html'],'<footer>','</footer>'); | ||
| 42 | - $this->param['head_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-header">','</style>'); | ||
| 43 | - $this->param['main_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-style">','</style>'); | ||
| 44 | - $this->param['footer_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-footer">','</style>'); | 39 | + $this->StringProcessing(); |
| 45 | if(isset($this->param['id'])){ | 40 | if(isset($this->param['id'])){ |
| 46 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 41 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 47 | }else{ | 42 | }else{ |
| @@ -52,7 +47,22 @@ class ATemplateLogic extends BaseLogic | @@ -52,7 +47,22 @@ class ATemplateLogic extends BaseLogic | ||
| 52 | } | 47 | } |
| 53 | return $this->success(); | 48 | return $this->success(); |
| 54 | } | 49 | } |
| 55 | - | 50 | + /** |
| 51 | + * @remark :字符串处理 | ||
| 52 | + * @name :StringProcessing | ||
| 53 | + * @author :lyh | ||
| 54 | + * @method :post | ||
| 55 | + * @time :2023/6/29 15:35 | ||
| 56 | + */ | ||
| 57 | + public function StringProcessing(){ | ||
| 58 | + //字符串截取 | ||
| 59 | + $this->param['head_html'] = characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); | ||
| 60 | + $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); | ||
| 61 | + $this->param['footer_html'] = characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'); | ||
| 62 | + $this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/style>/s'); | ||
| 63 | + $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-styles">(.*?)<\/style>/s'); | ||
| 64 | + $this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-footer">(.*?)<\/style>/s'); | ||
| 65 | + } | ||
| 56 | /** | 66 | /** |
| 57 | * @remark :修改模块状态 | 67 | * @remark :修改模块状态 |
| 58 | * @name :aTemplateStatus | 68 | * @name :aTemplateStatus |
| @@ -29,14 +29,14 @@ class BTemplateLogic extends BaseLogic | @@ -29,14 +29,14 @@ class BTemplateLogic extends BaseLogic | ||
| 29 | * @method :post | 29 | * @method :post |
| 30 | * @time :2023/6/29 9:34 | 30 | * @time :2023/6/29 9:34 |
| 31 | */ | 31 | */ |
| 32 | - public function publicTemplateLists($map,$order = 'created_at',$filed = ['*']){ | 32 | + public function publicTemplateLists($map,$order = 'created_at',$filed = ['id','name','image','created_at']){ |
| 33 | $templateModel = new Template(); | 33 | $templateModel = new Template(); |
| 34 | $lists = $templateModel->list($map,$order,$filed); | 34 | $lists = $templateModel->list($map,$order,$filed); |
| 35 | return $this->success($lists); | 35 | return $this->success($lists); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | /** | 38 | /** |
| 39 | - * @remark :获取当前选择的模板 | 39 | + * @remark :获取当前选择使用的模板 |
| 40 | * @name :getModuleTemplate | 40 | * @name :getModuleTemplate |
| 41 | * @author :lyh | 41 | * @author :lyh |
| 42 | * @method :post | 42 | * @method :post |
| @@ -47,8 +47,13 @@ class BTemplateLogic extends BaseLogic | @@ -47,8 +47,13 @@ class BTemplateLogic extends BaseLogic | ||
| 47 | $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | 47 | $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); |
| 48 | $TemplateInfo = []; | 48 | $TemplateInfo = []; |
| 49 | if($info !== false){ | 49 | if($info !== false){ |
| 50 | - //查看当前模板是否已编辑保存 | ||
| 51 | - $TemplateInfo = $this->model->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | 50 | + //查看当前模板是否已编辑保存web_template |
| 51 | + $TemplateInfo = $this->model->read([ | ||
| 52 | + 'template_id'=>$info['template_id'], | ||
| 53 | + 'source'=>$this->param['source'], | ||
| 54 | + 'project_id'=>$this->user['project_id'], | ||
| 55 | + 'source_id'=>$this->param['source_id'], | ||
| 56 | + ]); | ||
| 52 | if($TemplateInfo === false){ | 57 | if($TemplateInfo === false){ |
| 53 | //获取模板详情 | 58 | //获取模板详情 |
| 54 | $ATemplateModel = new Template(); | 59 | $ATemplateModel = new Template(); |
| @@ -91,22 +96,44 @@ class BTemplateLogic extends BaseLogic | @@ -91,22 +96,44 @@ class BTemplateLogic extends BaseLogic | ||
| 91 | * @time :2023/6/29 11:05 | 96 | * @time :2023/6/29 11:05 |
| 92 | */ | 97 | */ |
| 93 | public function templateSave(){ | 98 | public function templateSave(){ |
| 99 | + //查询当前模版是否已保存 | ||
| 100 | + $info = $this->model->read( | ||
| 101 | + [ | ||
| 102 | + 'project_id'=>$this->user['project_id'], | ||
| 103 | + 'source'=>$this->param['source'], | ||
| 104 | + 'source_id'=>$this->param['source_id'], | ||
| 105 | + 'template_id'=>$this->param['template_id'], | ||
| 106 | + ] | ||
| 107 | + ); | ||
| 108 | + if($info === false){ | ||
| 94 | //字符串截取 | 109 | //字符串截取 |
| 95 | - $this->param['head_html'] = characterTruncation($this->param['html'],'<header>','</header>'); | ||
| 96 | - $this->param['main_html'] = characterTruncation($this->param['html'],'<main>','</main>'); | ||
| 97 | - $this->param['footer_html'] = characterTruncation($this->param['html'],'<footer>','</footer>'); | ||
| 98 | - $this->param['head_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-header">','</style>'); | ||
| 99 | - $this->param['main_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-style">','</style>'); | ||
| 100 | - $this->param['footer_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-footer">','</style>'); | ||
| 101 | - if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 102 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 103 | - }else{ | 110 | + $this->StringProcessing(); |
| 104 | $this->param['project_id'] = $this->user['project_id']; | 111 | $this->param['project_id'] = $this->user['project_id']; |
| 105 | $rs = $this->model->add($this->param); | 112 | $rs = $this->model->add($this->param); |
| 113 | + }else{ | ||
| 114 | + $this->StringProcessing(); | ||
| 115 | + $rs = $this->model->edit($this->param,['id'=>$info['id']]); | ||
| 106 | } | 116 | } |
| 107 | if($rs === false){ | 117 | if($rs === false){ |
| 108 | $this->fail('error'); | 118 | $this->fail('error'); |
| 109 | } | 119 | } |
| 110 | return $this->success(); | 120 | return $this->success(); |
| 111 | } | 121 | } |
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * @remark :字符串处理 | ||
| 125 | + * @name :StringProcessing | ||
| 126 | + * @author :lyh | ||
| 127 | + * @method :post | ||
| 128 | + * @time :2023/6/29 15:35 | ||
| 129 | + */ | ||
| 130 | + public function StringProcessing(){ | ||
| 131 | + //字符串截取 | ||
| 132 | + $this->param['head_html'] = characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); | ||
| 133 | + $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); | ||
| 134 | + $this->param['footer_html'] = characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'); | ||
| 135 | + $this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/style>/s'); | ||
| 136 | + $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-styles">(.*?)<\/style>/s'); | ||
| 137 | + $this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-footer">(.*?)<\/style>/s'); | ||
| 138 | + } | ||
| 112 | } | 139 | } |
| @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\BTemplate; | @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\BTemplate; | ||
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | use App\Models\Template\TemplateModule; | 6 | use App\Models\Template\TemplateModule; |
| 7 | +use App\Models\Template\TemplateType; | ||
| 7 | 8 | ||
| 8 | class BTemplateModuleLogic extends BaseLogic | 9 | class BTemplateModuleLogic extends BaseLogic |
| 9 | { | 10 | { |
| @@ -25,4 +26,17 @@ class BTemplateModuleLogic extends BaseLogic | @@ -25,4 +26,17 @@ class BTemplateModuleLogic extends BaseLogic | ||
| 25 | $lists = $this->model->lists($map,$page,$row,$order,$filed); | 26 | $lists = $this->model->lists($map,$page,$row,$order,$filed); |
| 26 | return $this->success($lists); | 27 | return $this->success($lists); |
| 27 | } | 28 | } |
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * @remark :获取所有模块类型 | ||
| 32 | + * @name :ModuleType | ||
| 33 | + * @author :lyh | ||
| 34 | + * @method :post | ||
| 35 | + * @time :2023/6/29 14:42 | ||
| 36 | + */ | ||
| 37 | + public function ModuleType($map){ | ||
| 38 | + $typeModel = new TemplateType(); | ||
| 39 | + $lists = $typeModel->list($map); | ||
| 40 | + return $this->success($lists); | ||
| 41 | + } | ||
| 28 | } | 42 | } |
| @@ -3,13 +3,63 @@ | @@ -3,13 +3,63 @@ | ||
| 3 | namespace App\Http\Logic\Bside\BTemplate; | 3 | namespace App\Http\Logic\Bside\BTemplate; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | +use App\Models\Template\BCustomTemplate; | ||
| 6 | 7 | ||
| 7 | class CustomTemplateLogic extends BaseLogic | 8 | class CustomTemplateLogic extends BaseLogic |
| 8 | { | 9 | { |
| 9 | public function __construct() | 10 | public function __construct() |
| 10 | { | 11 | { |
| 11 | parent::__construct(); | 12 | parent::__construct(); |
| 12 | - $this->model = new Custom(); | 13 | + $this->model = new BCustomTemplate(); |
| 13 | $this->param = $this->requestAll; | 14 | $this->param = $this->requestAll; |
| 14 | } | 15 | } |
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * @remark :获取自定义模块列表 | ||
| 19 | + * @name :lists | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2023/6/29 15:46 | ||
| 23 | + */ | ||
| 24 | + public function customTemplateLists($map,$page,$row,$order = 'created_at',$filed = ['*']){ | ||
| 25 | + $lists = $this->model->lists($map,$page,$row,$order,$filed); | ||
| 26 | + return $this->success($lists); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @remark :获取当前自定义界面详情 | ||
| 31 | + * @name :customTemplateInfo | ||
| 32 | + * @author :lyh | ||
| 33 | + * @method :post | ||
| 34 | + * @time :2023/6/29 16:23 | ||
| 35 | + */ | ||
| 36 | + public function customTemplateInfo(){ | ||
| 37 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 38 | + if($info === false){ | ||
| 39 | + $this->fail('error'); | ||
| 40 | + } | ||
| 41 | + return $this->success($info); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :保存自定义界面 | ||
| 46 | + * @name :customTemplateSave | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2023/6/29 16:21 | ||
| 50 | + */ | ||
| 51 | + public function customTemplateSave(){ | ||
| 52 | + return $this->success(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * @remark :删除自定义界面 | ||
| 57 | + * @name :customTemplateDel | ||
| 58 | + * @author :lyh | ||
| 59 | + * @method :post | ||
| 60 | + * @time :2023/6/29 16:21 | ||
| 61 | + */ | ||
| 62 | + public function customTemplateDel(){ | ||
| 63 | + return $this->success(); | ||
| 64 | + } | ||
| 15 | } | 65 | } |
app/Http/Logic/Bside/TemplateLogic.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Logic\Bside; | ||
| 4 | - | ||
| 5 | -use App\Models\RouteMap; | ||
| 6 | -use App\Models\Template\Template; | ||
| 7 | -use App\Models\Template\BSetting; | ||
| 8 | -use App\Models\Template\BTemplate; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @author:dc | ||
| 12 | - * @time 2023/5/15 13:57 | ||
| 13 | - * Class TemplateLogic | ||
| 14 | - * @package App\Http\Logic\Bside | ||
| 15 | - */ | ||
| 16 | -class TemplateLogic extends BaseLogic | ||
| 17 | -{ | ||
| 18 | - public function __construct() | ||
| 19 | - { | ||
| 20 | - parent::__construct(); | ||
| 21 | - | ||
| 22 | - $this->model = new BTemplate(); | ||
| 23 | - $this->param = $this->requestAll; | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - /** | ||
| 28 | - * @param $param | ||
| 29 | - * @return array | ||
| 30 | - * @throws \App\Exceptions\AsideGlobalException | ||
| 31 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 32 | - * @author:dc | ||
| 33 | - * @time 2023/5/12 9:54 | ||
| 34 | - */ | ||
| 35 | - public function save($param) | ||
| 36 | - { | ||
| 37 | - | ||
| 38 | - // 查询 | ||
| 39 | - $data = $this->first($param['data_source'],$param['data_source_id']); | ||
| 40 | - if($data){ | ||
| 41 | - $param['id'] = $data['id']; | ||
| 42 | - }else{ | ||
| 43 | - $param['template_id'] = BSetting::_get($this->user['project_id'])['template_id']; | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - return parent::save($param); | ||
| 47 | - | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - /** | ||
| 52 | - * 状态修改 | ||
| 53 | - * @param $source | ||
| 54 | - * @param $source_id | ||
| 55 | - * @param $status | ||
| 56 | - * @return mixed | ||
| 57 | - * @throws \App\Exceptions\AsideGlobalException | ||
| 58 | - * @throws \App\Exceptions\BsideGlobalException | ||
| 59 | - * @author:dc | ||
| 60 | - * @time 2023/5/15 14:41 | ||
| 61 | - */ | ||
| 62 | - public function status($source,$source_id,$status){ | ||
| 63 | - | ||
| 64 | - $data = $this->first($source,$source_id); | ||
| 65 | - | ||
| 66 | - if(!$data){ | ||
| 67 | - $this->fail('数据不存在'); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - $data->status = $status; | ||
| 71 | - | ||
| 72 | - return $data->save(); | ||
| 73 | - | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - | ||
| 77 | - /** | ||
| 78 | - * @param $source | ||
| 79 | - * @param $source_id | ||
| 80 | - * @return mixed | ||
| 81 | - * @author:dc | ||
| 82 | - * @time 2023/5/15 14:49 | ||
| 83 | - */ | ||
| 84 | - public function first($source,$source_id) | ||
| 85 | - { | ||
| 86 | - $data = BTemplate::where([ | ||
| 87 | - 'project_id'=>$this->user['project_id'], | ||
| 88 | - 'data_source' => $source, | ||
| 89 | - 'data_source_id' => $source_id, | ||
| 90 | - 'template_id' => BSetting::_get($this->user['project_id'])['template_id'] | ||
| 91 | - ])->first(); | ||
| 92 | - if(empty($data)){ | ||
| 93 | - $data = Template::where([ | ||
| 94 | - 'id' => BSetting::_get($this->user['project_id'])['template_id'] | ||
| 95 | - ])->first(); | ||
| 96 | - } | ||
| 97 | - return $data; | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - | ||
| 101 | - /** | ||
| 102 | - * @remark :使用模版并保存数据 | ||
| 103 | - * @name :usingTemplates | ||
| 104 | - * @author :lyh | ||
| 105 | - * @method :post | ||
| 106 | - * @time :2023/6/27 15:26 | ||
| 107 | - */ | ||
| 108 | - public function usingTemplates(){ | ||
| 109 | - //获取模版详情 | ||
| 110 | - $asideTemplateModel = new Template(); | ||
| 111 | - $templateInfo = $asideTemplateModel->read(['id'=>$this->param['template_id']]); | ||
| 112 | - if($templateInfo === false){ | ||
| 113 | - $this->fail('当前模版不存在或已被删除'); | ||
| 114 | - } | ||
| 115 | - $bSettingTemplateModel = new BSetting(); | ||
| 116 | - //查看用户模版是否已使用过 | ||
| 117 | - $param = [ | ||
| 118 | - 'template_id'=>$this->param['template_id'], | ||
| 119 | - 'project_id'=>$this->user['project_id'] | ||
| 120 | - ]; | ||
| 121 | - $bSettingTemplateInfo = $bSettingTemplateModel->read($param); | ||
| 122 | - //当前用户选择模版并关联 | ||
| 123 | - if($bSettingTemplateInfo === false){ | ||
| 124 | - $rs = $bSettingTemplateModel->add($param); | ||
| 125 | - if($rs === false){ | ||
| 126 | - $this->fail('error'); | ||
| 127 | - } | ||
| 128 | - } | ||
| 129 | - return $this->success($templateInfo); | ||
| 130 | - } | ||
| 131 | -} |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | -namespace App\Http\Requests\Bside; | 3 | +namespace App\Http\Requests\Bside\Template; |
| 4 | 4 | ||
| 5 | use App\Models\Template\ATemplateHtml; | 5 | use App\Models\Template\ATemplateHtml; |
| 6 | use Illuminate\Foundation\Http\FormRequest; | 6 | use Illuminate\Foundation\Http\FormRequest; |
| 7 | -use Illuminate\Validation\Rule; | ||
| 8 | 7 | ||
| 9 | -/** | ||
| 10 | - * @author:dc | ||
| 11 | - * @time 2023/5/15 14:04 | ||
| 12 | - * Class TemplateRequest | ||
| 13 | - * @package App\Http\Requests\Bside\Nav | ||
| 14 | - */ | 8 | + |
| 15 | class TemplateRequest extends FormRequest | 9 | class TemplateRequest extends FormRequest |
| 16 | { | 10 | { |
| 17 | 11 | ||
| @@ -34,6 +28,8 @@ class TemplateRequest extends FormRequest | @@ -34,6 +28,8 @@ class TemplateRequest extends FormRequest | ||
| 34 | { | 28 | { |
| 35 | return [ | 29 | return [ |
| 36 | 'html'=>'required', | 30 | 'html'=>'required', |
| 31 | + 'source'=>'required', | ||
| 32 | + 'source_id'=>'required', | ||
| 37 | 'template_id'=>'required', | 33 | 'template_id'=>'required', |
| 38 | 'section_list_id'=>'required', | 34 | 'section_list_id'=>'required', |
| 39 | ]; | 35 | ]; |
| @@ -44,6 +40,8 @@ class TemplateRequest extends FormRequest | @@ -44,6 +40,8 @@ class TemplateRequest extends FormRequest | ||
| 44 | return [ | 40 | return [ |
| 45 | 'html.required'=>'请填写html', | 41 | 'html.required'=>'请填写html', |
| 46 | 'template_id.required'=>'模版id不能为空', | 42 | 'template_id.required'=>'模版id不能为空', |
| 43 | + 'source.required'=>'类型不能为空', | ||
| 44 | + 'source_id.required'=>'类型ID不能为空', | ||
| 47 | 'section_list_id.required'=>'所选择的模块', | 45 | 'section_list_id.required'=>'所选择的模块', |
| 48 | ]; | 46 | ]; |
| 49 | } | 47 | } |
app/Models/Template/TemplateType.php
0 → 100644
| @@ -245,24 +245,21 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -245,24 +245,21 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 245 | Route::any('/getPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getPublicTemplate'])->name('template_getPublicTemplate'); | 245 | Route::any('/getPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getPublicTemplate'])->name('template_getPublicTemplate'); |
| 246 | //设置默认主题模版 | 246 | //设置默认主题模版 |
| 247 | Route::any('/setPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setPublicTemplate'])->name('template_setPublicTemplate'); | 247 | Route::any('/setPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setPublicTemplate'])->name('template_setPublicTemplate'); |
| 248 | - | 248 | + //保存修改后的模版 |
| 249 | + Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'save'])->name('template_save'); | ||
| 249 | // 模板 | 250 | // 模板 |
| 250 | Route::prefix('module')->group(function () { | 251 | Route::prefix('module')->group(function () { |
| 251 | //获取所有左侧模版 | 252 | //获取所有左侧模版 |
| 252 | Route::any('/', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'lists'])->name('template_module_lists'); | 253 | Route::any('/', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'lists'])->name('template_module_lists'); |
| 254 | + Route::any('/type', [\App\Http\Controllers\Bside\Template\BTemplateModuleController::class, 'getType'])->name('template_module_getType'); | ||
| 253 | }); | 255 | }); |
| 254 | }); | 256 | }); |
| 255 | - | ||
| 256 | - | ||
| 257 | // 自定义页面,专题页 | 257 | // 自定义页面,专题页 |
| 258 | Route::prefix('custom')->group(function () { | 258 | Route::prefix('custom')->group(function () { |
| 259 | - Route::get('/', [\App\Http\Controllers\Bside\CustomController::class, 'index'])->name('bside_custom'); | ||
| 260 | - Route::post('/create', [\App\Http\Controllers\Bside\CustomController::class, 'save'])->name('bside_custom_create'); | ||
| 261 | - Route::post('/update', [\App\Http\Controllers\Bside\CustomController::class, 'save'])->name('bside_custom_update'); | ||
| 262 | - Route::delete('/delete', [\App\Http\Controllers\Bside\CustomController::class, 'delete'])->name('bside_custom_delete'); | ||
| 263 | - Route::any('/html/{id}', [\App\Http\Controllers\Bside\CustomController::class, 'html'])->where('id', '\d+')->name('bside_custom_delete'); | 259 | + Route::any('/', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'lists'])->name('custom_lists'); |
| 260 | + Route::any('/save', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'save'])->name('custom_save'); | ||
| 261 | + Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del'); | ||
| 264 | }); | 262 | }); |
| 265 | - | ||
| 266 | // 导航栏编辑 | 263 | // 导航栏编辑 |
| 267 | Route::prefix('nav')->group(function () { | 264 | Route::prefix('nav')->group(function () { |
| 268 | Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav'); | 265 | Route::get('/', [\App\Http\Controllers\Bside\NavController::class, 'index'])->name('bside_nav'); |
-
请 注册 或 登录 后发表评论