BTemplateLogLogic.php
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
/**
* @remark :
* @name :BTemplateLogLogic.php
* @author :lyh
* @method :post
* @time :2023/8/23 11:54
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateLog;
use App\Models\Template\Setting;
class BTemplateLogLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new BTemplateLog();
$this->param = $this->requestAll;
}
/**
* @remark :回滚版本
* @name :saveRollbackVersion
* @author :lyh
* @method :post
* @time :2023/8/23 11:55
*/
public function saveRollbackVersion(){
//获取当前数据详情
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('error');
}
$bTemplateModel = new BTemplate();
//演示项目,不允许其他号码编辑
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
//获取当前项目的模版
$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 {
$data = $this->setParam($info);
$BTemplateModel = new BTemplate();
$BTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
//同步更新公共头和底
return $this->success();
}
/**
* @remark :设置回滚参数
* @name :setParam
* @author :lyh
* @method :post
* @time :2023/8/23 14:18
*/
public function setParam($info){
$data = [
'main_html'=>$info['main_html'],
'main_css'=>$info['main_css'],
];
return $this->success($data);
}
/**
* @remark :设置回滚公共参数参数
* @name :setParam
* @author :lyh
* @method :post
* @time :2023/8/23 14:18
*/
public function setCommonParam($info){
$data = [
'head_html'=>$info['head_html'],
'head_css'=>$info['head_css'],
'footer_html'=>$info['footer_html'],
'footer_css'=>$info['footer_css'],
];
return $this->success($data);
}
/**
* @remark :获取数据详情
* @name :templateLogInfo
* @author :lyh
* @method :post
* @time :2023/9/19 14:42
*/
public function templateLogInfo(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('当前数据不存在,或已被删除');
}
$serviceSettingModel = new ServiceSettingModel();
$list = $serviceSettingModel->list(['type'=>2],'created_at');
$data = [
'info' => $info,
'header_footer'=>$list,
];
return $this->success($data);
}
}