作者 Your Name
... ... @@ -6,6 +6,8 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\CustomTemplateLogic;
use App\Http\Requests\Bside\Template\CustomTemplateRequest;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateLog;
/**
* @remark :自定义模块
... ... @@ -107,4 +109,22 @@ class CustomTemplateController extends BaseController
$customTemplateLogic->saveHtml();
$this->response('success');
}
/**
* @remark :获取自定义界面的保存记录
* @name :getCustomTemplateLog
* @author :lyh
* @method :post
* @time :2024/4/23 11:07
*/
public function getCustomTemplateLog(BTemplateLog $bTemplateLog){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'ID不能为空',
]);
$this->map['source'] = 9;
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row);
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
... ... @@ -39,38 +39,43 @@ class BTemplateLogLogic extends BaseLogic
$this->fail('error');
}
$bTemplateModel = new BTemplate();
if($info['template_id'] == 0){//定制项目
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
return $this->success();
}
//演示项目,不允许其他号码编辑
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
//获取当前项目的模版
if($info['template_id'] == 0){//todo::定制项目
$condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id'],'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],$condition);
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$info['type'],'project_id'=>$this->user['project_id']]);
return $this->success();
}
//TODO::非定制项目,获取当前项目的模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先选择模版');
}
//切换模版
if($info['template_id'] != $settingInfo['template_id']){
$bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);
}
try {
//切换模版
if($info['template_id'] != $settingInfo['template_id']){
$bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);
}
$data = $this->setParam($info);
$bTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id'],'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
$bTemplateModel->edit($data,$condition);
//还原头部+底部
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
//更新所有界面的other
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$info['type'],'project_id'=>$this->user['project_id']]);
if(!empty($info['other'])){
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
}else{
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
... ...
... ... @@ -417,7 +417,7 @@ class BTemplateLogic extends BaseLogic
}
//更新头部信息
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
return $this->success();
... ... @@ -646,7 +646,7 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/8/23 11:16
*/
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom = 0,$is_list = 0,$type = 0){
if($is_custom != BTemplate::IS_NO_CUSTOM){
return true;
}
... ... @@ -657,6 +657,7 @@ class BTemplateLogic extends BaseLogic
'text'=>$html,
'type'=>$type,
'is_custom'=>$is_custom,
'is_list'=>$is_list,
'source'=>$source,
'source_id'=>$source_id,
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
... ...
... ... @@ -364,4 +364,5 @@ class CustomTemplateLogic extends BaseLogic
}
return $this->success($data);
}
}
... ...
... ... @@ -396,6 +396,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/saveHtml', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'saveHtml'])->name('custom_saveHtml');
Route::any('/statusNum', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'statusNumber'])->name('custom_statusNum');
Route::any('/del', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'del'])->name('custom_del');
Route::any('/getCustomTemplateLog', [\App\Http\Controllers\Bside\Template\CustomTemplateController::class, 'getCustomTemplateLog'])->name('custom_getCustomTemplateLog');
});
// 菜单组
Route::prefix('nav_group')->group(function () {
... ...