VisualizationLogic.php
3.2 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
<?php
/**
* @remark :
* @name :VisualizationLogic.php
* @author :lyh
* @method :post
* @time :2023/11/15 10:09
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Visualization\Visualization;
class VisualizationLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Visualization();
$this->param = $this->requestAll;
}
/**
* @remark :保存定制html
* @name :saveHtml
* @author :lyh
* @method :post
* @time :2023/11/15 10:12
*/
public function saveVisualization(){
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->model->add($this->param);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :可视化装修获取html
* @name :getHtml
* @author :lyh
* @method :post
* @time :2023/11/15 11:30
*/
public function getHtml(){
//查询可视化是否第一次保存
$bTemplateModel = new BTemplate();
$TemplateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
]);
if($this->param['source'] == 2){
if($this->param['source_id'] == 0){$source = 3;}else{$source = 2;}
}
if($this->param['source'] == 3){
if($this->param['source_id'] == 0){$source = 5;}else{$source = 4;}
}
if($this->param['source'] == 4){
if($this->param['source_id'] == 0){$source = 7;}else{$source = 6;}
}
if($TemplateInfo === false){
$info = $this->model->read(['source'=>$source],['html','source','id','project_id']);
if($info === false){
$this->fail('请先上传定制代码块');
}
return $info['html'];
}
return $TemplateInfo['html'];
}
/**
* @remark :保存定制项目可视化
* @name :saveHtml
* @author :lyh
* @method :post
* @time :2023/11/15 11:47
*/
public function saveHtml(){
$bTemplateModel = new BTemplate();
$templateInfo = $bTemplateModel->read([
'source'=>$this->param['source'],
'project_id'=>$this->user['project_id'],
'source_id'=>$this->param['source_id'],
]);
try {
if($templateInfo === false){
$bTemplateModel->add($this->param);
}else{
$bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
}
}catch (\Exception $e){
$this->fail('系统错误请联系管理员');
}
return $this->success();
}
}