BTemplateModuleRandomLogic.php
2.1 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
<?php
/**
* @remark :
* @name :BTemplateModuleRandomLogic.php
* @author :lyh
* @method :post
* @time :2025/5/27 15:36
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Template\TemplateModuleRandom;
class BTemplateModuleRandomLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new TemplateModuleRandom();
$this->param = $this->requestAll;
}
/**
* @remark :保存为随机模块
* @name :saveRandomModule
* @author :lyh
* @method :post
* @time :2025/5/27 15:38
*/
public function saveRandomModule(){
//查询当前uuid是否已存在
$info = $this->model->read(['project_id'=>$this->user['project_id'],'uuid'=>$this->param['uuid'],'module_id'=>$this->param['module_id']]);
try {
if($info === false){
//执行新增数据
$this->model->add($this->param);
}else{
//执行编辑
$this->model->edit(['html'=>$this->param['html']],['id'=>$this->param['id']]);
}
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
/**
* @remark :获取当前项目的所有随机模块
* @name :getRandomList
* @author :lyh
* @method :post
* @time :2025/5/27 15:59
*/
public function getRandomList(){
$data = $this->model->list(['project_id'=>$this->user['project_id']],'id',['id','uuid','project_id','module_id']);
return $this->success($data);
}
/**
* @remark :获取当前模块是否为随机模块
* @name :getIsRandomModule
* @author :lyh
* @method :post
* @time :2025/5/27 15:47
*/
public function getRandomInfo(){
$info = $this->model->read(['project_id'=>$this->user['project_id'],'uuid'=>$this->param['uuid'],'module_id'=>$this->param['module_id']]);
if($info === false){
$info = [];
}
return $this->success($info);
}
}